mirror of
https://github.com/love2d/love.git
synced 2026-08-17 19:23:38 +02:00
Minor pre-emptive fixes for GL3.
--HG-- branch : minor
This commit is contained in:
@@ -56,6 +56,7 @@ namespace opengl
|
|||||||
Graphics::Graphics()
|
Graphics::Graphics()
|
||||||
: quadIndices(nullptr)
|
: quadIndices(nullptr)
|
||||||
, windowHasStencil(false)
|
, windowHasStencil(false)
|
||||||
|
, mainVAO(0)
|
||||||
{
|
{
|
||||||
gl = OpenGL();
|
gl = OpenGL();
|
||||||
|
|
||||||
@@ -224,9 +225,10 @@ bool Graphics::setMode(int width, int height, int pixelwidth, int pixelheight, b
|
|||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
|
|
||||||
// Auto-generated mipmaps should be the best quality possible
|
// Auto-generated mipmaps should be the best quality possible
|
||||||
glHint(GL_GENERATE_MIPMAP_HINT, GL_NICEST);
|
if (!gl.isCoreProfile())
|
||||||
|
glHint(GL_GENERATE_MIPMAP_HINT, GL_NICEST);
|
||||||
|
|
||||||
if (!GLAD_ES_VERSION_2_0)
|
if (!GLAD_ES_VERSION_2_0 && !gl.isCoreProfile())
|
||||||
{
|
{
|
||||||
// Make sure antialiasing works when set elsewhere
|
// Make sure antialiasing works when set elsewhere
|
||||||
glEnable(GL_MULTISAMPLE);
|
glEnable(GL_MULTISAMPLE);
|
||||||
@@ -235,6 +237,12 @@ bool Graphics::setMode(int width, int height, int pixelwidth, int pixelheight, b
|
|||||||
glEnable(GL_TEXTURE_2D);
|
glEnable(GL_TEXTURE_2D);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (gl.isCoreProfile())
|
||||||
|
{
|
||||||
|
glGenVertexArrays(1, &mainVAO);
|
||||||
|
glBindVertexArray(mainVAO);
|
||||||
|
}
|
||||||
|
|
||||||
gl.setTextureUnit(0);
|
gl.setTextureUnit(0);
|
||||||
|
|
||||||
// Set pixel row alignment
|
// Set pixel row alignment
|
||||||
@@ -334,6 +342,12 @@ void Graphics::unSetMode()
|
|||||||
framebufferObjects.clear();
|
framebufferObjects.clear();
|
||||||
stencilBuffers.clear();
|
stencilBuffers.clear();
|
||||||
|
|
||||||
|
if (mainVAO != 0)
|
||||||
|
{
|
||||||
|
glDeleteVertexArrays(1, &mainVAO);
|
||||||
|
mainVAO = 0;
|
||||||
|
}
|
||||||
|
|
||||||
gl.deInitContext();
|
gl.deInitContext();
|
||||||
|
|
||||||
created = false;
|
created = false;
|
||||||
|
|||||||
@@ -157,6 +157,8 @@ private:
|
|||||||
|
|
||||||
bool windowHasStencil;
|
bool windowHasStencil;
|
||||||
|
|
||||||
|
GLuint mainVAO;
|
||||||
|
|
||||||
}; // Graphics
|
}; // Graphics
|
||||||
|
|
||||||
} // opengl
|
} // opengl
|
||||||
|
|||||||
@@ -73,6 +73,8 @@ OpenGL::OpenGL()
|
|||||||
, maxRenderTargets(1)
|
, maxRenderTargets(1)
|
||||||
, maxRenderbufferSamples(0)
|
, maxRenderbufferSamples(0)
|
||||||
, maxTextureUnits(1)
|
, maxTextureUnits(1)
|
||||||
|
, maxPointSize(1)
|
||||||
|
, coreProfile(false)
|
||||||
, vendor(VENDOR_UNKNOWN)
|
, vendor(VENDOR_UNKNOWN)
|
||||||
, state()
|
, state()
|
||||||
{
|
{
|
||||||
@@ -90,6 +92,15 @@ bool OpenGL::initContext()
|
|||||||
if (!gladLoadGLLoader(LOVEGetProcAddress))
|
if (!gladLoadGLLoader(LOVEGetProcAddress))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if (GLAD_VERSION_3_2)
|
||||||
|
{
|
||||||
|
GLint profileMask = 0;
|
||||||
|
glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &profileMask);
|
||||||
|
coreProfile = (profileMask & GL_CONTEXT_CORE_PROFILE_BIT);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
coreProfile = false;
|
||||||
|
|
||||||
initOpenGLFunctions();
|
initOpenGLFunctions();
|
||||||
initVendor();
|
initVendor();
|
||||||
|
|
||||||
@@ -100,7 +111,8 @@ bool OpenGL::initContext()
|
|||||||
if (getVendor() == VENDOR_AMD)
|
if (getVendor() == VENDOR_AMD)
|
||||||
{
|
{
|
||||||
bugs.clearRequiresDriverTextureStateUpdate = true;
|
bugs.clearRequiresDriverTextureStateUpdate = true;
|
||||||
bugs.generateMipmapsRequiresTexture2DEnable = true;
|
if (!gl.isCoreProfile())
|
||||||
|
bugs.generateMipmapsRequiresTexture2DEnable = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -306,7 +318,10 @@ void OpenGL::initMaxValues()
|
|||||||
glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxTextureUnits);
|
glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxTextureUnits);
|
||||||
|
|
||||||
GLfloat limits[2];
|
GLfloat limits[2];
|
||||||
glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, limits);
|
if (GLAD_VERSION_3_0)
|
||||||
|
glGetFloatv(GL_POINT_SIZE_RANGE, limits);
|
||||||
|
else
|
||||||
|
glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, limits);
|
||||||
maxPointSize = limits[1];
|
maxPointSize = limits[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -741,6 +756,11 @@ void OpenGL::updateTextureMemorySize(size_t oldsize, size_t newsize)
|
|||||||
stats.textureMemory = (size_t) std::max(memsize, (int64) 0);
|
stats.textureMemory = (size_t) std::max(memsize, (int64) 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool OpenGL::isCoreProfile() const
|
||||||
|
{
|
||||||
|
return coreProfile;
|
||||||
|
}
|
||||||
|
|
||||||
OpenGL::Vendor OpenGL::getVendor() const
|
OpenGL::Vendor OpenGL::getVendor() const
|
||||||
{
|
{
|
||||||
return vendor;
|
return vendor;
|
||||||
|
|||||||
@@ -347,6 +347,11 @@ public:
|
|||||||
|
|
||||||
void updateTextureMemorySize(size_t oldsize, size_t newsize);
|
void updateTextureMemorySize(size_t oldsize, size_t newsize);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets whether the context is Core Profile OpenGL 3.2+.
|
||||||
|
**/
|
||||||
|
bool isCoreProfile() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the GPU vendor of this OpenGL context.
|
* Get the GPU vendor of this OpenGL context.
|
||||||
**/
|
**/
|
||||||
@@ -385,6 +390,8 @@ private:
|
|||||||
int maxTextureUnits;
|
int maxTextureUnits;
|
||||||
float maxPointSize;
|
float maxPointSize;
|
||||||
|
|
||||||
|
bool coreProfile;
|
||||||
|
|
||||||
Vendor vendor;
|
Vendor vendor;
|
||||||
|
|
||||||
// Tracked OpenGL state.
|
// Tracked OpenGL state.
|
||||||
|
|||||||
Reference in New Issue
Block a user