Hello. Did anyone manage to create anything more than an opengl 3.0 context? I have no problem creating the forward-compatible context, but I don’t know how to render anything without gl*Pointer calls.
Could anyone provide me with some example code e.g. rendering a triangle?
You use glVertexAttribPointer instead of glPointer calls. To get index either bind names of attributes to specific index’es before linking shader, or get them by glGetAttribLocation after linking. It is same as rendering in OGL 2.1 context without glPointer calls.
Wow did they do away with there stupid vertex attribute rule that you need to have glVertex placed in position 0 IIRC with GL3? and now you can place it where ever you want?
Forward compatible context has no predefined gl_Vertex attribute. You must define all attributes by yourself. And obviously you can bind any generic attribute to any index you want.
But anyway - even in my GL 2.1 code I do not use any of predefined gl_xxx vertex attributes. I always bind all attributes (position, normal, texcoords, …) myself, so I will need not to change much in code when I move to GL 3.0 forward compatbile context. Had no problems binding vertex_position to any index I want. Works fine on Mobility X1600, HD2400, 8400M GS, under Windows (GL 2.1 context).
The only issue with the 0 vertex attribute is when you are using the immediate mode (with glVertexAttrib*(), no “*Pointer” functions) because the vertex is ‘assembled’ for rendering at the 0 attribute location call.
I wish we have some kind of “glBindUniformLocation” to be able to set every variable locations …
If you’ve made a 3.0 forward-compatible context, you must use VBOs and VAOs. The spec says (in the Deprecation Model chapter):
“Calling VertexAttribPointer when no buffer object or no
vertex array object is bound will generate an INVALID OPERATION error,
as will calling any array drawing command when no vertex array object is
bound.”
I really appreciate all the help given to me in this topic, <s>however it still doesn’t want to work for me despite having newest drivers installed.</s>
<s>There is one last thing I suspect - I cannot use PFNGLGENVERTEXARRAYSPROC, I have to use PFNGLGENVERTEXARRAYSAPPLEPROC. Is it a bad thing or are they equivalent?</s>
THANKS! I finally figured it out. As it turns out, after some desperate fixes, I didn’t uncomment the glUseProgram call. As a result, I hadn’t had the shader bound while rendering.
Well, I can understand this, but OpenGL 3 specs says that shaders versions 1.10 and 1.20 are deprecated (obviously for forward-compatible context), with LoadIdentity, LoadMatrix and related GL routines.
Finally, I’m wondering how simply translate vertex positions without model view matrix routines (and most of the builtin uniform state. May I missed something?
Is there some default vertex array object bound? I don’t have any calls to glBindVertexArray() in my entire code, yet VertexAttribPointre doesn’t give me GL_INVALID_OPERATION
Then you have some buffer object (VBO) bound. The spec there deprecated pointers to client memory area - it forces in pointer argument to pass offset in buffer object memory.