ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
It seems that to open DDS texture files everyones tutorials use the typedef DDSURFACEDESC2 from the ddraw.h file. I assume that DWORD is just an int but what about the rest? Has anyone already converted this structure previously so it could be used in linux without using a program such as wine? Any help you could give would be greatly appreciated.
typedef struct _DDSURFACEDESC2
{
DWORD dwSize; // size of the DDSURFACEDESC structure
DWORD dwFlags; // determines what fields are valid
DWORD dwHeight; // height of surface to be created
DWORD dwWidth; // width of input surface
union
{
LONG lPitch; // distance to start of next line (return value only)
DWORD dwLinearSize; // Formless late-allocated optimized surface size
} DUMMYUNIONNAMEN(1);
union
{
DWORD dwBackBufferCount; // number of back buffers requested
DWORD dwDepth; // the depth if this is a volume texture
} DUMMYUNIONNAMEN(5);
union
{
DWORD dwMipMapCount; // number of mip-map levels requestde
// dwZBufferBitDepth removed, use ddpfPixelFormat one instead
DWORD dwRefreshRate; // refresh rate (used when display mode is described)
DWORD dwSrcVBHandle; // The source used in VB::Optimize
} DUMMYUNIONNAMEN(2);
DWORD dwAlphaBitDepth; // depth of alpha buffer requested
DWORD dwReserved; // reserved
LPVOID lpSurface; // pointer to the associated surface memory
union
{
DDCOLORKEY ddckCKDestOverlay; // color key for destination overlay use
DWORD dwEmptyFaceColor; // Physical color for empty cubemap faces
} DUMMYUNIONNAMEN(3);
DDCOLORKEY ddckCKDestBlt; // color key for destination blt use
DDCOLORKEY ddckCKSrcOverlay; // color key for source overlay use
DDCOLORKEY ddckCKSrcBlt; // color key for source blt use
union
{
DDPIXELFORMAT ddpfPixelFormat; // pixel format description of the surface
DWORD dwFVF; // vertex format description of vertex buffers
} DUMMYUNIONNAMEN(4);
DDSCAPS2 ddsCaps; // direct draw surface capabilities
DWORD dwTextureStage; // stage in multitexture cascade
} DDSURFACEDESC2;
I don't know what does that structure do, but from the comments it looks it won't be that easy. If you'd like to port it to Linux, you need to find similar structures in OpenGL and use them. There will be similarities, of course, but I don't thing it's an automatic process.
It's not all that complicated. What you basically need is lpSurface (ptr to
first byte of the surface), lPitch (number of bytes in a line), dwWidth
and dwHeight (vertical and horizontal extensions), and the pixel format.
BTW DWORD is an unsigned long. SDL and Xlib use a similar thing, here
you have some code which reads such data from each DDraw, SDL or
Xlib and writes it into member variables, so that
(sorry for the format, just straight out of MSVC editor) will set you a
single pixel in any of the libs. BTW to get a fully filled in DDSURFACEDESC2,
you need to lock/unlock the surface. From CreateSurface you will not get
the base pointer, only pixel format.
The code: (please note that the DDSURFACEDESC and similar structs in
SDL/Xlib are member variables set in other methods, so you shouldn't
wonder why I don't pass them as arguments)
void C_osi_graph_surface::get_Surface_data(){
printf("C_osi_graph_surface::get_Surface_data()\n");
int hRet=0;
unsigned short S_NumRBits,S_NumGBits,S_NumBBits;
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.