fendevel / guide-to-modern-opengl-functions Goto Github PK
View Code? Open in Web Editor NEWA guide to using modern OpenGL functions.
License: Creative Commons Zero v1.0 Universal
A guide to using modern OpenGL functions.
License: Creative Commons Zero v1.0 Universal
Hi, I tried to add you on Discord, so I could message you but when I entered your tag (Fen#0110) into the add friend bar there were no results. My guess is that if you had Nitro and used it to set your Discriminator, it may have run out and your discrim might have been rerandomized as a result.
Everything is in the title, your example is good but I don't understand why you use GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT.
Solution :
`GLuint vao = GL_NONE;
GLuint buffer = GL_NONE;
auto const ind_len = GLsizei(ind_count * sizeof(element_t));
auto const vrt_len = GLsizei(vrt_count * sizeof(vertex));
auto const ind_offset = vrt_len;
auto const vrt_offset = 0;
glCreateBuffers(1, &buffer);
glNamedBufferStorage(buffer, ind_len + vrt_len, nullptr, GL_DYNAMIC_STORAGE_BIT);
glNamedBufferSubData(buffer, ind_offset, ind_len, ind_data);
glNamedBufferSubData(buffer, vrt_offset, vrt_len, vrt_data);
glCreateVertexArrays(1, &vao);
glVertexArrayVertexBuffer(vao, 0, buffer, vrt_offset, sizeof(vertex));
glVertexArrayElementBuffer(vao, buffer);`
This is a very minor thing I dug details into when doing extensions.
For shader introspection, the following two function are actually defined with the extension ARB_separate_shader_objects and not ARB_direct_state_access. I think this should be mentioned in the page.
glProgramUniformXX, glProgramUniformXXv
I'm aware this is basically a non issue because if you support direct state access then you most likely support separate shader objects
Some links to the docs
https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_direct_state_access.txt
https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_separate_shader_objects.txt
Please consider adding an open source license so that people know their rights, see Choose a License for more information ๐
The README document describes the following in the following section
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
Do you probably want GL_CLAMP_TO_EDGE for these texture_wrap parameters?
https://www.khronos.org/opengl/wiki/Common_Mistakes
Never use GL_CLAMP; what you intended was GL_CLAMP_TO_EDGE. Indeed, GL_CLAMP was removed from core GL 3.1+, so it's not even an option anymore.
Excellent tutorial on the DSA features! Thank you very much for making this easily understandable.
I just want to point out that, farewell glGetError()
is not true, the new DebugMessageCallback()
does make debugging easier, but it doesn't work all the time. Sometimes it cannot catch an error even if glGetError()
returned some error code. My point is that, very often during debugging, glGetError()
can still help us a lot in finding errors, so I think we should use these two debugging functions together.
I always like to wrap glGetError()
in a function like this, then insert the call across multiple places in my code, while keeping track of each checkpoint. This can help us quickly find the line of code that triggers the error when DebugMessageCallback()
silently fails. Hope this helps!
void Log::CheckGLError(int checkpoint) {
GLenum err_code;
while ((err_code = glGetError()) != GL_NO_ERROR) {
CORE_ERROR("OpenGL error detected at checkpoint {0}: {1}", checkpoint, err_code);
}
}
There are two lines with glBindFramebuffer(fb)
, those should probably be glBindFramebuffer(GL_FRAMEBUFFER, fb)
According to the spec:
An INVALID_VALUE error is generated if width, height, depth or levels are less than 1, for commands with the corresponding parameters.
This line in your guide will generate an INVALID_VALUE error since levels is set to 0;
glTextureStorage3D(texarray, 0, GL_RGBA8, width, height, layers);
You did set it to 1 in the other examples so I'm guessing this is just a typo.
We need to use glTextureParameter to set mipmap levels. Or else the texture is incomplete.
First of all... let me just say, this modern OpenGL guide has been extremely helpful for me, so that you for putting it together.
Regarding the guidance on storing index + vertex data within a single buffer (link)
It states that:
All we need to do is store the indices before the vertex data and tell OpenGL where the vertices begin, this is achieved with glVertexArrayVertexBuffer's offset parameter.
Maybe this is no secret to some, but it eluded me for a while. It turns out it is entirely possible to reference index data from anywhere within a vertex buffer, there is no need for it to reside before/after the vertex data in particular.
Simply indicate the byte offset into the relevant buffer via the offset parameter of glDrawElements:
// Assume we have a prepopulated buffer, vertex attributes followed by index elements.
glCreateVertexArrays(1, &vao);
glVertexArrayVertexBuffer(vao, 0, buffer, buffer_size, sizeof(vertex_t));
glVertexArrayElementBuffer(vao, buffer);
size_t indices_offset = get_indices_offset(buffer);
at render time
glDrawElements(GL_TRIANGLES, indices_count, indices_format, (void *) indices_offset);
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.