re-add mipmapping, support it in OpenGL (D3D unimplemented)
This commit is contained in:
@@ -1009,7 +1009,7 @@ void BGAnimationLayer::Draw()
|
||||
0,
|
||||
RageColor(0.6f,0.6f,0.6f,1),
|
||||
RageColor(0.9f,0.9f,0.9f,1),
|
||||
RageColor(0,0,0,1),
|
||||
RageColor(0.1f,0.1f,0.1f,1),
|
||||
RageVector3(0, 0, 1) );
|
||||
}
|
||||
|
||||
|
||||
@@ -184,7 +184,7 @@ struct BannerTexture: public RageTexture
|
||||
ASSERT( DISPLAY->SupportsTextureFormat(pf) );
|
||||
|
||||
ASSERT(img);
|
||||
m_uTexHandle = DISPLAY->CreateTexture( pf, img );
|
||||
m_uTexHandle = DISPLAY->CreateTexture( pf, img, false );
|
||||
|
||||
CreateFrameRects();
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ void AnimatedTexture::Load( CString sTexOrIniPath )
|
||||
ID.filename = Dirname(sTexOrIniPath) + sFileName;
|
||||
ID.bStretch = true;
|
||||
ID.bHotPinkColorKey = true;
|
||||
ID.bMipMaps = true; // use mipmaps in Models
|
||||
AnimatedTextureState state = {
|
||||
TEXTUREMAN->LoadTexture( ID ),
|
||||
fDelay
|
||||
@@ -71,6 +72,7 @@ void AnimatedTexture::Load( CString sTexOrIniPath )
|
||||
ID.filename = sTexOrIniPath;
|
||||
ID.bHotPinkColorKey = true;
|
||||
ID.bStretch = true;
|
||||
ID.bMipMaps = true; // use mipmaps in Models
|
||||
AnimatedTextureState state = {
|
||||
TEXTUREMAN->LoadTexture( ID ),
|
||||
10
|
||||
|
||||
@@ -306,7 +306,7 @@ apply_color_key:
|
||||
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 );
|
||||
m_uTexHandle = DISPLAY->CreateTexture( pixfmt, img, actualID.bMipMaps );
|
||||
|
||||
CreateFrameRects();
|
||||
|
||||
|
||||
@@ -151,7 +151,8 @@ public:
|
||||
* (unsigned in OpenGL, texture pointer in D3D) */
|
||||
virtual unsigned CreateTexture(
|
||||
PixelFormat pixfmt, // format of img and of texture in video mem
|
||||
SDL_Surface* img // must be in pixfmt
|
||||
SDL_Surface* img, // must be in pixfmt
|
||||
bool bGenerateMipMaps
|
||||
) = 0;
|
||||
virtual void UpdateTexture(
|
||||
unsigned uTexHandle,
|
||||
|
||||
@@ -1053,7 +1053,8 @@ void RageDisplay_D3D::DeleteTexture( unsigned uTexHandle )
|
||||
|
||||
unsigned RageDisplay_D3D::CreateTexture(
|
||||
PixelFormat pixfmt,
|
||||
SDL_Surface* img )
|
||||
SDL_Surface* img,
|
||||
bool bGenerateMipMaps )
|
||||
{
|
||||
// texture must be power of two
|
||||
ASSERT( img->w == power_of_two(img->w) );
|
||||
|
||||
@@ -32,7 +32,10 @@ public:
|
||||
VideoModeParams GetVideoModeParams() const;
|
||||
void SetBlendMode( BlendMode mode );
|
||||
bool SupportsTextureFormat( PixelFormat pixfmt, bool realtime=false );
|
||||
unsigned CreateTexture( PixelFormat pixfmt, SDL_Surface* img );
|
||||
unsigned CreateTexture(
|
||||
PixelFormat pixfmt,
|
||||
SDL_Surface* img,
|
||||
bool bGenerateMipMaps );
|
||||
void UpdateTexture(
|
||||
unsigned uTexHandle,
|
||||
SDL_Surface* img,
|
||||
|
||||
@@ -73,6 +73,7 @@ namespace GLExt {
|
||||
|
||||
#ifdef WIN32
|
||||
#pragma comment(lib, "opengl32.lib")
|
||||
#pragma comment(lib, "glu32.lib")
|
||||
#endif
|
||||
|
||||
//
|
||||
@@ -1238,7 +1239,8 @@ RageDisplay::PixelFormat RageDisplay_OGL::GetImgPixelFormat( SDL_Surface* &img,
|
||||
|
||||
unsigned RageDisplay_OGL::CreateTexture(
|
||||
PixelFormat pixfmt,
|
||||
SDL_Surface* img )
|
||||
SDL_Surface* img,
|
||||
bool bGenerateMipMaps )
|
||||
{
|
||||
ASSERT( pixfmt < NUM_PIX_FORMATS );
|
||||
|
||||
@@ -1248,7 +1250,7 @@ unsigned RageDisplay_OGL::CreateTexture(
|
||||
|
||||
glBindTexture( GL_TEXTURE_2D, uTexHandle );
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, bGenerateMipMaps ? GL_LINEAR_MIPMAP_NEAREST : GL_LINEAR);
|
||||
SetTextureWrapping( false );
|
||||
|
||||
// texture must be power of two
|
||||
@@ -1304,9 +1306,24 @@ unsigned RageDisplay_OGL::CreateTexture(
|
||||
|
||||
FlushGLErrors();
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, glTexFormat,
|
||||
// YUCK! There's no way to tell gluBuild2DMipmaps how many mip-map levels
|
||||
// to make. It's all or nothing, so we have to call either glTexImage2D
|
||||
// or gluBuild2DMipmaps
|
||||
if( bGenerateMipMaps )
|
||||
{
|
||||
gluBuild2DMipmaps(
|
||||
GL_TEXTURE_2D, glTexFormat,
|
||||
img->w, img->h,
|
||||
glImageFormat, glImageType, img->pixels );
|
||||
}
|
||||
else
|
||||
{
|
||||
glTexImage2D(
|
||||
GL_TEXTURE_2D, 0, glTexFormat,
|
||||
img->w, img->h, 0,
|
||||
glImageFormat, glImageType, img->pixels);
|
||||
}
|
||||
|
||||
|
||||
GLenum error = glGetError();
|
||||
if( error != GL_NO_ERROR )
|
||||
|
||||
@@ -18,7 +18,10 @@ public:
|
||||
void SetBlendMode( BlendMode mode );
|
||||
bool SupportsTextureFormat( PixelFormat pixfmt, bool realtime=false );
|
||||
bool Supports4BitPalettes();
|
||||
unsigned CreateTexture( PixelFormat pixfmt, SDL_Surface* img );
|
||||
unsigned CreateTexture(
|
||||
PixelFormat pixfmt,
|
||||
SDL_Surface* img,
|
||||
bool bGenerateMipMaps );
|
||||
void UpdateTexture(
|
||||
unsigned uTexHandle,
|
||||
SDL_Surface* img,
|
||||
|
||||
@@ -3,40 +3,14 @@
|
||||
|
||||
void RageTextureID::Init()
|
||||
{
|
||||
/* Maximum size of the texture, per dimension. */
|
||||
iMaxSize = 2048;
|
||||
|
||||
/* Number of mipmaps. (unimplemented) */
|
||||
iMipMaps = 4;
|
||||
|
||||
/* Maximum number of bits for alpha. In 16-bit modes, lowering
|
||||
* this gives more bits for color values. (0, 1 or 4) */
|
||||
bMipMaps = false; // Most sprites (especially text) look worse with mip maps
|
||||
iAlphaBits = 4;
|
||||
|
||||
/* If this is greater than -1, then the image will be loaded as a luma/alpha
|
||||
* map, eg. I4A4. At most 8 bits per pixel will be used This only actually happens
|
||||
* when paletted textures are supported.
|
||||
*
|
||||
* If the sum of alpha and grayscale bits is <= 4, and the system supports 4-bit
|
||||
* palettes, then the image will be loaded with 4bpp.
|
||||
*
|
||||
* This may be set to 0, resulting in an alpha map with all pixels white. */
|
||||
iGrayscaleBits = -1;
|
||||
|
||||
/* If true and color precision is being lost, dither. (slow) */
|
||||
bDither = false;
|
||||
/* If true, resize the image to fill the internal texture. (slow) */
|
||||
bStretch = false;
|
||||
|
||||
/* Preferred color depth of the image. (This is overridden for
|
||||
* paletted images and transparencies.) */
|
||||
iColorDepth = -1; /* default */
|
||||
|
||||
/* If true, enable HOT PINK color keying. (deprecated but needed for
|
||||
* banners) */
|
||||
bHotPinkColorKey = false;
|
||||
|
||||
/* These hints will be used in addition to any in the filename. */
|
||||
AdditionalTextureHints = "";
|
||||
}
|
||||
|
||||
@@ -45,7 +19,7 @@ bool RageTextureID::operator<(const RageTextureID &rhs) const
|
||||
#define COMP(a) if(a<rhs.a) return true; if(a>rhs.a) return false;
|
||||
COMP(filename);
|
||||
COMP(iMaxSize);
|
||||
COMP(iMipMaps);
|
||||
COMP(bMipMaps);
|
||||
COMP(iAlphaBits);
|
||||
COMP(iGrayscaleBits);
|
||||
COMP(iColorDepth);
|
||||
@@ -63,7 +37,7 @@ bool RageTextureID::operator==(const RageTextureID &rhs) const
|
||||
return
|
||||
EQUAL(filename) &&
|
||||
EQUAL(iMaxSize) &&
|
||||
EQUAL(iMipMaps) &&
|
||||
EQUAL(bMipMaps) &&
|
||||
EQUAL(iAlphaBits) &&
|
||||
EQUAL(iGrayscaleBits) &&
|
||||
EQUAL(iColorDepth) &&
|
||||
|
||||
@@ -8,14 +8,42 @@
|
||||
struct RageTextureID
|
||||
{
|
||||
CString filename;
|
||||
|
||||
/* Maximum size of the texture, per dimension. */
|
||||
int iMaxSize;
|
||||
int iMipMaps;
|
||||
|
||||
/* Generate mipmaps for this texture */
|
||||
bool bMipMaps;
|
||||
|
||||
/* Maximum number of bits for alpha. In 16-bit modes, lowering
|
||||
* this gives more bits for color values. (0, 1 or 4) */
|
||||
int iAlphaBits;
|
||||
|
||||
/* If this is greater than -1, then the image will be loaded as a luma/alpha
|
||||
* map, eg. I4A4. At most 8 bits per pixel will be used This only actually happens
|
||||
* when paletted textures are supported.
|
||||
*
|
||||
* If the sum of alpha and grayscale bits is <= 4, and the system supports 4-bit
|
||||
* palettes, then the image will be loaded with 4bpp.
|
||||
*
|
||||
* This may be set to 0, resulting in an alpha map with all pixels white. */
|
||||
int iGrayscaleBits;
|
||||
|
||||
/* Preferred color depth of the image. (This is overridden for
|
||||
* paletted images and transparencies.) -1 for default. */
|
||||
int iColorDepth;
|
||||
|
||||
/* If true and color precision is being lost, dither. (slow) */
|
||||
bool bDither;
|
||||
|
||||
/* If true, resize the image to fill the internal texture. (slow) */
|
||||
bool bStretch;
|
||||
|
||||
/* If true, enable HOT PINK color keying. (deprecated but needed for
|
||||
* banners) */
|
||||
bool bHotPinkColorKey; /* #FF00FF */
|
||||
|
||||
/* These hints will be used in addition to any in the filename. */
|
||||
CString AdditionalTextureHints;
|
||||
|
||||
bool operator< (const RageTextureID &rhs) const;
|
||||
|
||||
@@ -521,6 +521,20 @@ ScreenGameplay::ScreenGameplay( CString sName, bool bDemonstration ) : Screen("S
|
||||
}
|
||||
}
|
||||
|
||||
for( p=0; p<NUM_PLAYERS; p++ )
|
||||
{
|
||||
if( !GAMESTATE->IsPlayerEnabled(p) )
|
||||
continue; // skip
|
||||
|
||||
m_textStepsDescription[p].LoadFromFont( THEME->GetPathToF("ScreenGameplay StepsDescription") );
|
||||
m_textStepsDescription[p].SetName( ssprintf("StepsDescriptionP%i",p+1) );
|
||||
Steps* pSteps = GAMESTATE->m_pCurNotes[p];
|
||||
ASSERT( pSteps );
|
||||
m_textStepsDescription[p].SetText( pSteps->GetDescription() );
|
||||
SET_XY( m_textStepsDescription[p] );
|
||||
this->AddChild( &m_textStepsDescription[p] );
|
||||
}
|
||||
|
||||
switch( GAMESTATE->m_PlayMode )
|
||||
{
|
||||
case PLAY_MODE_ARCADE:
|
||||
@@ -2254,6 +2268,7 @@ void ScreenGameplay::TweenOnScreen()
|
||||
ON_COMMAND( m_textCourseSongNumber[p] );
|
||||
if( GAMESTATE->m_PlayMode == PLAY_MODE_RAVE )
|
||||
ON_COMMAND( m_textPlayerName[p] );
|
||||
ON_COMMAND( m_textStepsDescription[p] );
|
||||
if( m_pPrimaryScoreDisplay[p] )
|
||||
ON_COMMAND( *m_pPrimaryScoreDisplay[p] );
|
||||
if( m_pSecondaryScoreDisplay[p] )
|
||||
@@ -2283,6 +2298,7 @@ void ScreenGameplay::TweenOffScreen()
|
||||
OFF_COMMAND( m_textCourseSongNumber[p] );
|
||||
if( GAMESTATE->m_PlayMode == PLAY_MODE_RAVE )
|
||||
OFF_COMMAND( m_textPlayerName[p] );
|
||||
OFF_COMMAND( m_textStepsDescription[p] );
|
||||
if( m_pPrimaryScoreDisplay[p] )
|
||||
OFF_COMMAND( *m_pPrimaryScoreDisplay[p] );
|
||||
if( m_pSecondaryScoreDisplay[p] )
|
||||
|
||||
@@ -116,6 +116,7 @@ protected:
|
||||
Sprite m_sprCourseSongNumber;
|
||||
BitmapText m_textCourseSongNumber[NUM_PLAYERS];
|
||||
BitmapText m_textPlayerName[NUM_PLAYERS];
|
||||
BitmapText m_textStepsDescription[NUM_PLAYERS];
|
||||
|
||||
BPMDisplay m_BPMDisplay;
|
||||
|
||||
|
||||
@@ -49,7 +49,8 @@ Sprite::~Sprite()
|
||||
|
||||
bool Sprite::LoadBG( RageTextureID ID )
|
||||
{
|
||||
ID.iMipMaps = 1;
|
||||
ID.bMipMaps = true;
|
||||
// Don't we want to dither 16 bit textures at least?
|
||||
// ID.bDither = true;
|
||||
return Load(ID);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user