Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Weird behaviour with glPolygonMode
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gentoo on PPC
View previous topic :: View next topic  
Author Message
zerebubuth
n00b
n00b


Joined: 20 May 2006
Posts: 1

PostPosted: Sat May 20, 2006 7:43 pm    Post subject: Weird behaviour with glPolygonMode Reply with quote

On my system the following program gives some weird results:

Code:

#include <stdio.h>
#include <stdlib.h>
#include <GL/glut.h>

float theta = 45.0f;
float phi = 45.0f;

void drawSphere(double radius) {
  GLUquadric *quad = gluNewQuadric();
  gluQuadricDrawStyle(quad, GLU_FILL);
  gluSphere(quad, radius, 20, 10);
  gluDeleteQuadric(quad);
}

void init() {
   glClearColor(1.0f, 1.0f, 1.0f, 0.0f);

   glEnable(GL_DEPTH_TEST);
   glDepthFunc(GL_LEQUAL);
   glClearDepth(1.0f);
}

void drawFilledSphere() {
   // draw lines in front, black
   glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
   glColor3f(0.0f, 0.0f, 0.0f);
   drawSphere(1.0);
}

void drawWireframeSphere() {
   // draw filled red sphere
   glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
   glColor3f(1.0f, 0.0f, 0.0f);
   drawSphere(0.7);
}

void display()
{
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   glLoadIdentity();

   gluLookAt(
      0.0f, 0.0f, 3.0f,
      0.0f, 0.0f, 0.0f,
      0.0f, 1.0f, 0.0f);

   glRotatef(theta, 1.0f, 0.0f, 0.0f);
   glRotatef(phi, 0.0f, 1.0f, 0.0f);

#ifndef BROKEN
   drawFilledSphere();
   drawWireframeSphere();
#else
   drawWireframeSphere();
   drawFilledSphere();
#endif

   glFlush();
   glutSwapBuffers();
}

void resize(int w, int h)
{
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();

   glViewport(0, 0, w, h);

   gluPerspective(45.0f, 1.0f * w / h, 1.0f, 100.0f);

   glMatrixMode(GL_MODELVIEW);
   glLoadIdentity();
}

void keyboard(unsigned char key, int x, int y) {
  switch(key) {
  case 27 :
   exit(1); break;
  }
}

int main(int argc, char *argv[]) {
   glutInit(&argc, argv);

   glutInitWindowPosition(50, 50);
   glutInitWindowSize(500, 500);

   glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
   
#ifndef BROKEN
   glutCreateWindow("Not Broken");
#else
   glutCreateWindow("Broken");
#endif

   glutDisplayFunc(display);
   glutKeyboardFunc(keyboard);
   glutReshapeFunc(resize);

   init();
   glutMainLoop();

   return 0;
}


When I compile up normally it shows what I expect: a small red sphere surrounded by a larger, black, wireframe sphere. When I compile with -DBROKEN all I see is a large black sphere.

I don't know if this is because I'm using OpenGL wrong (although the problem is also in the glviewer FOX toolkit test), or because my installation, or because of my graphics card drivers (r128). Has anyone else seen these sort of problems before?

Thanks,

Zerebubuth
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gentoo on PPC All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum