Been a long time since i last posted here. How is everyone hehe.
Lately ive been reading on some openGL stuff and need some help with a simple program. My problem is that i cant get the cylinder to be displayed, i only get 3 warnings but then there is nothing on the screen.
Code:
#include <stdio.h>
#include <GL/glut.h>
int wf = 1; /*wireframe*/
void display()
{
/*clear window*/
glClear (GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glLineWidth(2.0);
glColor3f(0.5, 1.0, 0.1);
}
void Idelfunc()
{
glutPostRedisplay();
}
void init()
{
/*set clear color to black*/
glClearColor (0.0, 0.0, 0.0, 0.0);
/*set fill color to yellow*/
glColor3f(0.0, 0.6, 0.9);
{
glEnable (GL_DEPTH_TEST);
glCullFace(GL_BACK);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
}
/*Cylinder*/
{
void Cylinder (double height, double radius, int slices, int stacks);
GLUquadricObj* cyl;
cyl = gluNewQuadric();
gluQuadricDrawStyle(cyl, GLU_LINE);
gluCylinder(cyl, 3, 3, 5, 12, 12);
}
}
void keys (unsigned char key1, int x, int y)
{
switch (key1)
{
//view in wireframe
case 'v':
wf = 1-wf;
if (wf)
{
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
}
else
{
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
}
glutPostRedisplay();
break;
case 'q':
if (key1 =='q' || key1 =='Q' ||key1 =='\27') exit(0);
}
}
int main( int argc, char** argv)
{
/*initialize mode and open a window in upper-left corner of screen*/
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE |GLUT_RGB);
glutInitWindowSize(500, 500);
glutInitWindowPosition(0,0);
glutCreateWindow("Cylinder");
glutDisplayFunc(display);
init();
// glutReshapeFunc(myreshape);
glutIdleFunc(Idelfunc);
glutKeyboardFunc(keys);
glutMainLoop();
}