Results 1 to 6 of 6

Thread: Assigning pointers

  1. #1
    Member 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
    Senior 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
    Member 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
    Senior 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
    Member 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
    Member 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.

Similar Threads

  1. Assigning a face value
    By Limdor in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 03-02-2011, 03:21 AM
  2. Assigning to a secondary GPU --and other issues
    By Josh S in forum OpenGL: Windows
    Replies: 11
    Last Post: 10-09-2009, 09:24 PM
  3. Assigning Sampler*s
    By Twixn in forum OpenGL: GLSL
    Replies: 3
    Last Post: 11-26-2004, 04:40 PM
  4. assigning an int to a float
    By geohoffman49431 in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 07-21-2004, 04:28 AM
  5. Assigning Normals for all triangles in a fan?
    By rjh57 in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 04-07-2003, 11:25 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean