Help!

I am trying for the first time to program in OpenGl using visual C++. I copied a program directly out of a book and it compiles fine, but doesnt link. It keeps giving me an error that says something like unreslolved external symbol _WinMain@16 What do I do to fix this?

You’re using main() and your compiler’s looking for WinMain(). You needed to create a Win32 Console Application when you initially made your project, instead of a Win32 Application.

…or is it the other way around? Oh well…

Ok, i fixed that, but now when i compile, the program will work, but there is a box in the backround that doesnt do anything. How do I get rid of this?

…huh?

I guess if it’s actually supposed to do something, then it doesn’t work. Try posting the code you’re using, so we may see what you’re doing wrong…or are you referring to the console window?

Yeah, how do i get rid of it?

#include <GL/glut.h>
#include <stdlib.h>

void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);

glColor3f(1.0,1.0,1.0);
glBegin(GL_POLYGON);
glVertex3f(0.25, 0.25, 0.0);
glVertex3f(0.75,0.25,0.0);
glVertex3f(0.75,0.75,0.0);
glVertex3f(0.25,0.75,0.0);
glEnd();
glFlush();

}

void init(void)
{
glClearColor(0.0,0.0,0.0,0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0,1.0,0.0,1.0,-1.0,1.0);
}

int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(250,250);
glutInitWindowPosition(100,100);
glutCreateWindow(“Hello”);
init();
glutDisplayFunc(display);
glutMainLoop();
return 0;
}

<sarcastic voice>Actually, I never figured that one out lol</sarcastic voice>

There is another discussion that you might want to read. The person’s asking the exact same question you are.

http://www.opengl.org/discussion_boards/ubb/Forum2/HTML/008711.html

I had a similiar problem when I just started out. You must remeber that when a 3D object is projected onto a viewing plane, the camera must not be at exactely the same position as the viewing plane or you will get division by zero errors for the perspective projections.
Thus opengl does not even bother drawing them. All you need to do is to move your camera back a bit before you actually start drawing.

glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0, 0.0, -5.0); //move the object 5 units in the negative Z-Axis direction.

Hope this helps.

, but there is a box in the backround that doesnt do anything. How do I get rid of this?

this is a console window. when you create a Win32 Console Application, your executable is run from this console (just a DOS window). this is where any printf/cout statements will be displayed. with the console app, your program will need a main(). if you create a Win32 Application, there is no DOS window. this requires a WinMain(). as for making the DOS window go away, i seem to remember hearing about this. search this forum for “DOS window” or “console window”.

b

There’s a compiler setting you can add to not show the console box. It’s in the FAQ. You can also use the Win32 function FreeConsole. This method is, of course, specific to Windows.

What FAQ?

The one on OpenGL’s web site. This link’ll take you directly to the part on GLUT, however, what you’re requesting is towards the bottom of this page.
http://www.opengl.org/developers/faqs/technical/glut.htm#glot0100

Basically, all it says is this:

3.100 How do I get rid of the console window in a Windows GLUT application?

With Visual C++ 6.0, go to the Project menu, Settings… dialog. Select the Link tab. In the Project options edit box, add /SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup to the end of the present text. Link options are similar for other Windows compilers.

…dunno how to do this in Borland, though.