OpenGL setting up OpenGL in VC.NET 2002

Recommended Posts

OpenGL_Guru    104
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
Doggan    528
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
Mercury    776
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
darookie    1441
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
Mercury    776
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
OpenGL_Guru    104
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
Ravyne    14300
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
OpenGL_Guru    104
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
OpenGL_Guru    104
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
Ravyne    14300
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 :)

Share on other sites
OpenGL_Guru    104
hey guys i forgot to add the glutMainLoop() call.. it all works now.. i have to work on the glutIdleFunc() but i got it rendering...

here is the deal just in case you are wondering...maybe i should make a new thread of how to get openGL set up in .NET2002..

go to Tools --> Options

a tree to the left gives you a list. click on projects. a sub tree expands.
click VC++ Directories.

now you will get 2 drop down menus at the top.

in the show directories drop down menu, scroll down to library files.
by default(at least in mine) the default VC.NET lib and include files are already there but this is where you would add new .lib files or any other include files if you would like to do that and save you space at the top of your header files. this is what i have found out. thanks you guys for your help :)

Create an account

Register a new account

• Similar Content

• By cebugdev
hi all,

i am trying to build an OpenGL 2D GUI system, (yeah yeah, i know i should not be re inventing the wheel, but this is for educational and some other purpose only),
i have built GUI system before using 2D systems such as that of HTML/JS canvas, but in 2D system, i can directly match a mouse coordinates to the actual graphic coordinates with additional computation for screen size/ratio/scale ofcourse.
now i want to port it to OpenGL, i know that to render a 2D object in OpenGL we specify coordiantes in Clip space or use the orthographic projection, now heres what i need help about.
1. what is the right way of rendering the GUI? is it thru drawing in clip space or switching to ortho projection?
2. from screen coordinates (top left is 0,0 nd bottom right is width height), how can i map the mouse coordinates to OpenGL 2D so that mouse events such as button click works? In consideration ofcourse to the current screen/size dimension.
3. when let say if the screen size/dimension is different, how to handle this? in my previous javascript 2D engine using canvas, i just have my working coordinates and then just perform the bitblk or copying my working canvas to screen canvas and scale the mouse coordinates from there, in OpenGL how to work on a multiple screen sizes (more like an OpenGL ES question).
lastly, if you guys know any books, resources, links or tutorials that handle or discuss this, i found one with marekknows opengl game engine website but its not free,
Just let me know. Did not have any luck finding resource in google for writing our own OpenGL GUI framework.
IF there are no any available online, just let me know, what things do i need to look into for OpenGL and i will study them one by one to make it work.
thank you, and looking forward to positive replies.

• I have a few beginner questions about tesselation that I really have no clue.
The opengl wiki doesn't seem to talk anything about the details.

What is the relationship between TCS layout out and TES layout in?
How does the tesselator know how control points are organized?
e.g. If TES input requests triangles, but TCS can output N vertices.
What happens in this case?
http://www.informit.com/articles/article.aspx?p=2120983
the isoline example TCS out=4, but TES in=isoline.
And gl_TessCoord is only a single one.
So which ones are the control points?
How are tesselator building primitives?
• By Orella
I've been developing a 2D Engine using SFML + ImGui.
Here you can see an image
The editor is rendered using ImGui and the scene window is a sf::RenderTexture where I draw the GameObjects and then is converted to ImGui::Image to render it in the editor.
Now I need to create a 3D Engine during this year in my Bachelor Degree but using SDL2 + ImGui and I want to recreate what I did with the 2D Engine.
I've managed to render the editor like I did in the 2D Engine using this example that comes with ImGui.
3D Editor preview
But I don't know how to create an equivalent of sf::RenderTexture in SDL2, so I can draw the 3D scene there and convert it to ImGui::Image to show it in the editor.
If you can provide code will be better. And if you want me to provide any specific code tell me.
Thanks!

• Hi
I'm new to learning OpenGL and still learning C. I'm using SDL2, glew, OpenGL 3.3, linmath and stb_image.
I started following through learnopengl.com and got through it until I had to load models. The problem is, it uses Assimp for loading models. Assimp is C++ and uses things I don't want in my program (boost for example) and C support doesn't seem that good.
Things like glVertexAttribPointer and shaders are still confusing to me, but I have to start somewhere right?
I can't seem to find any good loading/rendering tutorials or source code that is simple to use and easy to understand.
I have tried this for over a week by myself, searching for solutions but so far no luck. With tinyobjloader-c and project that uses it, FantasyGolfSimulator, I was able to actually load the model with plain color (always the same color no matter what I do) on screen and move it around, but cannot figure out how to use textures or use its multiple textures with it.
I don't ask much: I just want to load models with textures in them, maybe have lights affect them (directional spotlight etc). Also, some models have multiple parts and multiple textures in them, how can I handle those?
Are there solutions anywhere?
Thank you for your time. Sorry if this is a bit confusing, English isn't my native language

• FINALLY, upgrading my engine to openGL 4. I was having some trouble so I started with a stripped down application and was wondering if VAO's are required, because I have a sample working, but if I remove the VAO then it doesn't seem to like drawing my triangle.

• 31
• 14
• 9
• 15
• 9