Terribly odd display when using shader and glDrawRangeElements on a Powerbook G4

applmak
Unregistered
 
Post: #1
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:

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(),genericVertex​Buffer.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.wid​th()-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
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
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.
Quote this message in a reply
applmak
Unregistered
 
Post: #3
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.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #4
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.
Quote this message in a reply
applmak
Unregistered
 
Post: #5
I did try that, but it doesn't fix the problem.

Thanks for the suggestion, though.

Matt
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  ios/mac shader - shared glsl source OptimisticMonkey 2 5,313 Jun 17, 2011 08:59 AM
Last Post: OptimisticMonkey
  passing values from vertex to fragment shader Sumaleth 6 11,128 Feb 18, 2011 01:54 AM
Last Post: Holmes
  Changing Uniform Variables for a Single Shader reapz 3 5,576 Jul 15, 2010 01:29 AM
Last Post: dazza
  Vertex shader particle billboarding question TomorrowPlusX 3 5,711 Sep 15, 2008 06:46 AM
Last Post: TomorrowPlusX
  GLSL Shader getting corrupted Weebull 4 4,673 Jun 23, 2008 03:43 PM
Last Post: Weebull