Skip to main content
gamedev.net
🔒 Locked

Using DDS's

Started by GaryNas Sep 15, 2005 at 4:32 PM 7 replies 1.4k views
Original Post
GaryNas
GaryNas
A project I'm working on is using OpenGL and a problem has arose in which the best solution is to use a DDS texture (24-bit RGB surface, NOT DXTn) with stored mip map information. Does anyone know of a good starting place on info on how to load DDS's into OpenGL? Basically, all I want to do is load up this uncompressed texture and each of its mip-map levels so OpenGL will use it... I tried googling, but nothing is coming up that really helps. Also, my OpenGL is fairly weak as I normally program with Direct3D. Thanks.
Sneftel
Sneftel
NVidia used to offer sample code which did exactly this, but it looks like they've taken it down. Perhaps if you emailed them they'd send you a copy, though.
_the_phantom_
_the_phantom_
just use glTexImage(), give it a mipmap level and a pointer to the texture data and you're away.

I've got a texture loading lib I'm working on which might be able to help you... I was just about to get on with testing a few things pre beta release (either tonight or tomorrow night as I'm getting to the point where its all looking reasonably sane enuff to work).
adam17
adam17
just out of curiosity whats the advantage to using dds files over other images?
pauljan
pauljan
Precalculated mipmaps stored in a single file.
nife
nife
The size (of the file) compared to the quality (of the image) is also a great advantage.
Killers don't end up in jailThey end up on a high-score!
FReY
FReY
A DDS file is just the bytes 'DDS ' (with the space) followed by a DDSURFACEDESC2 structure that is serialized directly to file with the data following it in order of highest size mipmap data to lowest size mipmap data.

info on the DDS file format layout here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/directx/graphics/reference/DDSFileReference/ddsfileformat.asp

info on the DDSURFACEDESC2 structure here:
http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/ddraw7/directdraw7/ddref_2oqf.asp

What you then do is
* create a texture handle (with glGenTextures)
* enable 2d texture target (glEnable(GL_TEXTURE_2D))
* bind the texture handle to the texture target (glBindTexture(texture_handle obtained from glGenTextures))

What you then do is take each mipmap data pointer and call the following function on it to upload your image data (see MSDN docs on this function!)
glTexImage2D(GL_TEXTURE_2D, mipmap_level, etc...)

Obviously, this last step must be done for each mipmap.
Hope that helped.
do unto others... and then run like hell.
iliak
iliak
Look here, I gave my function to load DDS files.
- Iliak -
[ ArcEngine: An open source .Net gaming framework ]
[ Dungeon Eye: An open source remake of Eye of the Beholder II ]
zedzeek
zedzeek
Quote:
just out of curiosity whats the advantage to using dds files over other images?

*it handle practically everything u want in a single image file
compression, mipmaps, cubetextures, and various value formats (greyscale might be limited though from memory)
*its very easy to parse

in my engine i only have support for dds (also tga but ill remove that soon)
keep it simple only have the one image format
its like i see ppl advertising there engines (it loads md2/md3/3ds/obj etc) in my book this is something u should keep quite about (just load the single model file, unless of course your app is a modelling etc program for a game etc just use the one file)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.