Results 1 to 8 of 8

Thread: choose the right .h file.... (C++)

  1. #1
    Member Newbie
    Join Date
    May 2001
    Location
    bogota, colombia
    Posts
    42

    choose the right .h file.... (C++)

    Hi,

    Sorry if this isnīt a "real" OpenGL topic, but maybe somebody have done the same before...

    I use a file generated by 3dexplorer (.cpp) to import a 3D-object into my OpenGL window. I changed the file to be a .h file and in the end of that file there is a function called Gen3DObjectList() that I use like:

    m_uiDisplayListID = Gen3DObjectList();

    The thing is that Iīd like to use the same OpenGL window to be able to import different 3D-objects that I import from the .h file via the function above.

    But the .h-files have the same function Gen3DObjectList() so that makes things a mess....

    Somebody got a clue??

  2. #2
    Junior Member Newbie
    Join Date
    May 2001
    Location
    UK
    Posts
    18

    Re: choose the right .h file.... (C++)

    I know what you mean.
    I have the same problem and would love to know a solution.

    At the moment the only thing I can think of is by creating a loader to just handle the data output option.

  3. #3
    Senior Member Regular Contributor
    Join Date
    Feb 2001
    Location
    Australia
    Posts
    431

    Re: choose the right .h file.... (C++)

    This is a long shot - I don't have a compiler on this computer so I can't test it. I was thinking maybe you could do something like this:
    Code :
    namespace file1 {
    #include "file1.h"
    }
    namespace file2 {
    #include "file2.h"
    }
    Does that work? I'm guessing it won't. Otherwise, you could go into each .h file and wrap the whole file in a namespace. Then just call file1::Gen3DObjectList(), file2::Gen3DObjectList() ...

    Hope that helps.

  4. #4
    Senior Member Regular Contributor
    Join Date
    Nov 2000
    Location
    Sydney, NSW, Australia
    Posts
    426

    Re: choose the right .h file.... (C++)

    Ummm, well, what I did, delete everything except the vertext, texture, normal arrays, and used them as you would any other arrays, but you must do it in the proper order, thats what the other array is there for.
    :: Sleep is a poor substitute for caffeine ::

  5. #5
    Member Newbie
    Join Date
    May 2001
    Location
    bogota, colombia
    Posts
    42

    Re: choose the right .h file.... (C++)

    Thanks for the answers.
    Iīve tried to use namespace, I donīt know if Iīm doing something wrong, but I get a error message that Head is not a class nor a namespace when I do like:

    ... = Head::Gen3DObjectList();

    But I had another idea, to change the name of the function Gen3DObjectList() to GenerateCabezaList() or something like that, I changed the name of the function in the .h file and the call to the function, but I just get the error message:
    'GenerateCabezaList' : undeclared identifier
    Error executing cl.exe.

    Does that mean that Gen3DObjectList() is a kind of function that is already known??? Otherwise itīs quiet simple to just change the names of the functions and include all the desired files....

    /grodslukaren

  6. #6
    Junior Member Newbie
    Join Date
    May 2001
    Location
    UK
    Posts
    18

    Re: choose the right .h file.... (C++)

    Thanks ffish!
    That namespace trick worked a treat.
    That makes things a lot simpler and easier.
    I haven't used namespace before but I think it will become a very much used item in my game.
    Thanks again.

  7. #7
    Member Newbie
    Join Date
    May 2001
    Location
    bogota, colombia
    Posts
    42

    Re: choose the right .h file.... (C++)

    yeah, Thanks a lot!!

    I mixed my files in a stupied way, so it didnīt work... but now it does....

    thanks again!!

  8. #8
    Senior Member Regular Contributor
    Join Date
    Feb 2001
    Location
    Australia
    Posts
    431

    Re: choose the right .h file.... (C++)

    Glad it helped. That's actually what most C++ implementations do to wrap the C libraries in the std namespace. That's why you should now code like this in C++:
    Code :
    // The old way.
    // #include <math.h>
    // #include <stdio.h>
    // etc ...
     
    // The new way.
    #include <cmath>
    #include <cstdio>
    // etc ...
    I think from memory that files like cmath just look similar to this:
    Code :
    namespace std {
    // Some stuff here.
    #include <math.h>
    // Some more stuff here.
    }
    but don't quote me on that. Again, I don't have a compiler on this computer (uni library) but if you're interested, have a look at some sample files on your computer, like $INCLUDE_PATH/cmath etc.

Similar Threads

  1. OpenCL on Linux, which implementation to choose?
    By Dr. Jan Itor in forum OpenCL
    Replies: 6
    Last Post: 03-08-2011, 11:29 PM
  2. Which engine to choose?
    By torbjorn in forum OpenGL: Windows
    Replies: 6
    Last Post: 10-14-2004, 10:58 AM
  3. Which one should I choose, vp/fp or GLSL
    By N64Marin in forum OpenGL: Advanced Coding
    Replies: 6
    Last Post: 10-12-2004, 11:54 AM
  4. Unable to choose visual
    By in forum OpenGL: Linux
    Replies: 5
    Last Post: 03-29-2003, 04:37 AM
  5. How to choose the texture which is not in rectangular form?
    By songeb in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 01-22-2002, 05:46 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