re-add mipmapping, support it in OpenGL (D3D unimplemented)
This commit is contained in:
@@ -1009,7 +1009,7 @@ void BGAnimationLayer::Draw()
|
|||||||
0,
|
0,
|
||||||
RageColor(0.6f,0.6f,0.6f,1),
|
RageColor(0.6f,0.6f,0.6f,1),
|
||||||
RageColor(0.9f,0.9f,0.9f,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) );
|
RageVector3(0, 0, 1) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ struct BannerTexture: public RageTexture
|
|||||||
ASSERT( DISPLAY->SupportsTextureFormat(pf) );
|
ASSERT( DISPLAY->SupportsTextureFormat(pf) );
|
||||||
|
|
||||||
ASSERT(img);
|
ASSERT(img);
|
||||||
m_uTexHandle = DISPLAY->CreateTexture( pf, img );
|
m_uTexHandle = DISPLAY->CreateTexture( pf, img, false );
|
||||||
|
|
||||||
CreateFrameRects();
|
CreateFrameRects();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ void AnimatedTexture::Load( CString sTexOrIniPath )
|
|||||||
ID.filename = Dirname(sTexOrIniPath) + sFileName;
|
ID.filename = Dirname(sTexOrIniPath) + sFileName;
|
||||||
ID.bStretch = true;
|
ID.bStretch = true;
|
||||||
ID.bHotPinkColorKey = true;
|
ID.bHotPinkColorKey = true;
|
||||||
|
ID.bMipMaps = true; // use mipmaps in Models
|
||||||
AnimatedTextureState state = {
|
AnimatedTextureState state = {
|
||||||
TEXTUREMAN->LoadTexture( ID ),
|
TEXTUREMAN->LoadTexture( ID ),
|
||||||
fDelay
|
fDelay
|
||||||
@@ -71,6 +72,7 @@ void AnimatedTexture::Load( CString sTexOrIniPath )
|
|||||||
ID.filename = sTexOrIniPath;
|
ID.filename = sTexOrIniPath;
|
||||||
ID.bHotPinkColorKey = true;
|
ID.bHotPinkColorKey = true;
|
||||||
ID.bStretch = true;
|
ID.bStretch = true;
|
||||||
|
ID.bMipMaps = true; // use mipmaps in Models
|
||||||
AnimatedTextureState state = {
|
AnimatedTextureState state = {
|
||||||
TEXTUREMAN->LoadTexture( ID ),
|
TEXTUREMAN->LoadTexture( ID ),
|
||||||
10
|
10
|
||||||
|
|||||||
@@ -306,7 +306,7 @@ apply_color_key:
|
|||||||
ConvertSDLSurface(img, m_iTextureWidth, m_iTextureHeight,
|
ConvertSDLSurface(img, m_iTextureWidth, m_iTextureHeight,
|
||||||
pfd->bpp, pfd->masks[0], pfd->masks[1], pfd->masks[2], pfd->masks[3]);
|
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();
|
CreateFrameRects();
|
||||||
|
|
||||||
|
|||||||
@@ -151,7 +151,8 @@ public:
|
|||||||
* (unsigned in OpenGL, texture pointer in D3D) */
|
* (unsigned in OpenGL, texture pointer in D3D) */
|
||||||
virtual unsigned CreateTexture(
|
virtual unsigned CreateTexture(
|
||||||
PixelFormat pixfmt, // format of img and of texture in video mem
|
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;
|
) = 0;
|
||||||
virtual void UpdateTexture(
|
virtual void UpdateTexture(
|
||||||
unsigned uTexHandle,
|
unsigned uTexHandle,
|
||||||
|
|||||||
@@ -1053,7 +1053,8 @@ void RageDisplay_D3D::DeleteTexture( unsigned uTexHandle )
|
|||||||
|
|
||||||
unsigned RageDisplay_D3D::CreateTexture(
|
unsigned RageDisplay_D3D::CreateTexture(
|
||||||
PixelFormat pixfmt,
|
PixelFormat pixfmt,
|
||||||
SDL_Surface* img )
|
SDL_Surface* img,
|
||||||
|
bool bGenerateMipMaps )
|
||||||
{
|
{
|
||||||
// texture must be power of two
|
// texture must be power of two
|
||||||
ASSERT( img->w == power_of_two(img->w) );
|
ASSERT( img->w == power_of_two(img->w) );
|
||||||
|
|||||||
@@ -32,7 +32,10 @@ public:
|
|||||||
VideoModeParams GetVideoModeParams() const;
|
VideoModeParams GetVideoModeParams() const;
|
||||||
void SetBlendMode( BlendMode mode );
|
void SetBlendMode( BlendMode mode );
|
||||||
bool SupportsTextureFormat( PixelFormat pixfmt, bool realtime=false );
|
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(
|
void UpdateTexture(
|
||||||
unsigned uTexHandle,
|
unsigned uTexHandle,
|
||||||
SDL_Surface* img,
|
SDL_Surface* img,
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ namespace GLExt {
|
|||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#pragma comment(lib, "opengl32.lib")
|
#pragma comment(lib, "opengl32.lib")
|
||||||
|
#pragma comment(lib, "glu32.lib")
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -1238,7 +1239,8 @@ RageDisplay::PixelFormat RageDisplay_OGL::GetImgPixelFormat( SDL_Surface* &img,
|
|||||||
|
|
||||||
unsigned RageDisplay_OGL::CreateTexture(
|
unsigned RageDisplay_OGL::CreateTexture(
|
||||||
PixelFormat pixfmt,
|
PixelFormat pixfmt,
|
||||||
SDL_Surface* img )
|
SDL_Surface* img,
|
||||||
|
bool bGenerateMipMaps )
|
||||||
{
|
{
|
||||||
ASSERT( pixfmt < NUM_PIX_FORMATS );
|
ASSERT( pixfmt < NUM_PIX_FORMATS );
|
||||||
|
|
||||||
@@ -1248,7 +1250,7 @@ unsigned RageDisplay_OGL::CreateTexture(
|
|||||||
|
|
||||||
glBindTexture( GL_TEXTURE_2D, uTexHandle );
|
glBindTexture( GL_TEXTURE_2D, uTexHandle );
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
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 );
|
SetTextureWrapping( false );
|
||||||
|
|
||||||
// texture must be power of two
|
// texture must be power of two
|
||||||
@@ -1304,9 +1306,24 @@ unsigned RageDisplay_OGL::CreateTexture(
|
|||||||
|
|
||||||
FlushGLErrors();
|
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,
|
img->w, img->h, 0,
|
||||||
glImageFormat, glImageType, img->pixels);
|
glImageFormat, glImageType, img->pixels);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
GLenum error = glGetError();
|
GLenum error = glGetError();
|
||||||
if( error != GL_NO_ERROR )
|
if( error != GL_NO_ERROR )
|
||||||
|
|||||||
@@ -18,7 +18,10 @@ public:
|
|||||||
void SetBlendMode( BlendMode mode );
|
void SetBlendMode( BlendMode mode );
|
||||||
bool SupportsTextureFormat( PixelFormat pixfmt, bool realtime=false );
|
bool SupportsTextureFormat( PixelFormat pixfmt, bool realtime=false );
|
||||||
bool Supports4BitPalettes();
|
bool Supports4BitPalettes();
|
||||||
unsigned CreateTexture( PixelFormat pixfmt, SDL_Surface* img );
|
unsigned CreateTexture(
|
||||||
|
PixelFormat pixfmt,
|
||||||
|
SDL_Surface* img,
|
||||||
|
bool bGenerateMipMaps );
|
||||||
void UpdateTexture(
|
void UpdateTexture(
|
||||||
unsigned uTexHandle,
|
unsigned uTexHandle,
|
||||||
SDL_Surface* img,
|
SDL_Surface* img,
|
||||||
|
|||||||
@@ -3,40 +3,14 @@
|
|||||||
|
|
||||||
void RageTextureID::Init()
|
void RageTextureID::Init()
|
||||||
{
|
{
|
||||||
/* Maximum size of the texture, per dimension. */
|
|
||||||
iMaxSize = 2048;
|
iMaxSize = 2048;
|
||||||
|
bMipMaps = false; // Most sprites (especially text) look worse with mip maps
|
||||||
/* 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) */
|
|
||||||
iAlphaBits = 4;
|
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;
|
iGrayscaleBits = -1;
|
||||||
|
|
||||||
/* If true and color precision is being lost, dither. (slow) */
|
|
||||||
bDither = false;
|
bDither = false;
|
||||||
/* If true, resize the image to fill the internal texture. (slow) */
|
|
||||||
bStretch = false;
|
bStretch = false;
|
||||||
|
|
||||||
/* Preferred color depth of the image. (This is overridden for
|
|
||||||
* paletted images and transparencies.) */
|
|
||||||
iColorDepth = -1; /* default */
|
iColorDepth = -1; /* default */
|
||||||
|
|
||||||
/* If true, enable HOT PINK color keying. (deprecated but needed for
|
|
||||||
* banners) */
|
|
||||||
bHotPinkColorKey = false;
|
bHotPinkColorKey = false;
|
||||||
|
|
||||||
/* These hints will be used in addition to any in the filename. */
|
|
||||||
AdditionalTextureHints = "";
|
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;
|
#define COMP(a) if(a<rhs.a) return true; if(a>rhs.a) return false;
|
||||||
COMP(filename);
|
COMP(filename);
|
||||||
COMP(iMaxSize);
|
COMP(iMaxSize);
|
||||||
COMP(iMipMaps);
|
COMP(bMipMaps);
|
||||||
COMP(iAlphaBits);
|
COMP(iAlphaBits);
|
||||||
COMP(iGrayscaleBits);
|
COMP(iGrayscaleBits);
|
||||||
COMP(iColorDepth);
|
COMP(iColorDepth);
|
||||||
@@ -63,7 +37,7 @@ bool RageTextureID::operator==(const RageTextureID &rhs) const
|
|||||||
return
|
return
|
||||||
EQUAL(filename) &&
|
EQUAL(filename) &&
|
||||||
EQUAL(iMaxSize) &&
|
EQUAL(iMaxSize) &&
|
||||||
EQUAL(iMipMaps) &&
|
EQUAL(bMipMaps) &&
|
||||||
EQUAL(iAlphaBits) &&
|
EQUAL(iAlphaBits) &&
|
||||||
EQUAL(iGrayscaleBits) &&
|
EQUAL(iGrayscaleBits) &&
|
||||||
EQUAL(iColorDepth) &&
|
EQUAL(iColorDepth) &&
|
||||||
|
|||||||
@@ -8,14 +8,42 @@
|
|||||||
struct RageTextureID
|
struct RageTextureID
|
||||||
{
|
{
|
||||||
CString filename;
|
CString filename;
|
||||||
|
|
||||||
|
/* Maximum size of the texture, per dimension. */
|
||||||
int iMaxSize;
|
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;
|
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;
|
int iGrayscaleBits;
|
||||||
|
|
||||||
|
/* Preferred color depth of the image. (This is overridden for
|
||||||
|
* paletted images and transparencies.) -1 for default. */
|
||||||
int iColorDepth;
|
int iColorDepth;
|
||||||
|
|
||||||
|
/* If true and color precision is being lost, dither. (slow) */
|
||||||
bool bDither;
|
bool bDither;
|
||||||
|
|
||||||
|
/* If true, resize the image to fill the internal texture. (slow) */
|
||||||
bool bStretch;
|
bool bStretch;
|
||||||
|
|
||||||
|
/* If true, enable HOT PINK color keying. (deprecated but needed for
|
||||||
|
* banners) */
|
||||||
bool bHotPinkColorKey; /* #FF00FF */
|
bool bHotPinkColorKey; /* #FF00FF */
|
||||||
|
|
||||||
|
/* These hints will be used in addition to any in the filename. */
|
||||||
CString AdditionalTextureHints;
|
CString AdditionalTextureHints;
|
||||||
|
|
||||||
bool operator< (const RageTextureID &rhs) const;
|
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 )
|
switch( GAMESTATE->m_PlayMode )
|
||||||
{
|
{
|
||||||
case PLAY_MODE_ARCADE:
|
case PLAY_MODE_ARCADE:
|
||||||
@@ -2254,6 +2268,7 @@ void ScreenGameplay::TweenOnScreen()
|
|||||||
ON_COMMAND( m_textCourseSongNumber[p] );
|
ON_COMMAND( m_textCourseSongNumber[p] );
|
||||||
if( GAMESTATE->m_PlayMode == PLAY_MODE_RAVE )
|
if( GAMESTATE->m_PlayMode == PLAY_MODE_RAVE )
|
||||||
ON_COMMAND( m_textPlayerName[p] );
|
ON_COMMAND( m_textPlayerName[p] );
|
||||||
|
ON_COMMAND( m_textStepsDescription[p] );
|
||||||
if( m_pPrimaryScoreDisplay[p] )
|
if( m_pPrimaryScoreDisplay[p] )
|
||||||
ON_COMMAND( *m_pPrimaryScoreDisplay[p] );
|
ON_COMMAND( *m_pPrimaryScoreDisplay[p] );
|
||||||
if( m_pSecondaryScoreDisplay[p] )
|
if( m_pSecondaryScoreDisplay[p] )
|
||||||
@@ -2283,6 +2298,7 @@ void ScreenGameplay::TweenOffScreen()
|
|||||||
OFF_COMMAND( m_textCourseSongNumber[p] );
|
OFF_COMMAND( m_textCourseSongNumber[p] );
|
||||||
if( GAMESTATE->m_PlayMode == PLAY_MODE_RAVE )
|
if( GAMESTATE->m_PlayMode == PLAY_MODE_RAVE )
|
||||||
OFF_COMMAND( m_textPlayerName[p] );
|
OFF_COMMAND( m_textPlayerName[p] );
|
||||||
|
OFF_COMMAND( m_textStepsDescription[p] );
|
||||||
if( m_pPrimaryScoreDisplay[p] )
|
if( m_pPrimaryScoreDisplay[p] )
|
||||||
OFF_COMMAND( *m_pPrimaryScoreDisplay[p] );
|
OFF_COMMAND( *m_pPrimaryScoreDisplay[p] );
|
||||||
if( m_pSecondaryScoreDisplay[p] )
|
if( m_pSecondaryScoreDisplay[p] )
|
||||||
|
|||||||
@@ -116,6 +116,7 @@ protected:
|
|||||||
Sprite m_sprCourseSongNumber;
|
Sprite m_sprCourseSongNumber;
|
||||||
BitmapText m_textCourseSongNumber[NUM_PLAYERS];
|
BitmapText m_textCourseSongNumber[NUM_PLAYERS];
|
||||||
BitmapText m_textPlayerName[NUM_PLAYERS];
|
BitmapText m_textPlayerName[NUM_PLAYERS];
|
||||||
|
BitmapText m_textStepsDescription[NUM_PLAYERS];
|
||||||
|
|
||||||
BPMDisplay m_BPMDisplay;
|
BPMDisplay m_BPMDisplay;
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,8 @@ Sprite::~Sprite()
|
|||||||
|
|
||||||
bool Sprite::LoadBG( RageTextureID ID )
|
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;
|
// ID.bDither = true;
|
||||||
return Load(ID);
|
return Load(ID);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user