OpenGL environment configuration in VS2008
1. Installation
Download the OpenGL installation library file online.
a. Copy the .h file to the C:\Program Files\Microsoft Visual Studio 9.0\VC\include\GL directory
b. Copy the .lib file to the C:\Program Files\Microsoft Visual Studio 9.0\VC\lib directory
c. Copy the .dll file to the C:\Windows\System32 directory
2. Configure the environment
First create a Win32 console project and configure the project properties:
(1) Project - Project Properties - Configuration Properties - C/C++ - Preprocessor - Preprocessor Definition, add
GLUT_BUILDING_LIB
(2) Project - Project Properties - Configuration Properties - Linker - Input - Additional Dependencies, add
glut32.lib Opengl32.lib Glu32.lib glaux.lib
Here is a piece of test code
#include "glos.h"#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glaux.h>
void myinit(void);
void CALLBACK myReshape(GLsizei w, GLsizei h);
void CALLBACK display(void);
void CALLBACK display(void)
{
GLdouble eqn[4] = {1.0, 0.0, 0.0, 0.0};
glClear(GL_COLOR_BUFFER_BIT);
glColor3f (1.0, 0.0, 1.0);
glPushMatrix();
glTranslatef (0.0, 0.0, -5.0);
/* clip the left part of wire_sphere : x<0 */
glClipPlane (GL_CLIP_PLANE0, eqn);
glEnable (GL_CLIP_PLANE0);
glRotatef (-90.0, 1.0, 0.0, 0.0);
auxWireSphere(1.0);
glPopMatrix();
glFlush();
}
void myinit (void)
{
glShadeModel (GL_FLAT);
}
void CALLBACK myReshape(GLsizei w, GLsizei h)
{
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0, (GLfloat) w/(GLfloat) h, 1.0, 20.0);
glMatrixMode(GL_MODELVIEW);
}
void main(void)
{
auxInitDisplayMode (AUX_SINGLE | AUX_RGB);
auxInitPosition (0, 0, 500, 500);
auxInitWindow(LPCWSTR("Arbitrary Clipping Planes"));
myinit ();
auxReshapeFunc (myReshape);
auxMainLoop(display);
}