Robotics C++ Physics II AP Physics B Electronics Java Astronomy Other Courses Summer Session  

Notes for use of C++ Express Edition

 

Step 1: Open C++ Console Applications and create a new project

 

Step 2: Link to the OpenGL libraries

 

¢  Under the Project menu select Project Properties (Alt+F7) at the bottom.

¢  Select Configuration Properties → Linker → Input from the navigation panel on the left.

¢  Select All Configurations from the Configuration drop-down box at the top of the dialog.

     This ensures you are changing the settings for both the Debug and Release configurations.

¢  Type “opengl32.lib glu32.lib” in Additional Dependencies and click OK.

 

Step 3: Insert and run the following code

 

#include "stdafx.h"

#include <GL/glut.h>

void mydisplay()

{

   glClear(GL_COLOR_BUFFER_BIT);

   glBegin(GL_POLYGON);       

   glVertex2f(-0.5, -0.5);       

   glVertex2f(-0.5, 0.5);       

   glVertex2f(0.5, 0.5);       

   glVertex2f(0.5, -0.5);   

   glEnd();

   glFlush();

}

int main(int argc, char** argv)

{

   glutCreateWindow("Simple");    

   glutDisplayFunc(mydisplay);   

   glutMainLoop();

}

Output