Some weird problem ...

Started by
2 comments, last by Dante77 21 years, 5 months ago
I've got one major problem ... I'm coding new OpenGL engine and there's problem with rendering. I've made some high-resolution timer and message loop with WNDPROC and so on ... Engine is built using classes (why not?), but I think thats not problem ... I'm in point where I can create window, set and count exact framerate with float precison and etc., no prob.. But when it comes to rendering function (to make it easy, I put NeHe's rotating pyramid and cube from lesson05 there), it's terribly slow ... I realy do not know why ... I've got no problems running any of games (Quake III Arena, UT 2003...) and I have latest Detonator drives (GeForce 2 GTS 64MB) and whatever ... So why is it so slow??? Can sombody tell me how fast NeHe's tuts. run on your comp.??? Just to know if this isn't some weird "bug"... I think it may be SwapBuffers function (or wglSwapBuffers....) This is rendering code.... { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glTranslatef(-1.5f,0.0f,-6.0f); glRotatef(rtri,0.0f,1.0f,0.0f); glBegin(GL_TRIANGLES); glColor3f(1.0f,0.0f,0.0f); glVertex3f( 0.0f, 1.0f, 0.0f); glColor3f(0.0f,1.0f,0.0f); glVertex3f(-1.0f,-1.0f, 1.0f); glColor3f(0.0f,0.0f,1.0f); glVertex3f( 1.0f,-1.0f, 1.0f); glColor3f(1.0f,0.0f,0.0f); glVertex3f( 0.0f, 1.0f, 0.0f); glColor3f(0.0f,0.0f,1.0f); glVertex3f( 1.0f,-1.0f, 1.0f); glColor3f(0.0f,1.0f,0.0f); glVertex3f( 1.0f,-1.0f, -1.0f); glColor3f(1.0f,0.0f,0.0f); glVertex3f( 0.0f, 1.0f, 0.0f); glColor3f(0.0f,1.0f,0.0f); glVertex3f( 1.0f,-1.0f, -1.0f); glColor3f(0.0f,0.0f,1.0f); glVertex3f(-1.0f,-1.0f, -1.0f); glColor3f(1.0f,0.0f,0.0f); glVertex3f( 0.0f, 1.0f, 0.0f); glColor3f(0.0f,0.0f,1.0f); glVertex3f(-1.0f,-1.0f,-1.0f); glColor3f(0.0f,1.0f,0.0f); glVertex3f(-1.0f,-1.0f, 1.0f); glEnd(); glLoadIdentity(); glTranslatef(1.5f,0.0f,-7.0f); glRotatef(rquad,1.0f,0.0f,0.0f); glBegin(GL_QUADS); glColor3f(1.0f,0.0f,0.0f); glVertex3f( 1.0f, 1.0f,-1.0f); glColor3f(0.0f,1.0f,0.0f); glVertex3f(-1.0f, 1.0f,-1.0f); glColor3f(0.0f,0.0f,1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); glColor3f(1.0f,0.0f,0.0f); glVertex3f( 1.0f, 1.0f, 1.0f); glColor3f(1.0f,0.0f,0.0f); glVertex3f( 1.0f,-1.0f, 1.0f); glColor3f(0.0f,1.0f,0.0f); glVertex3f(-1.0f,-1.0f, 1.0f); glColor3f(0.0f,0.0f,1.0f); glVertex3f(-1.0f,-1.0f,-1.0f); glVertex3f( 1.0f,-1.0f,-1.0f); glColor3f(1.0f,0.0f,0.0f); glVertex3f( 1.0f, 1.0f, 1.0f); glColor3f(0.0f,0.0f,1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); glVertex3f(-1.0f,-1.0f, 1.0f); glColor3f(1.0f,0.0f,0.0f); glVertex3f( 1.0f,-1.0f, 1.0f); glColor3f(1.0f,1.0f,0.0f); glVertex3f( 1.0f,-1.0f,-1.0f); glVertex3f(-1.0f,-1.0f,-1.0f); glColor3f(1.0f,0.0f,0.0f); glColor3f(0.0f,0.0f,1.0f); glVertex3f(-1.0f, 1.0f,-1.0f); glVertex3f( 1.0f, 1.0f,-1.0f); glColor3f(0.0f,0.0f,1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); glColor3f(1.0f,0.0f,0.0f); glVertex3f(-1.0f, 1.0f,-1.0f); glVertex3f(-1.0f,-1.0f,-1.0f); glColor3f(0.0f,0.0f,1.0f); glVertex3f(-1.0f,-1.0f, 1.0f); glColor3f(1.0f,0.0f,0.5f); glColor3f(1.0f,0.0f,0.0f); glVertex3f( 1.0f, 1.0f,-1.0f); glColor3f(0.0f,0.0f,1.0f); glVertex3f( 1.0f, 1.0f, 1.0f); glVertex3f( 1.0f,-1.0f, 1.0f); glColor3f(0.0f,0.0f,1.0f); glVertex3f( 1.0f,-1.0f,-1.0f); glEnd(); rtri+=2.0f; rquad-=1.5f; SwapBuffers (p_hDC); return OK; } it takes about 350 milliseconds to render ?!?!? ..... Sorry for the look of code... I'm lazy to do some formatting.... :-))) Dante77 [edited by - Dante77 on November 2, 2002 1:20:19 PM]
Dante77
Advertisement
The code you have posted runs fine. The only odd thing about it is the p_hDC in the SwapBuffers. Is it a pointer? SwapBuffers just takes the HDC unless you cast the pointer.
Yeah, and here comes sh**. If this runs fine snd smooth on your PC, then why it runs so slow on mine??
I really got no idea. All "classic" stuff works nice, but this simple code works weird (I mean that gamez, 3D Studio Max, benchmark ... all work fine).

No, no p_HDC just means:
private: HDC p_hDC

What about function glSwapBuffers??? Any dfference in functionality ??
Dante77
At this moment I cannot tell you why your program is running slow. There seems to be no problem with the code you have provided. So you must do a bit of debbuging. Elimination is the best way to handle this. First compile NeHe''s tutorial on your machine and run it. If it run''s slow then your problem is most likely not your code. If the tutorial runs fine then you need to narrow down the possibilities. Some thoughts on what could be slowing the process down is your high-resolution timer. Comment out the sections of code and run again. Another problem could be how your engine is set up. I am sorry if my answers are not percise, but the information you have provided is very limited.

This topic is closed to new replies.

Advertisement