PDA

View Full Version : Objects aren't always drawn



Shelling
03-15-2008, 01:57 PM
Hey guys,

i know, it's not really good to come in a forum as a newby and directly ask something, but i just don't find the answer by searching in the web.

(I'm sorry if my english is a bit bad, i hopy you can understand it though^^)

So, my problem is the following thing. Due to a school project, i write a little graphic engine using OpenGL. It works quite fine, but since I added support for using Displaylists something odd happens.

The engine should just, at the moment, show a triangle and the current fps. I have tested that on 13 PCs, but only on 7 PCs is the triangle shown. However, The fps counter is always shown.

So I gave an other version to these "Non triangle testers" to determine where the error is. Surprisingly, there is no error. All the data is the same as by the testers, who have a triangle. Even glGetError always returns 0.

I will post some code, maybe it helps you to determine the error, because i can't see it.

The function to add an object:


void CDevice::AddSingleObject(Vertex *Vertices, int Count)
{
C3DObject *NewObject;

NewObject=new C3DObject;

NewObject->CreateMeshes(1);
NewObject->Meshes[0].CreateMesh(Vertices,Count);

NewObject->Next=NULL;
NewObject->Prev=LastObject;
LastObject->Next=NewObject;
LastObject=NewObject;

}


The function to create a mesh for an object:


void CMesh::CreateMesh(Vertex *Vertices, int Count)
{
int i;

this->Vertices=new Vertex[Count];
AmountVertices=Count;

for(i=0;i<Count;i++)
{
this->Vertices[i].X=Vertices->X;
this->Vertices[i].Y=Vertices->Y;
this->Vertices[i].Z=Vertices->Z;
Vertices++;
}
}


The function to create a displaylist:


bool CMesh::BuildDisplayList()
{
int i;

Object=glGenLists(1);

glNewList(this->Object,GL_COMPILE);

glBegin(GL_TRIANGLES);

for(i=0;i<AmountVertices;i++)
{
glVertex3f(this->Vertices[i].X,this->Vertices[i].Y,this->Vertices[i].Z);
}

glEnd();

glEndList();

return (this->Object==NULL) ? false : true;
}


And maybe a download link to the engine Link (http://www.ewetel.net/~anita.wilken1/wigfx.exe)

Do you have any idea why the triangle is only shown on some pc and not on all?

Thanks in advance,
Shelling

ZbuffeR
03-15-2008, 02:36 PM
Check that you request (and get) a double buffered GL context.

Try this :
http://glintercept.nutty.org/download.html
This tool can help you debug your gl calls.

Shelling
03-15-2008, 03:13 PM
Ah, thanks a lot, i will try this program as soon as I can.

But (unfortunatly?) I think I get a double bufferd GL context. In some earlier versions of the engine, which also just drew a triangle, but using glBegin and glEnd in a draw loop, everything works fine. Only the version with the Displaylist causes this problem and I didn't change anything at the creating of a GL context.

In the earlier versions i got a double buffered context (I forgot the SwapBuffers function once and only got a black window, so there had to be 2 buffers, or?), so i didn't think of it.

//EDIT:
Well, i tried the program you gave me. It tells me that i'm using a few OpenGL commands without having a context. I'm using 2 Threads, one for rendering and another for input and message handling ect. But in the code i wrote, i first set the window dimensions, than create the window, getting the device and OpenGL context and finally initialize OpenGL... there should be no GL command executted without context....

//EDIT2:
Just remembered.. did i forgot to mention it? Anyways, it can't be a problem with the double buffer i think. The engine includes a fps counter which is always visible, every tester can see it. The only thing that's not drawn is the white triangle.

So, when you start the program, you either see a fps counter AND a white triangle, or you will see just the fps counter...

quite funny i think... erm... yes... good night for now^^

greets,
Shelling

Shelling
03-16-2008, 10:18 AM
Ok, that's kind of funny^^

I tested a bit and cutted out the use of a displaylist and glPushMatrix and glPopMatrix, just to see whats happening. When i cutted out the glPushMatrix and glPopMatrix function calls, nothing changes.

But when i replaced the glCalllist function call with 3 glVertex3f calls to create my triangle, every tester could see a triangle. So it seems like the displaylist makes some trouble, but i can't imagine why.

It isn't the fact that the displaylist is a member of an other class, because nothing changes when i created it in the same class as the render function.

It isn't the fact that displaylist aren't supported, because an other program, that uses displaylists as well works perfectly, plus, my fps counter uses also displaylists.

Thats it for now... maybe you can give me a hint or something like that..

greets
Shelling

PS: Why couldn't i edit my old post?