PDA

View Full Version : HELP cannot run prog on VC++ 6.0



09-16-2000, 09:22 AM
here's the program, of course i linked opengl32.lib, glut.lib, glut32.lib (Win32 Console app), I keep getting:
d:\prog\test11\test11.cpp(105) : warning C4007: 'WinMain' : must be '__stdcall'
d:\prog\test11\test11.cpp(105) : error C2731: 'WinMain' : function cannot be overloaded
d:\prog\test11\test11.cpp(104) : see declaration of 'WinMain'

HEre's the code:


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


GLenum doubleBuffer;
GLint thing1, thing2;


void Init()
{

glClearColor(0.0, 0.0, 0.0, 0.0);
glClearAccum(0.0, 0.0, 0.0, 0.0);

thing1 = glGenLists(1);
glNewList(thing1, GL_COMPILE);
glColor3f(1.0, 0.0, 0.0);
glRectf(-1.0, -1.0, 1.0, 0.0);
glEndList();

thing2 = glGenLists(1);
glNewList(thing2, GL_COMPILE);
glColor3f(0.0, 1.0, 0.0);
glRectf(0.0, -1.0, 1.0, 1.0);
glEndList();
}

void Reshape(int width, int height)
{

glViewport(0, 0, width, height);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}

void Key(unsigned char key, int x, int y)
{

switch (key) {
case '1':
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glutPostRedisplay();
break;
case '2':
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glutPostRedisplay();
break;
case 27:
exit(0);
}
}

void Draw()
{

glPushMatrix();

glScalef(0.8, 0.8, 1.0);

glClear(GL_COLOR_BUFFER_BIT);
glCallList(thing1);
glAccum(GL_LOAD, 0.5);

glClear(GL_COLOR_BUFFER_BIT);
glCallList(thing2);
glAccum(GL_ACCUM, 0.5);

glAccum(GL_RETURN, 1.0);

glPopMatrix();

if (doubleBuffer) {
glutSwapBuffers();
} else {
glFlush();
}
}

void Args(int argc, char **argv)
{
GLint i;

doubleBuffer = GL_FALSE;

for (i = 1; i < argc; i++) {
if (strcmp(argv[i], "-sb") == 0) {
doubleBuffer = GL_FALSE;
} else if (strcmp(argv[i], "-db") == 0) {
doubleBuffer = GL_TRUE;
}
}
}

void bingo()
{

}

void WinMain(int argc, char **argv)
{
GLenum type;

glutInit(&argc, argv);
Args(argc, argv);

type = GLUT_RGB | GLUT_ACCUM;
type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
glutInitDisplayMode(type);
glutInitWindowSize(300, 300);
glutCreateWindow("Accum Test");

Init();

glutReshapeFunc(Reshape);
glutKeyboardFunc(Key);
glutDisplayFunc(Draw);
glutMainLoop();
}

Bob
09-16-2000, 10:43 AM
Rename the function WinMain to main.

09-16-2000, 10:47 AM
did that, got :
LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/test.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

i think it is looking for WinMain because the project is a Win32 Application (I also tried Win32 console application, same thing)

HEELLLPP!!

Bob
09-16-2000, 11:20 AM
When using GLUT, you should create a Win32 Console Application and use main. Most, if not all, other combinations will give you problems.

And if you tried main with a console application, I really doubt you got that errormessage.

09-16-2000, 11:29 AM
COOL it worked main with Win32 Console Application, so which one should i be using Win32 Application or Win32 Console Application? Why did I get that overload message?

Thx again!!

09-16-2000, 11:30 AM
in general that is... which one is better Win32 application or Win32 Console application?

Bob
09-17-2000, 05:21 AM
Which is better? A console application is better if you want to use the consol, and a Win32 Application is better if you don't want the console http://www.opengl.org/discussion_boards/ubb/biggrin.gif
It's just a question about what you want/need, and we can't answer that question for you.

When using GLUT, you should always create a Win32 Console Application, because GLUT uses the console to output any information. So if any error occur, this will appear in the consol. Otherwise, I suggest you stick to a general Win32 Application.

And, I really don't know why you can't overload WinMain, but I think it has something to do with the standard set of arguments passed to the entrypoint (where the program starts executing) by the operatingsystem.