March 5, 2002
Visual C++, jag har GLUT-grejerna 😉
OBS detta är taget ifrån en annan sida, jag bara experimenterar 🙂
#include <windows.h>
#include <glut.h>
#include <stdio.h>
#include <stdlib.h>
void init ( void )
{
glEnable ( GL_DEPTH_TEST );
glClearColor ( 0.0, 0.0, 0.0, 0.0 );
}
void display ( void ) // Used to draw stuff to the screen
{
glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
// Draw a single point
glColor4f(1.0, 1.0, 0.0, 1.0);
glPushMatrix ( );
glBegin(GL_POINTS);
glPointSize(5.0);
glVertex3f(0.f,0.f,0.f);
glEnd();
glPopMatrix ( );
glutSwapBuffers ( );
}
void reshape (int w, int h)
{
// w inneholder bredden på skjermen 1280
glViewport (0, 0, (GLsizei) w, (GLsizei) h);
glMatrixMode (GL_PROJECTION);
glLoadIdentity();
if (w <= h)
glOrtho (-1.5, 1.5, -1.5*(GLfloat)h/(GLfloat)w, 1.5*(GLfloat)h/(GLfloat)w, -10.0, 10.0);
else
glOrtho (-1.5*(GLfloat)w/(GLfloat)h, 1.5*(GLfloat)w/(GLfloat)h, -1.5, 1.5, -10.0, 10.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void keyboard ( unsigned char key, int x, int y ) // This is the keyboard input method
{
switch ( key ) {
case 27:
exit ( 0 );
break;
case 'f':
glutFullScreen ();
break;
case 'w':
glutReshapeWindow ( 500,500 );
break;
default:
break;
}
}
void myMouse(int button, int state, int x, int y) {
switch (button) {
case 0:
switch(state) {
case 0: // MouseDown (Left)
break;
case 1: // MouseDown (Right)
break;
}
break;
case 2:
switch(state) {
case 0: // MouseDown (Right)
break;
case 1: // MouseUp (Right)
break;
}
break;
}
}
void IdleFunc() {
display();
}
/* Main */
int main ( int argc, char** argv )
{
glutInit ( &argc, argv );
glutInitDisplayMode ( GLUT_RGB | GLUT_DOUBLE ); // Initialize double buffered display
glutInitWindowSize ( 500, 500 ); // Set the window size to 250x250 pixels
glutCreateWindow ( argv[0] ); // Open the window
init(); // Initialize stuff
glutReshapeFunc ( reshape ); // Method used to create the perspective view (makes stuff look 3Dish)
glutKeyboardFunc ( keyboard ); // Method to handle keyboard input
glutMouseFunc ( myMouse ); // Method to handle mouse input
glutDisplayFunc ( display ); // Method that displays stuff on the screen
glutIdleFunc ( IdleFunc ); // Idle Function
glutMainLoop ( ); // Keep program running in a loop until exit
return 0; // return
}
Detta fungerar inte att kompilera, av någon anledning.
Linking...
C:ProgramMicrosoft Visual StudioVC98LIBglut32.lib : warning LNK4003: invalid library format; library ignored
C:ProgramMicrosoft Visual StudioVC98LIBglut32.lib : warning LNK4003: invalid library format; library ignored
simple_app.obj : error LNK2001: unresolved external symbol _glutSwapBuffers@0
simple_app.obj : error LNK2001: unresolved external symbol _glutReshapeWindow@8
simple_app.obj : error LNK2001: unresolved external symbol _glutFullScreen@0
simple_app.obj : error LNK2001: unresolved external symbol _glutMainLoop@0
simple_app.obj : error LNK2001: unresolved external symbol _glutIdleFunc@4
simple_app.obj : error LNK2001: unresolved external symbol _glutDisplayFunc@4
simple_app.obj : error LNK2001: unresolved external symbol _glutMouseFunc@4
simple_app.obj : error LNK2001: unresolved external symbol _glutKeyboardFunc@4
simple_app.obj : error LNK2001: unresolved external symbol _glutReshapeFunc@4
simple_app.obj : error LNK2001: unresolved external symbol _glutCreateWindow@4
simple_app.obj : error LNK2001: unresolved external symbol _glutInitWindowSize@8
simple_app.obj : error LNK2001: unresolved external symbol _glutInitDisplayMode@4
simple_app.obj : error LNK2001: unresolved external symbol _glutInit@8
Debug/simple_app.exe : fatal error LNK1120: 13 unresolved externals
Error executing link.exe.simple_app.exe - 14 error(s), 2 warning(s)
1 Guest(s)