mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-10-10 00:11:29 +00:00
Eliminating obsolete #ifdefs and friends (#26)
The following options have been applied globally, using unifdef(1): ```c #undef BBGE_BUILD_DIRECTX #define BBGE_BUILD_OPENGL 1 #define GL_GLEXT_LEGACY 1 #define HAVE_PUTENV 1 #define TIXML_USE_STL 1 #define BBGE_BUILD_SDL 1 ```
This commit is contained in:
parent
dff33b0530
commit
276265be1d
54 changed files with 1 additions and 2248 deletions
|
@ -41,11 +41,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include "..\j2k-codec\j2k-codec.h"
|
||||
#endif
|
||||
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
GLint Texture::filter = GL_LINEAR;
|
||||
|
||||
GLint Texture::format = 0;
|
||||
#endif
|
||||
bool Texture::useMipMaps = true;
|
||||
|
||||
/*
|
||||
|
@ -57,12 +55,7 @@ bool Texture::useMipMaps = true;
|
|||
|
||||
Texture::Texture()
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
textures[0] = 0;
|
||||
#endif
|
||||
#ifdef BBGE_BUILD_DIRECTX
|
||||
d3dTexture = 0;
|
||||
#endif
|
||||
width = height = 0;
|
||||
|
||||
repeat = false;
|
||||
|
@ -79,7 +72,6 @@ Texture::~Texture()
|
|||
|
||||
void Texture::read(int tx, int ty, int w, int h, unsigned char *pixels)
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
if (tx == 0 && ty == 0 && w == this->width && h == this->height)
|
||||
{
|
||||
glBindTexture(GL_TEXTURE_2D, textures[0]);
|
||||
|
@ -94,12 +86,10 @@ void Texture::read(int tx, int ty, int w, int h, unsigned char *pixels)
|
|||
<< tx << "," << ty << "+" << w << "x" << h << ")";
|
||||
debugLog(os.str());
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Texture::write(int tx, int ty, int w, int h, const unsigned char *pixels)
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
glBindTexture(GL_TEXTURE_2D, textures[0]);
|
||||
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0,
|
||||
|
@ -145,12 +135,10 @@ void Texture::write(int tx, int ty, int w, int h, const unsigned char *pixels)
|
|||
|
||||
pixels Specifies a pointer to the image data in memory.
|
||||
*/
|
||||
#endif
|
||||
}
|
||||
|
||||
void Texture::unload()
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
if (textures[0])
|
||||
{
|
||||
ow = width;
|
||||
|
@ -165,28 +153,17 @@ void Texture::unload()
|
|||
glDeleteTextures(1, &textures[0]);
|
||||
textures[0] = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Texture::destroy()
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
unload();
|
||||
#endif
|
||||
#ifdef BBGE_BUILD_DIRECTX
|
||||
if (d3dTexture)
|
||||
{
|
||||
d3dTexture->Release();
|
||||
d3dTexture = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
core->removeTexture(this);
|
||||
}
|
||||
|
||||
int Texture::getPixelWidth()
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
int w = 0, h = 0;
|
||||
unsigned int size = 0;
|
||||
unsigned char *data = getBufferAndSize(&w, &h, &size);
|
||||
|
@ -210,14 +187,10 @@ int Texture::getPixelWidth()
|
|||
}
|
||||
free(data);
|
||||
return largestx - smallestx;
|
||||
#elif defined(BBGE_BUILD_DIRECTX)
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int Texture::getPixelHeight()
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
int w = 0, h = 0;
|
||||
unsigned int size = 0;
|
||||
unsigned char *data = getBufferAndSize(&w, &h, &size);
|
||||
|
@ -241,9 +214,6 @@ int Texture::getPixelHeight()
|
|||
}
|
||||
free(data);
|
||||
return largesty - smallesty;
|
||||
#elif defined(BBGE_BUILD_DIRECTX)
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void Texture::reload()
|
||||
|
@ -320,25 +290,8 @@ bool Texture::load(std::string file)
|
|||
if (post == "png")
|
||||
{
|
||||
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
return loadPNG(file);
|
||||
#endif
|
||||
|
||||
#ifdef BBGE_BUILD_DIRECTX
|
||||
D3DXCreateTextureFromFile(core->getD3DDevice(), file.c_str(), &this->d3dTexture);
|
||||
if (!d3dTexture)
|
||||
{
|
||||
errorLog ("failed to load texture");
|
||||
}
|
||||
else
|
||||
{
|
||||
D3DSURFACE_DESC desc;
|
||||
this->d3dTexture->GetLevelDesc(0,&desc);
|
||||
|
||||
width = desc.Width;
|
||||
height = desc.Height;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else if (post == "zga")
|
||||
{
|
||||
|
@ -364,7 +317,6 @@ bool Texture::load(std::string file)
|
|||
|
||||
void Texture::apply(bool repeatOverride)
|
||||
{
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
glBindTexture(GL_TEXTURE_2D, textures[0]);
|
||||
if (repeat || repeatOverride)
|
||||
{
|
||||
|
@ -384,11 +336,6 @@ void Texture::apply(bool repeatOverride)
|
|||
repeating = false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifdef BBGE_BUILD_DIRECTX
|
||||
core->getD3DDevice()->SetTexture(0, d3dTexture);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
void Texture::unbind()
|
||||
|
@ -400,7 +347,6 @@ bool Texture::loadPNG(const std::string &file)
|
|||
if (file.empty()) return false;
|
||||
bool good = false;
|
||||
|
||||
#ifdef BBGE_BUILD_OPENGL
|
||||
|
||||
|
||||
pngInfo info;
|
||||
|
@ -444,7 +390,6 @@ bool Texture::loadPNG(const std::string &file)
|
|||
if(memptr)
|
||||
delete [] memptr;
|
||||
|
||||
#endif
|
||||
return good;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue