mirror of
https://github.com/love2d/love.git
synced 2026-08-17 19:23:38 +02:00
Only pad when needed
This commit is contained in:
@@ -29,7 +29,6 @@ namespace graphics
|
|||||||
{
|
{
|
||||||
namespace opengl
|
namespace opengl
|
||||||
{
|
{
|
||||||
|
|
||||||
Image::Image(love::image::ImageData * data)
|
Image::Image(love::image::ImageData * data)
|
||||||
: width((float)(data->getWidth())), height((float)(data->getHeight())), texture(0)
|
: width((float)(data->getWidth())), height((float)(data->getHeight())), texture(0)
|
||||||
{
|
{
|
||||||
@@ -276,6 +275,14 @@ namespace opengl
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Image::loadVolatile()
|
bool Image::loadVolatile()
|
||||||
|
{
|
||||||
|
if (GLEE_ARB_texture_non_power_of_two)
|
||||||
|
return loadVolatileNPOT();
|
||||||
|
else
|
||||||
|
return loadVolatilePOT();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Image::loadVolatilePOT()
|
||||||
{
|
{
|
||||||
glGenTextures(1,(GLuint*)&texture);
|
glGenTextures(1,(GLuint*)&texture);
|
||||||
glBindTexture(GL_TEXTURE_2D, texture);
|
glBindTexture(GL_TEXTURE_2D, texture);
|
||||||
@@ -321,6 +328,32 @@ namespace opengl
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Image::loadVolatileNPOT()
|
||||||
|
{
|
||||||
|
glGenTextures(1,(GLuint*)&texture);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, texture);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
|
|
||||||
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
|
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
|
|
||||||
|
glTexImage2D(GL_TEXTURE_2D,
|
||||||
|
0,
|
||||||
|
GL_RGBA8,
|
||||||
|
(GLsizei)width,
|
||||||
|
(GLsizei)height,
|
||||||
|
0,
|
||||||
|
GL_RGBA,
|
||||||
|
GL_UNSIGNED_BYTE,
|
||||||
|
data->getData());
|
||||||
|
|
||||||
|
setFilter(settings.filter);
|
||||||
|
setWrap(settings.wrap);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void Image::unloadVolatile()
|
void Image::unloadVolatile()
|
||||||
{
|
{
|
||||||
settings.filter = getFilter();
|
settings.filter = getFilter();
|
||||||
|
|||||||
@@ -69,6 +69,9 @@ namespace opengl
|
|||||||
Image::Wrap wrap;
|
Image::Wrap wrap;
|
||||||
} settings;
|
} settings;
|
||||||
|
|
||||||
|
bool loadVolatilePOT();
|
||||||
|
bool loadVolatileNPOT();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user