PDA

View Full Version : Vert Arrays + Cg shader = crash, seperately work fine



game_cy
05-29-2007, 08:23 AM
Hello,
I have had this weird bug with Cg fragment shader and vertex arrays ( blue screen bug (http://www.opengl.org/discussion_boards/ubb/ultimatebb.php?ubb=get_topic;f=11;t=001369#000000) ) for a while now.

I have managed to reduce it to this:
-The shader works fine when I render stuff in immediate mode.
-The Vertex arrays render fine when not using shader.
-I get bluescreen on my laptop, crashes on other peoples pcs when I try to use them in combination.


I have made a sample test case that demonstrates this , you can d/l it from here ( test (http://www.cs.ucy.ac.cy/~ssotos/shots/fragtest.zip) )

Can anyone suggest what I might be doing wrong?

B.

Jackis
05-29-2007, 08:39 AM
Commonly, it happens when you enable some vertex attrib arrays and forget to set their pointers, or they violate buffer's data storage.
Immediate mode doesn't fall, because it gets attribute value as it were set very last (or zero if no calls were made).
Check, whether all your pointers setup is correct.

game_cy
05-29-2007, 08:57 AM
I have tested the indexes when loading from my maya exported files and they had no errors and still I got the same bug. Also, I have been using this 3DS loader for some years now and I am 99.9% sure that there is no problem with the data. Tested with various models also.

The weird thing is that it renders a few frames, then hangs.

here is my Vertex arrays rendering code


void CMesh::RenderPerPixel()
{
// if (m_ShadowPass==1) { RenderDepthPass(); return; }

glDisable(GL_TEXTURE_2D);
gCgMan.BasicPerPixelEnable();

glEnableClientState(GL_INDEX_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY); // added this now, makes no difference

glVertexPointer(3, GL_FLOAT, 0, m_pVert);
glNormalPointer( GL_FLOAT, 0, m_pNorm);


// glLockArraysEXT(0, m_numVerts);

glDrawElements(GL_TRIANGLES, m_numIdxs, GL_UNSIGNED_INT, m_pIdx);
// glUnlockArraysEXT();
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_INDEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);

gCgMan.BasicPerPixelDisable();

}

Jackis
05-29-2007, 10:35 AM
Excuse me, but for what actually do you need INDEX_ARRAY?
When you enable it - it means that you want to use some single-valued color index.
INDEX_ARRAY is not indices array specification )))

game_cy
05-29-2007, 11:40 AM
Yep GL_INDEX_ARRAY was the problem It wasted more than a few days of my time.
It's been there for years and didn't cause any problems until shaders where added.

Well done Jackis

knackered
05-29-2007, 01:44 PM
what did you think it meant?????

game_cy
05-30-2007, 08:15 AM
I knew it was for color indexes, I read about it so many times here and other places...
It just sliped my attention....
too much copy paste programming
... four eyes are always better than two :)

knackered
05-30-2007, 08:38 AM
you're not much of a "comment-out-build-comment-out-build" debugger then?

game_cy
06-03-2007, 07:36 AM
knackered ofcourse I comment out stuff. . but usually commenting out stuff creates more bugs, in fact it creates bugs even if you correct the original problem, and you dont even notice what the problem was, you just create new bugs.
how about you? you are not much of a team player then?