Changed: Renamed a few classes
Changed: Moved most sensible objects into the OpenArena namespace ~g2k
This commit is contained in:
106
src/mygl.cpp
106
src/mygl.cpp
@@ -1,65 +1,67 @@
|
||||
|
||||
#include "../include/mygl.h"
|
||||
|
||||
void FreeGLTexture(GLuint& texture)
|
||||
namespace OpenArena
|
||||
{
|
||||
glDeleteTextures(1, &texture);
|
||||
}
|
||||
|
||||
bool LoadGLTexture(string fn, GLuint& texture, GLuint mag, GLuint min)
|
||||
{
|
||||
if(Right(tolower(fn), 4) == ".bmp")
|
||||
void FreeGLTexture(GLuint& texture)
|
||||
{
|
||||
TextureImage* texImage = NULL;
|
||||
if(texImage = LoadBMP(fn.c_str()))
|
||||
glDeleteTextures(1, &texture);
|
||||
}
|
||||
|
||||
bool LoadGLTexture(string fn, GLuint& texture, GLuint mag, GLuint min)
|
||||
{
|
||||
if(Right(tolower(fn), 4) == ".bmp")
|
||||
{
|
||||
glGenTextures(1, &texture);
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, 3, texImage->sizeX, texImage->sizeY, 0, texImage->type, GL_UNSIGNED_BYTE, texImage->data);
|
||||
|
||||
if(texImage) //Just in case somehow the file was empty or unloadable
|
||||
TextureImage* texImage = NULL;
|
||||
if(texImage = LoadBMP(fn.c_str()))
|
||||
{
|
||||
if(texImage->data)
|
||||
free(texImage->data);
|
||||
free(texImage);
|
||||
glGenTextures(1, &texture);
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, 3, texImage->sizeX, texImage->sizeY, 0, texImage->type, GL_UNSIGNED_BYTE, texImage->data);
|
||||
|
||||
if(texImage) //Just in case somehow the file was empty or unloadable
|
||||
{
|
||||
if(texImage->data)
|
||||
free(texImage->data);
|
||||
free(texImage);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if(Right(tolower(fn), 4) == ".tga")
|
||||
{
|
||||
TextureImage* texImage = NULL;
|
||||
if(texImage = LoadTGA(fn.c_str()))
|
||||
{
|
||||
glGenTextures(1, &texture);
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, 3, texImage->sizeX, texImage->sizeY, 0, texImage->type, GL_UNSIGNED_BYTE, texImage->data);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
if(texImage) //Just in case somehow the file was empty or unloadable
|
||||
{
|
||||
if(texImage->data)
|
||||
free(texImage->data);
|
||||
free(texImage);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(Right(tolower(fn), 4) == ".tga")
|
||||
{
|
||||
TextureImage* texImage = NULL;
|
||||
if(texImage = LoadTGA(fn.c_str()))
|
||||
{
|
||||
glGenTextures(1, &texture);
|
||||
glBindTexture(GL_TEXTURE_2D, texture);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, 3, texImage->sizeX, texImage->sizeY, 0, texImage->type, GL_UNSIGNED_BYTE, texImage->data);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
|
||||
if(texImage) //Just in case somehow the file was empty or unloadable
|
||||
{
|
||||
if(texImage->data)
|
||||
free(texImage->data);
|
||||
free(texImage);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
OpenArena::Window g_Screen;
|
||||
|
||||
Reference in New Issue
Block a user