Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

nraiyani

What's wrong with this code

This topic is 6540 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

//****************************************************** GLfloat x,y,z,angle; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glPushMatrix(); glRotatef(xRot, 1.0f, 0.0f, 0.0f); glRotatef(yRot, 0.0f, 1.0f, 0.0f); // Call only once for all remaining points glBegin(GL_LINE_STRIP); z = -50.0f; for(angle = 0.0f; angle <= (2.0f*GL_PI)*3.0f; angle += 0.1f) { x = 50.0f*sin(angle); y = 50.0f*cos(angle); // Specify the point and move the Z value up a little glVertex3f(x, y, z); z += 0.5f; } // Done drawing points glEnd(); // Restore transformations glPopMatrix(); glFinish(); SwapBuffers(wglGetCurrentDC()); //-------------------------------------------------------- If Nothing is wrong why do i get the following error ----> EZeroDivide with ''Floating point division by zero''. Any though will be Appreciated.

Share this post


Link to post
Share on other sites
Advertisement
There is no division so the problem is not explicit in the code.

I had some problem with
SwapBuffers(wglGetCurrentDC());
(OpenGL-Win32 does not work )

Try to GetDC when you create the window and then use the same HDC and use it every time you swap buffers...

// create window and setup OpenGL
...
HDC hDC;
...
hDC = GetDC(hwnd); // hwnd is your window handle
...


// rendering loop
...
SwapBuffers(hDC);
...

It seems strange but on my system is not the same thing!

Share this post


Link to post
Share on other sites
That''s what i did, i keep getting the same error at

// Specify the point and move the Z value up a little
glVertex3f(x, y, z);
z += 0.5f; <-----This Line

Share this post


Link to post
Share on other sites
Now I don''t know anything about OpenGl, but what does the vertexing function do?

Because you are starting Z at a negative value, so eventually it''ll probably reach 0. Just put in something like..

z += 0.5f;
if (z==0) z=0.5f;

See if that fixes it.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!