3D - Texture

PakToh
Unregistered
 
Post: #1
Hello to all of you! - I have a little problem and hope to find somebody in this forum who can help me.

I need to use 3D-Textures for fur-rendering. The technics for that are clearly, but I don't know how to load the §D-Texture.

I have several dds-Files to load this Texture (dds-files are Direct 3D-files), but I'm also able to convert them with a Photoshop-Plugin into any other format.
I know how to load one picture(bmp - but I have enough tutorials to load others like JPEG or tga, too).
I also changed the GL_TEXTURE_2D to GL_TEXTURE_3D and load a bmp-file into the first layer of the 3D-Texture (Depth set to 0). - Works fine and perfect! But how can i load the next Data?

Or am I going a wrong way to get the 3D - Texture loaded?

I know rthat the 3D-Texture can, once loaded, be used like every other Texture.

Would be really great if anybody could give me a clue how this works - If i findan answer (alone or with help) - I will post the answer in this thread.

greetings
Marcel
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #2
Read the man page for glTexImage3D or gluBuild3DMipmaps.

It works just like glTexImage2D, except there is a depth parameter in addition to width and height.
Quote this message in a reply
PakToh
Unregistered
 
Post: #3
Thanks for the answer - i'm looking for it - thanks for the help!

Marcel
Quote this message in a reply
PakToh
Unregistered
 
Post: #4
OK, I have another Problem with that stuff, but it's more a general C++-Problem i have with that Pointer-Stuff:

I need to generate an array for my Texture-Data (I will generate it manually now).
I have written a class containing a
GLubyte**** data;
-array and in the constructor of the class i want to do:

GLubyte**** test [64][64][8][4];
... //(Defining every member of the array with a value - I already made a simple Algorithm for that)
data = test;

But XCode always tells me:
initialisation to 'GLubyte ****' from 'GLubyte **** (*)[64][8][4]'

I think I know what the compiler wants to tell me with this error, but I don't see the Problem with it - the Array has the right datatype (GLubyte****) so, why doesn't the compiler assignes the data to the pointer?

I know I'm a newbie and maybe this is a silly problem for a more advanced programmer, but these Pointer-Array-Problems are really annoying. The last times i was able to find ways without Arrays and so on, but now OpenGL wants an array with the data stored in it and perhaps sooner or later i have to understand why this is wrong and how i can make it right.
So I would really appreciate it, whensomebody of you could help me, thanks!
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #5
GLubyte**** data;
GLubyte test[64][64][8][4];
data = test;
Quote this message in a reply
PakToh
Unregistered
 
Post: #6
Thanks for your answer,
but that was my first code, and the compiler told (and still tells) me:

assignment to 'GLubyte ****' from 'unsigned char (*)[64][8][4]'

I tried to change the type of the array from GLubyte to GLubyte **** - and the other Error occured.

and a cast with
data = (GLubyte ****) test;
works perfectly while compiling, but while Executing it terminates with Sigbus 10.

I think i will inspect all the code for any other problems and then try to use another internal Data-Structur like a deque and write a method to return a GLubyte [64][64][8][4] - array, but if any body has a clue what could be wrong - let me know, thanks.
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #7
Just use
GLubyte* data = (GLubyte *) test;
that should work as expected, you can access data as if it were a linear array. Remember to copy a statically allocated array when you return it from your function, though.
Quote this message in a reply
Member
Posts: 156
Joined: 2002.11
Post: #8
Isn't it just like in the code below?

GLubyte* data;
GLubyte test[64][64][8][4];
data = test;

You may want to check out a C/C++ tutorial that explains pointers and other stuff fairly well at http://www.cplusplus.com/doc/tutorial/
Quote this message in a reply
PakToh
Unregistered
 
Post: #9
Thanks DoG! - Just spared me some coding-time!
It works now with the "translation" to a linear array and with re-"translating" it later to its original arrangement.

+++
GLubyte* data;
GLubyte test[64][64][8][4];
data = test;
- This didn't work, sorry, but now the problem is solved i hope (not tested it practically running) - I will give a short answer when finished!

Thanks a lot to all your suggestions!
Quote this message in a reply
PakToh
Unregistered
 
Post: #10
Could it be possible, that my Graphics-card can not display 3D-Textures? - Everything works fine and i finally got the pointer-thigs work pretty well.
I have a datastructure VolumetricTexture and it has a Method GLubyte**** getArray() that returns an array with the Texture-Data in it.
I check the array before I use it in glTexImage3D and the data is perfectly set!
I also tried a source-code i found on a website (used a little 8x8x8x4 - Array wich was set to a value by four for-loops) - that code worked also perfectly, but i saw just a white 'Texture' on the object i textured.

Can anybody tell me if a ATI Rage 128 PCI (G3 Yosemite) and a ATI Rage 128 Pro AGP (PowerBook G4) are unable to draw such Textures?!? - I will check it tomorrow on a Debian-Linux with a GeForce4 at university, but i want to know why it doesn't work on my Mac's - and I could focus on coding other things in my programm now.

A good thing to know - I think I will send a question to ATI and Apple, too.

And thanks for your help so far!!!
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #11
Rage128 and GF2MX/GF4MX don't support 3D textures. The Generic SW renderer doesn't, either. Time to upgrade?

btw, you know 3D texturing is available if your Open GL version is >= 1.2, or GL_EXT_TEXTURE3D is exported.
Quote this message in a reply
PakToh
Unregistered
 
Post: #12
Thanks for your fast reply!
I thought it - I know OpenGL is needed for 3D-Texturing - MY PC_Radoen 9000 can do it, but at the Moment i have no money toi buy a Mac-Version and I hope to get my PC back running, so I can't (and donÄt want) to patch my PC-Card - especially because I think a generic one is better and faster, so I have to wait a little bit - first I upgraded my Ram, next thing will be Graphics card, then Harddisks and CPU.

Ok, not more of that - I will post a short rwply, when I know if it works at university on the computers (on that cards it will definitely work).
Quote this message in a reply
Post Reply