Hello all,
i just started using openGl and have been using it in eclipse with glut library.
I just wrote this code. First i tried drawing a circle.Nothing came up on the screen.So to confirm,i tried rendering a rectangle.But nothing is coming up on the screen.I do not know,if it is a problem in my code, or i need some other library.can anyone kindly help me on this.
Here is my code
#include <windows.h>
#include <math.h>
#include <GL/glut.h>
const int WIDTH = 600;
const int HEIGHT = 400;
/* Prototypes */
void init();
void display();
/* Definitions */
/* Initializes the OpenGL state /
void init() {
glClearColor(0.0,0.0,0.0,0.0 ); / Set the clear color */
}
/* Displays a black clear screen */
void display() {
glClear( GL_COLOR_BUFFER_BIT ); /* Clear the screen with the clear color */
glBegin(GL_LINES); //begin
glColor3f(1.0f, 1.0f, 1.0f); //draw with this color //on blackbackground of window
glRectf(0.0f,0.0f,50.0f,50.0f);//at this loc and //width and height
glEnd();
glFlush();
glutSwapBuffers(); /* Double buffering */
}
/* The main function */
int main( int argc, char argv[] ) {
/ Glut setup function calls /
glutInit( &argc, argv );
glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGB ); / Use double buffering and RGB colors /
glutInitWindowPosition( 100, 100 );
glutInitWindowSize( WIDTH, HEIGHT );
glutCreateWindow( argv[0] );
init();
glutDisplayFunc( display ); / Call back display function /
glutMainLoop(); / Continue drawing the scene */
return 0;
}
Awaiting reply,
Many thanks