Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: Assigning pointers

  1. #1
    Intern Contributor
    Join Date
    Feb 2000
    Location
    Stafford, UK
    Posts
    60

    Assigning pointers

    I seem to have a problem with assigning either display lists or textures in a class.

    I have a class variable relating to a list or a texture which is instanciated when the object is created (for example a mesh object)

    But when I use GenLists or whatever command is used to return a number in a method (say for example GetTexture which assigns a texture to the object) (GLuint) it returns rubbish , I know there is nothing wrong with the code itself as I have had to transfer it to Main() where it works fine.

    What I am having to do is use GenList or the get texture command in Main() and pass the GLuint back to the class.

    Any Ideas why it doesnt work?

    Thanks

  2. #2
    Member Regular Contributor
    Join Date
    Feb 2000
    Location
    milano, italy
    Posts
    282

    Re: Assigning pointers

    when researching, i use similar methods.
    a sphere class, for example, will hold informations with display lists and texture objects.
    i got no troubles so far.

    rubbish... makes me think about a recent problem i had with multithreading: is your application single-threaded ?

    Dolo/\/\ightY
    Dolo/\/\ightY

  3. #3
    Intern Contributor
    Join Date
    Feb 2000
    Location
    Stafford, UK
    Posts
    60

    Re: Assigning pointers

    I assume it is single threaded as i am using windows 98.

    My method is public and my variable that holds the pointer is protected. Just a thought, would I have to declare my class as public? at present I call it:

    class objectname
    {
    private

    vars

    public

    methods
    };

  4. #4
    Member Regular Contributor
    Join Date
    Feb 2000
    Location
    milano, italy
    Posts
    282

    Re: Assigning pointers

    where are you creating the display list? into the constructor?
    if it so, make sure to instantiate your object only after opengl is initialized.

    personally, i prefer to call a method like object.init() into a startup function wich is called when the application is running.

    Dolo/\/\ightY
    Dolo/\/\ightY

  5. #5
    Intern Contributor
    Join Date
    Feb 2000
    Location
    Stafford, UK
    Posts
    60

    Re: Assigning pointers

    Yes I think your right!

    Im trying to call it in the instanciation method, this explains a lot. I'll follow your advice and create an init method.

    Thanks!

  6. #6
    Intern Contributor
    Join Date
    Feb 2000
    Location
    Italy
    Posts
    77

    Re: Assigning pointers

    Originally posted by David:

    My method is public and my variable that holds the pointer is protected.
    If you are you using a pointer like this:

    int *list;
    glGenLists(1, list);

    IT'S WRONG! YOU HAVE TO ALLOCATE THE INT.

    Right ways:

    1) single list
    int list;
    glGenLists(1m, &list);

    2) array of lists
    int list[3];
    glGenLists(3, list);
    --
    Paolo M.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •