WTF is wrong with my first GL code ??

Started by
5 comments, last by Estor 20 years, 8 months ago
Hi Last week i did try to run this example but it is not workin like it shold and i dont have any more ideas what is wrong. Problem is that: when i resize window GL is not drawing any more, but DrawGLScene function is CALLED !!!!!! Please help... Here is link to VC++ source
"The Gods Made Heavy Metal And They Saw That It Was Good They Said To Play It Louder Than Hell We Promised That We WouldWhen Losers Say Its Over With You Know That It's A Lie The Gods Made Heavy Metal And It's Never Gonna Die"THE GODS MADE HEAVY METAL/by ManOwaR
Advertisement
i had the same problem some time ago ... cant remember what the error was, but check your wndproc i think it has something to do with that (display your width/height in your WM_SIZE event and check if its correct, in my case the app drew the scene after resizing but with totally wrong x/y sizes - which seems to be nothing)...

...zapata
Nope, I have this at WM_SIZE:
      case WM_SIZE:         height = HIWORD(lParam);         width = LOWORD(lParam);         GL_ErrorMsg (0, "height %d    width %d", height, width);         if (!height)            height=1;                  glViewport(0, 0, width ,height);         glMatrixMode(GL_PROJECTION);         glLoadIdentity();         gluPerspective(45.0f,(GLfloat)width/(GLfloat)height, 0.1f, 100.0f);         glMatrixMode(GL_MODELVIEW);         glLoadIdentity();         return 0;

I made test (GL_ErrorMsg prints data to msgbox)... every thing looks fine 8(
And when window is created DrawGLAScene renders to window, correctly. I can move window and every thing is ok, until i resize it


[edited by - Estor on August 9, 2003 11:34:53 AM]

[edited by - Estor on August 9, 2003 11:35:34 AM]
"The Gods Made Heavy Metal And They Saw That It Was Good They Said To Play It Louder Than Hell We Promised That We WouldWhen Losers Say Its Over With You Know That It's A Lie The Gods Made Heavy Metal And It's Never Gonna Die"THE GODS MADE HEAVY METAL/by ManOwaR
your resize proc is fine ... i got bad experience with getting the instance more than 1 time .. dont know why this should cause the error but try to get the instance once on start and then always use your variable your stored the instance ...
The first time the WM_SIZE message is passed to the app the GL context hasn''t been fully setup yet, so calls you are making are being ignored... hence the projection matrix is Identity when you draw the quad... Resize the window and the WM_SIZE message is handled with a valid context, hence the projection matrix is actually setup this time... but to a projection matrix not an identity matrix...

Move the WM_SIZE code into a differnt function, and call it at the end of the initalization code.

| - Project-X - On hold.. - | - adDeath - | - email me - |
Thanks will try...




"The Gods Made Heavy Metal And They Saw That It Was Good
They Said To Play It Louder Than Hell We Promised That We Would
When Losers Say Its Over With You Know That It’s A Lie
The Gods Made Heavy Metal And It’s Never Gonna Die"

THE GODS MADE HEAVY METAL/by ManOwaR
"The Gods Made Heavy Metal And They Saw That It Was Good They Said To Play It Louder Than Hell We Promised That We WouldWhen Losers Say Its Over With You Know That It's A Lie The Gods Made Heavy Metal And It's Never Gonna Die"THE GODS MADE HEAVY METAL/by ManOwaR
Heh... now it looks fine... it resizes
now WM_SIZE looks like this
      case WM_SIZE:         height = HIWORD(lParam);         width = LOWORD(lParam);         if (!height)            height=1;         w = (float) width;         h = (float) height;         glViewport(0, 0, width ,height);

And all resize code (glMatrixMode, glLoadIdentity and other... i initialize after wglCreateContext but before wglMakeCurrent.
I dont realy know why when I called functions after wglMakeCurrent it was not drawing.
Thanks for help...

I made test with NeHe Tut... i downloaded source for lesson 1 (most code of my source is from this tutorial) from NeHe i paste my GL_DrawScene to NeHe tutorial source code, it was nat drawing quad too





"The Gods Made Heavy Metal And They Saw That It Was Good
They Said To Play It Louder Than Hell We Promised That We Would
When Losers Say Its Over With You Know That It’s A Lie
The Gods Made Heavy Metal And It’s Never Gonna Die"

THE GODS MADE HEAVY METAL/by ManOwaR

[edited by - Estor on August 10, 2003 6:30:49 AM]
"The Gods Made Heavy Metal And They Saw That It Was Good They Said To Play It Louder Than Hell We Promised That We WouldWhen Losers Say Its Over With You Know That It's A Lie The Gods Made Heavy Metal And It's Never Gonna Die"THE GODS MADE HEAVY METAL/by ManOwaR

This topic is closed to new replies.

Advertisement