Only query for GL_MAX_SAMPLES once

This commit is contained in:
Magnus Norddahl 2016-08-17 17:59:47 +02:00
parent 3c08f5ae48
commit fc01a6b832
2 changed files with 3 additions and 16 deletions

View file

@ -65,6 +65,7 @@ CVAR(Bool, gl_renderbuffers, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG);
FGLRenderBuffers::FGLRenderBuffers()
{
glGetIntegerv(GL_FRAMEBUFFER_BINDING, (GLint*)&mOutputFB);
glGetIntegerv(GL_MAX_SAMPLES, &mMaxSamples);
}
//==========================================================================
@ -147,7 +148,7 @@ void FGLRenderBuffers::Setup(int width, int height, int sceneWidth, int sceneHei
if (width <= 0 || height <= 0)
I_FatalError("Requested invalid render buffer sizes: screen = %dx%d", width, height);
int samples = GetCvarSamples();
int samples = clamp((int)gl_multisample, 0, mMaxSamples);
GLint activeTex;
GLint textureBinding;
@ -269,20 +270,6 @@ GLuint FGLRenderBuffers::GetHdrFormat()
return ((gl.flags & RFL_NO_RGBA16F) != 0) ? GL_RGBA8 : GL_RGBA16;
}
//==========================================================================
//
// Converts the CVAR multisample value into a valid level for OpenGL
//
//==========================================================================
int FGLRenderBuffers::GetCvarSamples()
{
int maxSamples = 0;
glGetIntegerv(GL_MAX_SAMPLES, &maxSamples);
return clamp((int)gl_multisample, 0, maxSamples);
}
//==========================================================================
//
// Creates a 2D texture defaulting to linear filtering and clamp to edge

View file

@ -59,12 +59,12 @@ private:
void DeleteRenderBuffer(GLuint &handle);
void DeleteFrameBuffer(GLuint &handle);
int GetCvarSamples();
GLuint GetHdrFormat();
int mWidth = 0;
int mHeight = 0;
int mSamples = 0;
int mMaxSamples = 0;
int mBloomWidth = 0;
int mBloomHeight = 0;