🔒 Locked
Using DDS's
Advertisement
Original Post
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.
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).
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).
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.
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.
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.
Advertisement