mirror of
https://github.com/love2d/love.git
synced 2026-08-16 08:11:02 +02:00
Minor pre-emptive fixes for GL3.
--HG-- branch : minor
This commit is contained in:
@@ -56,6 +56,7 @@ namespace opengl
|
||||
Graphics::Graphics()
|
||||
: quadIndices(nullptr)
|
||||
, windowHasStencil(false)
|
||||
, mainVAO(0)
|
||||
{
|
||||
gl = OpenGL();
|
||||
|
||||
@@ -224,9 +225,10 @@ bool Graphics::setMode(int width, int height, int pixelwidth, int pixelheight, b
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
// 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
|
||||
glEnable(GL_MULTISAMPLE);
|
||||
@@ -235,6 +237,12 @@ bool Graphics::setMode(int width, int height, int pixelwidth, int pixelheight, b
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
}
|
||||
|
||||
if (gl.isCoreProfile())
|
||||
{
|
||||
glGenVertexArrays(1, &mainVAO);
|
||||
glBindVertexArray(mainVAO);
|
||||
}
|
||||
|
||||
gl.setTextureUnit(0);
|
||||
|
||||
// Set pixel row alignment
|
||||
@@ -334,6 +342,12 @@ void Graphics::unSetMode()
|
||||
framebufferObjects.clear();
|
||||
stencilBuffers.clear();
|
||||
|
||||
if (mainVAO != 0)
|
||||
{
|
||||
glDeleteVertexArrays(1, &mainVAO);
|
||||
mainVAO = 0;
|
||||
}
|
||||
|
||||
gl.deInitContext();
|
||||
|
||||
created = false;
|
||||
|
||||
@@ -157,6 +157,8 @@ private:
|
||||
|
||||
bool windowHasStencil;
|
||||
|
||||
GLuint mainVAO;
|
||||
|
||||
}; // Graphics
|
||||
|
||||
} // opengl
|
||||
|
||||
@@ -73,6 +73,8 @@ OpenGL::OpenGL()
|
||||
, maxRenderTargets(1)
|
||||
, maxRenderbufferSamples(0)
|
||||
, maxTextureUnits(1)
|
||||
, maxPointSize(1)
|
||||
, coreProfile(false)
|
||||
, vendor(VENDOR_UNKNOWN)
|
||||
, state()
|
||||
{
|
||||
@@ -90,6 +92,15 @@ bool OpenGL::initContext()
|
||||
if (!gladLoadGLLoader(LOVEGetProcAddress))
|
||||
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();
|
||||
initVendor();
|
||||
|
||||
@@ -100,7 +111,8 @@ bool OpenGL::initContext()
|
||||
if (getVendor() == VENDOR_AMD)
|
||||
{
|
||||
bugs.clearRequiresDriverTextureStateUpdate = true;
|
||||
bugs.generateMipmapsRequiresTexture2DEnable = true;
|
||||
if (!gl.isCoreProfile())
|
||||
bugs.generateMipmapsRequiresTexture2DEnable = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -306,7 +318,10 @@ void OpenGL::initMaxValues()
|
||||
glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxTextureUnits);
|
||||
|
||||
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];
|
||||
}
|
||||
|
||||
@@ -741,6 +756,11 @@ void OpenGL::updateTextureMemorySize(size_t oldsize, size_t newsize)
|
||||
stats.textureMemory = (size_t) std::max(memsize, (int64) 0);
|
||||
}
|
||||
|
||||
bool OpenGL::isCoreProfile() const
|
||||
{
|
||||
return coreProfile;
|
||||
}
|
||||
|
||||
OpenGL::Vendor OpenGL::getVendor() const
|
||||
{
|
||||
return vendor;
|
||||
|
||||
@@ -347,6 +347,11 @@ public:
|
||||
|
||||
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.
|
||||
**/
|
||||
@@ -385,6 +390,8 @@ private:
|
||||
int maxTextureUnits;
|
||||
float maxPointSize;
|
||||
|
||||
bool coreProfile;
|
||||
|
||||
Vendor vendor;
|
||||
|
||||
// Tracked OpenGL state.
|
||||
|
||||
Reference in New Issue
Block a user