Right I've been trying to start a simple window for ages now, it just gives:
1>LINK : fatal error LNK1104: cannot open file 'freeglut.lib'
Whatever I try.
Copied the files to VC/include/GL directories, included the path in additional dependancies in Linker->general->additional includes but nothing.
I keep reading about 'Making' the file when I download freeGLUT but when I open the VS file in C:\freeglut-2.8.1\VisualStudio\2010 and try to build it I get the same error (unable to open freeglut.lib).
I even tried the following I read on a forum:
#define FREEGLUT_STATIC
#define _LIB
#define FREEGLUT_LIB_PRAGMAS=0
//You need that FREEGLUT_STATIC to let GLUT know that it's linking statically. Otherwise it looks for a DLL.
that just thows the following error
\sample.cpp(30): error C2008: '=' : unexpected in macro definition
\sample.cpp(30): warning C4005: 'FREEGLUT_LIB_PRAGMAS' : macro redefinition
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\gl\freeglut_std.h(51) : see previous definition of 'FREEGLUT_LIB_PRAGMAS'
What am I doing wrong guys I'm getting really fed up of this, please can someone help?
The code i'm using is as follows:
#include <stdio.h>
#include <stdlib.h>
#if defined(__APPLE__)
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif
#define NENDS 2 /* number of end "points" to draw */
GLdouble width, height; /* window width and height */
int wd; /* GLUT window handle */
int ends[NENDS][2]; /* array of 2D points */
/* Program initialization NOT OpenGL/GLUT dependent,
as we haven't created a GLUT window yet */
void
init(void)
{
width = 1280.0; /* initial window width and height, */
height = 800.0; /* within which we draw. */
ends[0][0] = (int)(0.25*width); /* (0,0) is the lower left corner */
ends[0][1] = (int)(0.75*height);
ends[1][0] = (int)(0.75*width);
ends[1][1] = (int)(0.25*height);
}
/* Callback functions for GLUT */
/* Draw the window - this is where all the GL actions are */
void
display(void)
{
int i;
/* clear the screen to white */
glClearColor(1.0, 1.0, 1.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
/* draw a black line */
glColor3f(0.0, 0.0, 0.0);
glBegin(GL_LINES);
for (i = 0; i < NENDS; ++i) {
glVertex2iv((GLint *) ends);
}
glEnd();
glFlush();
}
/* Called when window is resized,
also when window is first created,
before the first call to display(). */
void
reshape(int w, int h)
{
/* save new screen dimensions */
width = (GLdouble) w;
height = (GLdouble) h;
/* tell OpenGL to use the whole window for drawing */
glViewport(0, 0, (GLsizei) width, (GLsizei) height);
/* do an orthographic parallel projection with the coordinate
system set to first quadrant, limited by screen/window size */
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, width, 0.0, height);
}
int
main(int argc, char *argv[])
{
/* perform initialization NOT OpenGL/GLUT dependent,
as we haven't created a GLUT window yet */
init();
/* initialize GLUT, let it extract command-line
GLUT options that you may provide
- NOTE THE '&' BEFORE argc */
glutInit(&argc, argv);
/* specify the display to be single
buffered and color as RGBA values */
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA);
/* set the initial window size */
glutInitWindowSize((int) width, (int) height);
/* create the window and store the handle to it */
wd = glutCreateWindow("Experiment with line drawing" /* title */ );
/* --- register callbacks with GLUT --- */
/* register function to handle window resizes */
glutReshapeFunc(reshape);
/* register function that draws in the window */
glutDisplayFunc(display);
/* start the GLUT main loop */
glutMainLoop();
return 0;
}