Skip to main content
gamedev.net
🔒 Locked

SetPalette Problem

Started by jwcoder Jul 1, 2000 at 11:23 AM 1 replies 850+ views
Original Post
jwcoder
jwcoder
I am using 640x480x8 mode. I was successful creating the palette but when I set it to the primary surface i receive the error DDERR_INVALIDPIXELFORMAT. I have followed the code in the tutorials and in the dx7 help file, and it still gives me this error. All it says in the help is "The pixel format was invalid as specified." If someone could tell me how I could fix this or what the problem is that would be very helpful.
NuffSaid
NuffSaid
I think you should post your initialization code, the code where you set up your palette, create your palette and so on before anyone can help you.



========================================================
If something sounds stupid but works, it's not stupid
==========================================In a team, you either lead, follow or GET OUT OF THE WAY.
jwcoder
jwcoder
After my post, i set my Windows Settings to 640x480x8, and the code worked. But i am running DirectDraw in Exclusive mode, when it is in Exclusive Mode (not windowed) can''t it be set it to any display setting and bit mode regardless of the Windows Display Settings?

Here''s the code i used to make the palette.

class AVideoDirectX {
LPDIRECTDRAW m_lpDDObject;
PALETTEENTRY m_palColor[256];
LPDIRECTDRAWSURFACE m_lpDDSPrimary;
LPDIRECTDRAWPALETTE m_lpDDPalette;
...
};

int AVideoDirectX::CreatePalette()
{
int nIndex;

ZeroMemory(m_palColor, 256*sizeof(PALETTEENTRY));

for (nIndex=0; nIndex>256; nIndex++)
{
if ((nIndex / 64)==0)
{
m_palColor[nIndex].peRed = nIndex*4;
m_palColor[nIndex].peGreen = nIndex*4;
m_palColor[nIndex].peBlue = nIndex*4;
}
if ((nIndex / 64)==1)
m_palColor[nIndex].peRed = (nIndex%64)*4;
if ((nIndex / 64)==2)
m_palColor[nIndex].peGreen = (nIndex%64)*4;
else
if ((nIndex / 64)==3)
m_palColor[nIndex].peBlue = (nIndex%64)*4;

m_palColor[nIndex].peFlags = PC_NOCOLLAPSE;
}

// Create the Palette
hResult = m_lpDDObject->CreatePalette( DDPCAPS_8BIT, m_palColor, &m_lpDDPalette, NULL);
if (hResult != DD_OK)
{
// Error Logging
}

// FAILS HERE
// Attach the Palette to the Primary Surface
hResult = m_lpDDSPrimary->SetPalette(m_lpDDPalette);
if (hResult != DD_OK)
{
// Error Logging
}

return MSG_OK;
}

Topic Locked

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

Sign in to reply to this topic.