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??

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.

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:

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.

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.

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

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.

yeah, Thanks a lot!!

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

thanks again!!

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++:

// The old way.
// #include <math.h>
// #include <stdio.h>
// etc …

// The new way.
#include
#include
// etc …

I think from memory that files like cmath just look similar to this:

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.