Terribly odd display when using shader and glDrawRangeElements on a Powerbook G4
Hello.
I have a Powerbook G4 with an ATI Mobility Radeon 9700. I'm writing a demonstration app that works just fine when using the fixed functionality pipeline of OpenGL; however, when I start using the shader, the GLUT window draws some random address in memory, resulting in a very odd display indeed.
I'll include a code excerpt below. You must know, however, that I'm using my own 2D array of data class called MImage. However, it's unit-tested to death, and I'm sure of its functionality. Here's the code:
The loop around the glDrawRangeElements is to ensure I don't exceed that the appropriate OpenGL limits for my card.
Anyway, this code works fine when using the fixed pipeline. However, when I enable the following shader, the window doesn't draw correctly.
What gives?
Matt
I have a Powerbook G4 with an ATI Mobility Radeon 9700. I'm writing a demonstration app that works just fine when using the fixed functionality pipeline of OpenGL; however, when I start using the shader, the GLUT window draws some random address in memory, resulting in a very odd display indeed.
I'll include a code excerpt below. You must know, however, that I'm using my own 2D array of data class called MImage. However, it's unit-tested to death, and I'm sure of its functionality. Here's the code:
Code:
//initialization
glGenBuffersARB(1,&vertexID);
//create generic vertex buffer
g = new MImage<float>(levelData[0]->width(),levelData[0]->height(),2);
MImage<float> &genericVertexBuffer = *g;
for (unsigned int j=0;j<genericVertexBuffer.height();j++)
{
for (unsigned int i=0;i<genericVertexBuffer.width();i++)
{
genericVertexBuffer(i,j,0) = i;
genericVertexBuffer(i,j,1) = j;
}
}
glBindBufferARB(GL_ARRAY_BUFFER_ARB,vertexID);
glBufferDataARB(GL_ARRAY_BUFFER_ARB,genericVertexBuffer.dataSize(),genericVertexBuffer.data(),GL_DYNAMIC_DRAW_ARB);
indices = new unsigned short[6*(genericVertexBuffer.width()-1)*(genericVertexBuffer.height()-1)];
unsigned short *indicesPtr = indices;
for (unsigned int j=0;j<genericVertexBuffer.height()-1;j++)
{
for (unsigned int i=0;i<genericVertexBuffer.width()-1;i++)
{
*(indicesPtr++) = i+j*genericVertexBuffer.width();
*(indicesPtr++) = i+1+j*genericVertexBuffer.width();
*(indicesPtr++) = i+(j+1)*genericVertexBuffer.width();
*(indicesPtr++) = i+1+j*genericVertexBuffer.width();
*(indicesPtr++) = i+(j+1)*genericVertexBuffer.width();
*(indicesPtr++) = i+1+(j+1)*genericVertexBuffer.width();
}
}
indexCount = (unsigned int)(indicesPtr-indices);
//drawing code
glEnableClientState(GL_VERTEX_ARRAY);
glBindBufferARB(GL_ARRAY_BUFFER_ARB,vertexID);
glVertexPointer(2,GL_FLOAT,0,NULL);
MImage<float> &data = *g;
for (unsigned int j=0;j<data.height()-1;j++)
{
glDrawRangeElements(GL_TRIANGLES,j*data.width(),(j+1)*data.width()+data.width()-1,indexCount/(data.height()-1),GL_UNSIGNED_SHORT,indices+6*j*(data.width()-1));
}The loop around the glDrawRangeElements is to ensure I don't exceed that the appropriate OpenGL limits for my card.
Anyway, this code works fine when using the fixed pipeline. However, when I enable the following shader, the window doesn't draw correctly.
Code:
//vertex shader
void main()
{
gl_FrontColor = gl_Color;
gl_Position = ftransform();
}
//fragment shader
void main()
{
gl_FragColor = gl_Color;
}What gives?
Matt
Have you tried the shader in isolation, using the GLSLEditorSample that comes with the developer tools? That'll tell you whether it's your setup or the shader itself.
The PowerPC OpenGL drivers haven't been updated since 10.4.3, it seems, so GLSL is likely to be rather buggy.
The PowerPC OpenGL drivers haven't been updated since 10.4.3, it seems, so GLSL is likely to be rather buggy.
Yep. It's nearly the simplest shader imaginable.
Ack! Buggy drivers! No support! Death....
It seems like something is wrong with the driver. When I use immediate mode, I have no problem. It's only when I use VBOs + glDrawRangeElements + a shader that things start acting up. Very odd.
Thanks for your reply.
Ack! Buggy drivers! No support! Death....
It seems like something is wrong with the driver. When I use immediate mode, I have no problem. It's only when I use VBOs + glDrawRangeElements + a shader that things start acting up. Very odd.
Thanks for your reply.
As always, file a bug report -- http://bugreport.apple.com/
Also, try ditching the DrawRangeElements for DrawElements... I've heard a few complaints about DrawRangeElements recently.
Also, try ditching the DrawRangeElements for DrawElements... I've heard a few complaints about DrawRangeElements recently.
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| ios/mac shader - shared glsl source | OptimisticMonkey | 2 | 4,400 |
Jun 17, 2011 08:59 AM Last Post: OptimisticMonkey |
|
| passing values from vertex to fragment shader | Sumaleth | 6 | 8,624 |
Feb 18, 2011 01:54 AM Last Post: Holmes |
|
| Changing Uniform Variables for a Single Shader | reapz | 3 | 4,467 |
Jul 15, 2010 01:29 AM Last Post: dazza |
|
| Vertex shader particle billboarding question | TomorrowPlusX | 3 | 4,756 |
Sep 15, 2008 06:46 AM Last Post: TomorrowPlusX |
|
| GLSL Shader getting corrupted | Weebull | 4 | 3,844 |
Jun 23, 2008 03:43 PM Last Post: Weebull |
|

