basically I am trying to write a OpenGL3 compatible renderer, but since the Open Source radeon driver just supports OpenGL1.5 I have to use vp/fp instead of GLSL.
I already managed to write a simple shader and to load it. Now I want to push some external data into it like the Model-View-Matrix, which is the following in OpenGL3:
int loc = glGetUniformLocation(programObject, “name”);
glUniformMatrix4fv(loc, 1, GL_FALSE, identity);
I also would like to know whether there is a function closer to glVertexAttribPointer than glVertexPointer?
Generally I am looking for a tutorial which explains a vp/fp based render and also has some documentation for the assembly language.
Or if you have any other tips how to develop a OpenGL3 render with the OSS stack, they are welcome. Speed does not matter yet.
glProgramStringARB
glGenProgramsARB
glBindProgramARB
glDeleteProgramsARB
glProgramLocalParameter4fARB
glProgramLocalParameter4fvARB
glProgramLocalParameters4fvEXT // very nifty, but not always available. Loop with glProgramLocalParameter4fvARB if not available
** compiler you need:
cgc
** parameters to the compiler:
thanks that is exactly what I was looking for. But I have one more question. What is the best way to feed in the attribute Variables? I guess it is still glVertexPointer, glNormalPointer etc. since there is no concept of Attributes yet?
And I could use glProgramLocalParameters4fvEXT throughout, since it is available in the OSS MESA drivers
Yes, you’re stuck with the glNormalPointer, etc.
Ps: but you can still be putting the attribs in the 8 tex-coords, instead of using glNormalPtr/glColorPtr .
Ah, since you’ll be specifying attribs via those glVertexPtr/etc, the “ATTR1” semantics in the shader-code should be actually “TEXCOORD0” or whatever the cgc docs specify.
I guess it is still glVertexPointer, glNormalPointer etc. since there is no concept of Attributes yet?
ARB_vertex_program was where they first introduced generic attributes. You are perfectly capable of using them with ARB_vertex_programs: just use ATTR#, where # is the attribute index.
Maybe it’s not available to him even as an extension o_O (however unlikely) ?
P.S. Anyway, even like that you can make your code remap attributes: use just the glVertexPointer and glTexCoordPtr, call attrib0=vtxPtr, attrib1…8=texcoordptr in a wrapper-func; have this macro in the shader:
#define attrib0(a) attribute a : POSITION;
#define attrib1(a) attribute a : TEXCOORD0;
#define attrib2(a) attribute a : TEXCOORD1;
..
#define attrib8(a) attribute a : TEXCOORD7;
glVertexAttribPointerARB is available, but I am still not sure how to correctly use it, since I cannot find any good documentation on it.
Right now I am doing:
// load the interleaved buffer
glBindBuffer(GL_ARRAY_BUFFER, vbo);
// set the vertex pointer to the correct offset
glVertexPointer(3, GL_FLOAT, 8*sizeof(float), (void*)(5*sizeof(float)));
// render the triangle
glDrawArrays(GL_TRIANGLES, 0, 3);
and the data is accessible as POSITION in the shader.
if I try instead:
// load the interleaved buffer
glBindBuffer(GL_ARRAY_BUFFER, vbo);
// set the attrib pointer to the correct offset
glVertexAttribPointerARB(0, 3, GL_FLOAT, false, 8*sizeof(float), (void*)(5*sizeof(float)));
// render the triangle
glDrawArrays(GL_TRIANGLES, 0, 3);
and try to access the data through ATTR0 it does not work.
Anything I have forgotten and should do?
Have you bound attribute names in the program object to the right generic vertex attribute index? Take a look at glBindAttribLocation if it not already done.
In the source, I specified “attribute vec4 a : ATTR0;”
If I had specified “attribute vec4 a : POSITION;” , it would have used “vertex.position” instead of “vertex.attrib[0]”.