Sandundhammika's Blog











Hi all,

This is my first program on OpenGL with using GLUT library and under windows.

I had used the GNU C compiler ‘gcc’ to compile this.

#include <stdlib.h>

#define GLUT_DISABLE_ATEXIT_HACK ;; this is a dirty hack,but we have to do this.
#include <GL/gl.h>
#include <GL/glut.h>

void renderScene(void);

int main (int argc , char ** argv)
{
	glutInit(&argc , argv);
	glutInitWindowPosition( 100,100);
	glutInitWindowSize( 320,320);
	glutInitDisplayMode(GLUT_DEPTH |GLUT_SINGLE | GLUT_RGBA );
	glutCreateWindow( "OpenGL Window");
	glutDisplayFunc( renderScene);
	glutMainLoop();

}

void renderScene( void)
{
	glClear ( GL_COLOR_BUFFER_BIT);
	glLineWidth( 3);
	glEnable ( GL_LINE_SMOOTH);
	glBegin(GL_LINE_LOOP);
		glVertex3f(-0.75,-0.75,0);
		glVertex3f(0.75,-0.75, 0);
		glVertex3f(0.0,0.9,0);

	glEnd();
	glBegin(GL_LINE_LOOP);
		glVertex3f(-0.75,0.75,0);
		glVertex3f(0.75,0.75,0);
		glVertex3f( 0.0,-0.9,0);
	glEnd();
	glFlush();
}

And this is how it visible on the screen.

opengl star glut

glut opengl star

Do it yourself and comment.

and on Backtrack linux live CD version this compiles without any change in the source code.

see,

and even without compiling.Using wine win32 emulator,

–happy coding–

Advertisements


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

et cetera
%d bloggers like this: