# OpenGL setting up OpenGL in VC.NET 2002

This topic is 4879 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

hi all i started a project in VC.NET, i picked on win32 application, then changed my selection to console application. here is my code:


// test1.cpp : Defines the entry point for the console application.
//

#include <windows.h>
#include "stdafx.h"
#include <iostream>
//#include <gl/gl.h>
//#include <gl/glu.h>
#include <gl/glut.h>

using namespace std;

int main()
{

std::cout << "this is a test" << endl;
return 0;
}


you'll notice i have gl and glu.h commented out. this is why i get all these errors when i try to build the application...it seems like all of the errors that the compiler does not like is in gl.h saying stuff about WINGDIAPI and APIENTRY and how it is a redefinition... funny how glut didnt give me any trouble. also even though i have glut.h included how do i add the .lib files to the project? i am SO used to VC6 that this is a little bit different. thank you so much for your time and help..

##### Share on other sites
To add the libraries, either do:

#pragma comment ( lib, "glu32.lib" )#pragma comment ( lib, "opengl32.lib" )#pragma comment ( lib, "glut.lib" )

or (as that is compiler specific) go to Projects -> Properties, Linker, Command Line, and add the 3 libraries above (this is in 2003, but I'm sure it's similar).

As for commenting out gl/glu headers... You don't need to manually include them if you have glut. If you look in glut.h, you'll see it includes gl/glu already for you.

Try adding the libraries and rebuilding. Make sure you have choosen a Win32 Console Application. If there's still errors, post them.

##### Share on other sites
That's an odd error indeed. Try removing the precompiled headers, that's the only thing I can think of that would be the problem there. Either remove them, or move the inclusion of windows.h to after the precompiled header has been included.
I usually have precompiled headers first, then the standard C++ libraries, then API libraries (Win32, GL, Glut, SDL, etc.), then custom project headers.

Can I ask why you have "using namespace std;" and then are using "std::cout", also?

##### Share on other sites
Never include windows.h if you already include glut.h! You also don't need gl.h and glu.h if you use glut.

Good luck,
Pat.

##### Share on other sites
Quote:
 Original post by DogganTry adding the libraries and rebuilding. Make sure you have choosen a Win32 Console Application. If there's still errors, post them.

I can't see this being a problem with the libraries, because they're the last thing to be linked into the project. If it were a problem with libraries, it'd be a linker error, not a compile-time error.

##### Share on other sites
Quote:
 or (as that is compiler specific) go to Projects -> Properties, Linker, Command Line, and add the 3 libraries above (this is in 2003, but I'm sure it's similar).As for commenting out gl/glu headers... You don't need to manually include them if you have glut. If you look in glut.h, you'll see it includes gl/glu already for you.Try adding the libraries and rebuilding. Make sure you have choosen a Win32 Console Application. If there's still errors, post them.

hi again.. thanks for your input, i deleted the window, gl and glu.h lines. however i do not see where Project->Properties is. properties is not in projects..VC6 it was like this and as you say 2003.. but its not set up that way in 2002..evidently..

i am still looking, i havent stopped.. any ideas? anyone out there use .NET 2002?

##### Share on other sites
You need to be creating a Win32 GDI app I believe. The console applications are text only, so OGL won't do you much good.

Console apps don't include GDI stuff, thats the WINGDIAPI error.

Start over as a non-console win32 app.

##### Share on other sites
i dont want to use just a win32 app b/c i want to write something with glut and something that is portable. as someone said, glut.h include the gl and glu headers so that worked out well.

i see where i can go to projects->properties.. but i dont see the link tab/selection to add the libraries to the command line...:(

##### Share on other sites
here is my updated code.. it looks like all the lib files were already included.. including glut32.lib. here is my code.. it compiles fine, 0 errors and 0 warnings, but no window opens up.. i just get the print out to the console...

// test1.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include <iostream>#include <gl/glut.h>using namespace std;void draw() {	glClear(GL_COLOR_BUFFER_BIT);	glBegin(GL_TRIANGLES);		glVertex3f(-0.5,-0.5,0.0);		glVertex3f(0.5,0.0,0.0);		glVertex3f(0.0,0.5,0.0);	glEnd();	glFlush();}int main(int argc, char **argv){	std::cout << "this is a test" << endl;	glutInit(&argc, argv);	glutInitDisplayMode(GLUT_DEPTH | GLUT_SINGLE | GLUT_RGBA);	glutInitWindowPosition(100,100);	glutInitWindowSize(320,320);	glutCreateWindow("3D Tech- GLUT Tutorial");	glutDisplayFunc(draw);        glutMainLoop(); //<--- forgot to add this per last post :)	return 0;}

[Edited by - OpenGL_Guru on February 14, 2005 8:21:06 PM]

##### Share on other sites
Quote:
 Original post by OpenGL_Gurui dont want to use just a win32 app b/c i want to write something with glut and something that is portable. as someone said, glut.h include the gl and glu headers so that worked out well.i see where i can go to projects->properties.. but i dont see the link tab/selection to add the libraries to the command line...:(

Oh, right. Sorry, somehow it slipped my mind what glut was there for :)

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 15
• 13
• 9
• 12
• 10
• ### Forum Statistics

• Total Topics
631442
• Total Posts
3000089
×