please help me

This is a discussion on please help me within the Game Programming forums, part of the General Programming Boards category; I am trying to teach myself open gl programming (with the help of glut), but every time I try to ...

  1. #1
    Registered User insane's Avatar
    Join Date
    May 2003
    Posts
    8

    Unhappy OpenGL problem

    I am trying to teach myself open gl programming (with the help of glut), but every time I try to compile a program, I get a declaration syntax error within gl.h, and I can't seem to get around it. The error is occuring on the WINGDIAPI declaration lines. Could someone please tell me what I am doing wrong?
    Last edited by insane; 05-04-2003 at 10:13 PM.

  2. #2
    Banned
    Join Date
    Jan 2003
    Posts
    1,708
    declaration syntax error with gl.h? Seems like you may not be including it, but im not sure. Could you post the code that is causing the trouble and / or the error message itself? That'd help a lot.

  3. #3
    Registered User insane's Avatar
    Join Date
    May 2003
    Posts
    8
    okay, here is the source code, and I have attached a copy of gl.h just to be sure
    Code:
    //---------------------------------------------------------------------------
    
    #pragma hdrstop
    
    //---------------------------------------------------------------------------
    
    #pragma argsused
    #ifdef _FLAT_
    #include windows.h
    #endif
    
    #include <gl/glut.h>
    
       void main(int argc, char** argv)
       {
          glutInit (&argc, argv);
          glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB);
          glutInitWindowSize (400, 100);
          glutInitWindowPosition (100, 100);
          glutCreateWindow ("First Chapter - Opening an OpenGL Window");
    
          init();
          glutDisplayFunc (display);
    
          glutMainLoop();
       }
    //---------------------------------------------------------------------------
    here is the error message:

    [C++ Error] gl.h(1153): E2141 Declaration syntax error
    [C++ Error] gl.h(1154): E2238 Multiple declaration for 'WINGDIAPI'
    [C++ Error] gl.h(1153): E2344 Earlier declaration of 'WINGDIAPI'
    [C++ Error] gl.h(1154): E2141 Declaration syntax error
    [C++ Error] gl.h(1155): E2238 Multiple declaration for 'WINGDIAPI'
    [C++ Error] gl.h(1154): E2344 Earlier declaration of 'WINGDIAPI'
    [C++ Error] gl.h(1155): E2141 Declaration syntax error
    [C++ Error] gl.h(1156): E2238 Multiple declaration for 'WINGDIAPI'
    [C++ Error] gl.h(1155): E2344 Earlier declaration of 'WINGDIAPI'
    [C++ Error] gl.h(1156): E2141 Declaration syntax error
    [C++ Error] gl.h(1157): E2238 Multiple declaration for 'WINGDIAPI'
    [C++ Error] gl.h(1156): E2344 Earlier declaration of 'WINGDIAPI'
    [C++ Error] gl.h(1157): E2141 Declaration syntax error
    [C++ Error] gl.h(1158): E2238 Multiple declaration for 'WINGDIAPI'
    [C++ Error] gl.h(1157): E2344 Earlier declaration of 'WINGDIAPI'
    [C++ Error] gl.h(1158): E2141 Declaration syntax error
    [C++ Error] gl.h(1159): E2238 Multiple declaration for 'WINGDIAPI'
    [C++ Error] gl.h(1158): E2344 Earlier declaration of 'WINGDIAPI'
    [C++ Error] gl.h(1159): E2141 Declaration syntax error
    [C++ Error] gl.h(1160): E2238 Multiple declaration for 'WINGDIAPI'
    [C++ Error] gl.h(1159): E2344 Earlier declaration of 'WINGDIAPI'
    [C++ Error] gl.h(1160): E2141 Declaration syntax error
    [C++ Error] gl.h(1161): E2238 Multiple declaration for 'WINGDIAPI'
    [C++ Error] gl.h(1160): E2344 Earlier declaration of 'WINGDIAPI'
    [C++ Error] gl.h(1161): E2141 Declaration syntax error
    [C++ Error] gl.h(1161): E2228 Too many error or warning messages
    Attached Files Attached Files
    • File Type: h gl.h (67.5 KB, 116 views)
    Last edited by insane; 05-04-2003 at 10:14 PM.

  4. #4
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    #1. Use Code Tags

    #2. Read this first. Especially 14.2.

    #3. Never do this: void main(int argc, char** argv) again.

    #4. Change it to int main(int argc, char** argv) and then give the function a return value.

    As for the problem you posted...I have no idea. What happens if you don't #include <windows.h>?
    Away.

  5. #5
    Registered User insane's Avatar
    Join Date
    May 2003
    Posts
    8
    sorry about that

    Okay, so I tried taking out windows.h, and changed the void to int and gave it a return value. It compiled, but nothing happenedwhen I ran it. So I put windows.h back in, and it compiled once again, but once again, when I ran it, nothing happened.

  6. #6
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    hmmm...I didn't see the #ifdef in your code before...which explains why changing the thing with windows.h didn't do anything...it wasn't really there in the first place, probably. Thank you for editing your post with the code tags...new people usually ignore those requests. I don't know OpenGL, but from this call: glutDisplayFunc (display); I would assume that display is a variable...and it doesn't appear to be defined? Perhaps it is defined in a glut.h...but in that case...do you need to give it a value before you call that function? I'm just throwing out ideas...I should probably just shut up now. But you say that it's compiling now? did you change something?
    Away.

  7. #7
    Registered User insane's Avatar
    Join Date
    May 2003
    Posts
    8
    I changed the void main to int main, and when I did that, it successfully compiled, but I have absolutely no idea why, it shouldn't have made a difference on the declarations within gl.h. But I'll check out your ideas, see if they make a difference.

    thanks

  8. #8
    Registered User insane's Avatar
    Join Date
    May 2003
    Posts
    8
    okay, so I think I've narrowed down my problem, now I need someone to help me expand upon the glut APIENTRY glutMainLoop(). I don't actually know how to use it, or expand upon it, so if someone could help me, please, figure this one out.

  9. #9
    Registered User insane's Avatar
    Join Date
    May 2003
    Posts
    8
    Okay, so, I've done a bit more research into the area of OpenGL programming, and I've noticed one common thing that I don't have, opengl.h

    I'm going to make the assumption that this would have a pretty drastic affect on the fact that my code doesn't run, however, I didn't get any linking errors, so I don't understand why this file being missing is causing the program not to run. Could someone please explain this at least a little to me?

    thanx

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21