calling OpenGL methods from outside the main class

This is a discussion on calling OpenGL methods from outside the main class within the Game Programming forums, part of the General Programming Boards category; Hi, I'm new to both C++ and OpenGL. (Kind of dumb to try and learn them both at the same ...

  1. #1
    Registered User
    Join Date
    Jun 2006
    Posts
    2

    calling OpenGL methods from outside the main class

    Hi,

    I'm new to both C++ and OpenGL. (Kind of dumb to try and learn them both at the same time, but meh, it keeps me interested.) Anyway I should ask about this, since I'm probably misunderstanding something fundamental, what actually happens when you call an OpenGL method from another class?

    I'm trying to make a simple game structure. I've made a class I've just called 'World'. I construct a world object and pass it the information it needs to load a level. They I call various methods which get it to load in what it needs, which eventually will be textures and models and whatnot. For the moment all it does is build a single display list which is stored as a member field. My draw method back in the main code then calls glCallList on the field in my World object .

    The problem is that the display list isn't drawn. When I copy the list building method back into my main file it works fine. I'm not sure what's going on here.

  2. #2
    Registered User
    Join Date
    Aug 2003
    Posts
    1,199
    You can call OpenGL-function from any class and function. OpenGL will keep track of the states you have set and such. Now I dont think its a good thing at all, actually its a very bad thing, to learn opengl and c++ at the same time. It will just get too much for you, and you wont understand things fully.
    STL Util a small headers-only library with various utility functions. Mainly for fun but feedback is welcome.

  3. #3
    Registered User
    Join Date
    Jun 2006
    Posts
    2
    Thanks for the reply Shakti. (There was in fact just something wrong with the way I made the display list in the World class, so now it's all fixed.)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Class methods in header or source file?
    By TriKri in forum C++ Programming
    Replies: 13
    Last Post: 09-17-2007, 05:23 AM
  2. Access to methods of another (external) class
    By praul in forum C++ Programming
    Replies: 12
    Last Post: 04-19-2006, 11:42 AM
  3. My Window Class
    By Epo in forum Game Programming
    Replies: 2
    Last Post: 07-10-2005, 02:33 PM
  4. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  5. opengl code not working
    By Unregistered in forum Windows Programming
    Replies: 4
    Last Post: 02-14-2002, 09:01 PM

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