Jump to content
  • Advertisement
Sign in to follow this  

OpenGL Problem with Displaying with glutSwapBuffers()

This topic is 4079 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

I have created a Sphere tree and am trying to display that using the following code. void DisplayScene() { typedef PassData CommunicateData; CommunicateData Data; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Compute the Bounding Box and the Centre of the Point Cloud ComputeBoundingBox(pointlist, Data.BoundingBox, Data.Centre, NumPoints); Data.eyePosition[0] = 0.0f; Data.eyePosition[1] = 0.0f; Data.eyePosition[2] = 10.0f; Data.eyePosition[3] = 1.0f; float LookAt[3] = {Data.eyePosition[0], Data.eyePosition[1], Data.eyePosition[2] - 10.0f }; #ifdef CG_RENDERING buildLookAtMatrix(Data.eyePosition[0], Data.eyePosition[1], Data.eyePosition[2], LookAt[0], LookAt[1], LookAt[2], 0, 1, 0, Data.viewMatrix); #endif #ifdef OPENGL_RENDERING glMatrixMode(GL_MODELVIEW); gluLookAt(Data.eyePosition[0], Data.eyePosition[1], Data.eyePosition[2], LookAt[0], LookAt[1], LookAt[2], 0, 1, 0); #endif BreadthFirstTraversal(&SpTreeRoot, 0, true, ROOT_LEVEL, &DisplaySphereScene, (void *)&Data); glutSolidSphere(3, 40, 40); glutSwapBuffers(); } // void DisplaySphereScene(float position[], float viewMatrix[], float eyePosition[]) bool DisplaySphereScene(SphereTreeNode *node, void *StructureData) { // Here we will be sending the Data in the form of a structure. // Hence we will be typecasting the Structure so as to match the data we get. typedef PassData Pdata; float scaleFactor[3]; Pdata *IncomingData = (Pdata *)StructureData; const float lightPosition[4] = { 5.0f, 10.0f, 0.0f, 1.0f}; #ifdef OPENGL_RENDERING glPushMatrix(); glEnable(GL_LIGHT0); glLightfv(GL_LIGHT0, GL_AMBIENT, yellow); glLightfv(GL_LIGHT0, GL_DIFFUSE, yellow); glLightfv(GL_LIGHT0, GL_SPECULAR, red); glLightfv(GL_LIGHT0, GL_POSITION, lightPosition); glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 12); glutSolidSphere(3, 40, 40); glPopMatrix(); // DrawCube(IncomingData->BoundingBox); #endif // Display the Current Node Data return true; } /////////////////////////////////////////////////////////////////////////////// End of Code /////////////////////////////////////////////////////////////////////////////// The problem I am facing is that my display function using Glut is DisplayScene() above. I then call a tree traversal code which then uses a function pointer to call the DisplaySphereScene() function. The problem is that when I try to display a sphere in the DisplaySphereScene() function it is not displayed. However, a sphere being drawn in the DisplaySphere() function is rendered. I can't understand why I am not able to render spheres in the DisplaySphereScene() function. I would really appreciate the help. Thanks

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • 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!