PDA

View Full Version : Can I do OpenGL in Console programs ???



ajaytemp
02-03-2004, 08:33 AM
The sample tutorials are not Windows programs. They seem to be console programs. However when I try to compile them they do give an error in Visual C++ 6.0. I'm running WindowsXP.

Can someone explain why I can't use OpenGL in console programs and why are the tutorial programs written like that?

-AJ

dorbie
02-03-2004, 08:47 AM
What error?

What do you mean by console programs? main() vs winmain()?
That won't be your problem.

stonemetal
02-03-2004, 12:01 PM
What sample programs are you talking about NeHe's are all windows programs. The red book uses glut wich creats a window as well.

ajaytemp
02-03-2004, 03:50 PM
What do you mean by console programs? main() vs winman()?

That is exactly what I mean.


What error?

I forgot what error it was, i can still get it for you if you want it.

Can someone give me an OpenGL console program that will compile in Visual C++ 6.0 and run on WindowsXP.



What sample programs are you talking about NeHe's are all windows programs.
http://www.eecs.tulane.edu/www/Terry/OpenGL/Examples/Hello_World.c

ajaytemp
02-03-2004, 03:54 PM
ok my program is like this:



#include <gl\gl.h>

void main()
{
}


I get these errors:


--------------------Configuration: openGlTEST - Win32 Debug--------------------
Compiling...
opengltest.cpp
c:\microsoft visual studio\vc98\include\gl\gl.h(1152) : error C2144: syntax error : missing ';' before type 'void'
c:\microsoft visual studio\vc98\include\gl\gl.h(1152) : error C2501: 'WINGDIAPI' : missing storage-class or type specifiers
c:\microsoft visual studio\vc98\include\gl\gl.h(1152) : fatal error C1004: unexpected end of file found
Error executing cl.exe.

openGlTEST.exe - 3 error(s), 0 warning(s)

chowe6685
02-03-2004, 04:52 PM
try including windows.h explicity before gl.h

nexusone
02-04-2004, 03:53 AM
This example is written for Linux X windows, not windows:
Requires a library called Tk which may not be a version of it written for windows, need to check on it though.
Also the examples on that webpage are also almost 7 years old.

http://www.eecs.tulane.edu/www/Terry/OpenGL/Examples/Hello_World.c [/B][/QUOTE]


If you want a good source for openGL under windows, nehe.gamedev.net is a good resource.

Your bit of code:

#include <gl\gl.h>
void main()
{
// You have a empty main with no window opening commands!
}

This is not enought code to do anything, you also need to have code in which to open a window. OpenGL has no windowing commands, it is strictly a drawing API. So you ether need to open a windows with Native windows code or a API like GLUT.




[This message has been edited by nexusone (edited 02-04-2004).]

Dr Dogg
02-04-2004, 10:13 AM
"This example is written for Linux X windows, not windows" - well, put it this way: that error is because windows gl headers depend on windows.h. If it is a linux program, then odds on it wont compile under VCPP as it lacks the Linux windowing headers etc.

I don't mean this in a patronising way, but are you sure you have a windows port there?