Make pixel format querying a member (massaging for merge).

Remove a function from the header.
This commit is contained in:
Glenn Maynard
2003-05-26 03:12:12 +00:00
parent 35405bc34c
commit 56b79a197d
6 changed files with 41 additions and 24 deletions
+7 -6
View File
@@ -230,9 +230,9 @@ void RageBitmapTexture::Create()
(pixfmt==FMT_RGBA4 || pixfmt==FMT_RGB5A1) ) /* Don't dither if format is 32bpp; there's no point. */
{
/* Dither down to the destination format. */
SDL_Surface *dst = SDL_CreateRGBSurfaceSane(SDL_SWSURFACE, img->w, img->h, PIXEL_FORMAT_DESC[pixfmt].bpp,
PIXEL_FORMAT_DESC[pixfmt].masks[0], PIXEL_FORMAT_DESC[pixfmt].masks[1],
PIXEL_FORMAT_DESC[pixfmt].masks[2], PIXEL_FORMAT_DESC[pixfmt].masks[3]);
const PixelFormatDesc *pfd = DISPLAY->GetPixelFormatDesc(pixfmt);
SDL_Surface *dst = SDL_CreateRGBSurfaceSane(SDL_SWSURFACE, img->w, img->h,
pfd->bpp, pfd->masks[0], pfd->masks[1], pfd->masks[2], pfd->masks[3]);
SM_SDL_ErrorDiffusionDither(img, dst);
SDL_FreeSurface(img);
@@ -247,9 +247,10 @@ void RageBitmapTexture::Create()
/* Convert the data to the destination format and dimensions
* required by OpenGL if it's not in it already. */
ConvertSDLSurface(img, m_iTextureWidth, m_iTextureHeight, PIXEL_FORMAT_DESC[pixfmt].bpp,
PIXEL_FORMAT_DESC[pixfmt].masks[0], PIXEL_FORMAT_DESC[pixfmt].masks[1],
PIXEL_FORMAT_DESC[pixfmt].masks[2], PIXEL_FORMAT_DESC[pixfmt].masks[3]);
const PixelFormatDesc *pfd = DISPLAY->GetPixelFormatDesc(pixfmt);
ConvertSDLSurface(img, m_iTextureWidth, m_iTextureHeight,
pfd->bpp, pfd->masks[0], pfd->masks[1], pfd->masks[2], pfd->masks[3]);
m_uTexHandle = DISPLAY->CreateTexture( pixfmt, img );
+12
View File
@@ -34,6 +34,18 @@ static int g_iFramesRenderedSinceLastCheck,
g_iVertsRenderedSinceLastCheck,
g_iNumChecksSinceLastReset;
CString PixelFormatToString( PixelFormat pixfmt )
{
const CString s[NUM_PIX_FORMATS] = {
"FMT_RGBA8",
"FMT_RGBA4",
"FMT_RGB5A1",
"FMT_RGB5",
"FMT_RGB8",
"FMT_PAL" };
return s[pixfmt];
};
void RageDisplay::ProcessStatsOnFlip()
{
g_iFramesRenderedSinceLastCheck++;
+4 -13
View File
@@ -46,29 +46,20 @@ enum PixelFormat {
FMT_PAL,
NUM_PIX_FORMATS
};
inline CString PixelFormatToString( PixelFormat pixfmt )
{
const CString s[NUM_PIX_FORMATS] = {
"FMT_RGBA8",
"FMT_RGBA4",
"FMT_RGB5A1",
"FMT_RGB5",
"FMT_RGB8",
"FMT_PAL" };
return s[pixfmt];
};
CString PixelFormatToString( PixelFormat pixfmt );
struct PixelFormatDesc {
int bpp;
unsigned int masks[4];
};
/* This is info is different for OGL and D3D. */
extern const PixelFormatDesc PIXEL_FORMAT_DESC[NUM_PIX_FORMATS];
class RageDisplay
{
friend class RageTexture;
public:
const PixelFormatDesc *GetPixelFormatDesc(PixelFormat pf) const;
RageDisplay( bool windowed, int width, int height, int bpp, int rate, bool vsync, CString sWindowTitle, CString sIconFile );
~RageDisplay();
void Update(float fDeltaTime);
+8 -1
View File
@@ -122,7 +122,7 @@ static void SetPalette( unsigned TexResource )
#define D3DFVF_RAGEVERTEX (D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_DIFFUSE|D3DFVF_TEX1) // D3D FVF flags which describe our vertex structure
const PixelFormatDesc PIXEL_FORMAT_DESC[NUM_PIX_FORMATS] = {
static const PixelFormatDesc PIXEL_FORMAT_DESC[NUM_PIX_FORMATS] = {
{
/* A8B8G8R8 */
32,
@@ -165,6 +165,13 @@ const PixelFormatDesc PIXEL_FORMAT_DESC[NUM_PIX_FORMATS] = {
}
};
const PixelFormatDesc *RageDisplay::GetPixelFormatDesc(PixelFormat pf) const
{
ASSERT( pf < NUM_PIX_FORMATS );
return &PIXEL_FORMAT_DESC[pf];
}
RageDisplay::RageDisplay( bool windowed, int width, int height, int bpp, int rate, bool vsync, CString sWindowTitle, CString sIconFile )
{
+7 -1
View File
@@ -740,7 +740,7 @@ void RageDisplay::SetBackfaceCull( bool b )
glDisable( GL_CULL_FACE );
}
const PixelFormatDesc PIXEL_FORMAT_DESC[NUM_PIX_FORMATS] = {
static const PixelFormatDesc PIXEL_FORMAT_DESC[NUM_PIX_FORMATS] = {
{
/* B8G8R8A8 */
32,
@@ -783,6 +783,12 @@ const PixelFormatDesc PIXEL_FORMAT_DESC[NUM_PIX_FORMATS] = {
}
};
const PixelFormatDesc *RageDisplay::GetPixelFormatDesc(PixelFormat pf) const
{
ASSERT( pf < NUM_PIX_FORMATS );
return &PIXEL_FORMAT_DESC[pf];
}
struct GLPixFmtInfo_t {
GLenum internalfmt; /* target format */
@@ -320,9 +320,9 @@ void MovieTexture_DShow::CreateTexture()
if(TEXTUREMAN->GetTextureColorDepth() == 16)
m_PixelFormat = FMT_RGB5;
m_img = SDL_CreateRGBSurfaceSane(SDL_SWSURFACE, m_iTextureWidth, m_iTextureHeight, PIXEL_FORMAT_DESC[m_PixelFormat].bpp,
PIXEL_FORMAT_DESC[m_PixelFormat].masks[0], PIXEL_FORMAT_DESC[m_PixelFormat].masks[1],
PIXEL_FORMAT_DESC[m_PixelFormat].masks[2], PIXEL_FORMAT_DESC[m_PixelFormat].masks[3]);
const PixelFormatDesc *pfd = DISPLAY->GetPixelFormatDesc(m_PixelFormat);
m_img = SDL_CreateRGBSurfaceSane(SDL_SWSURFACE, m_iTextureWidth, m_iTextureHeight,
pfd->bpp, pfd->masks[0], pfd->masks[1], pfd->masks[2], pfd->masks[3]);
m_uTexHandle = DISPLAY->CreateTexture( m_PixelFormat, m_img );
}