mirror of
https://github.com/PixarAnimationStudios/OpenSubdiv
synced 2024-12-29 19:21:18 +00:00
Minor fixes to gl_hud and gl_framebuffer
- leave framebuffer off by default (and remove SSAO UI from examples) - fix some resources leakage when toggling SSAO on/off
This commit is contained in:
parent
b74f45f68d
commit
77b71a0446
@ -73,14 +73,18 @@ GLFrameBuffer::Init(int width, int height) {
|
||||
if (not _program)
|
||||
_program = compileProgram(g_framebufferShaderSource);
|
||||
|
||||
if (not _vao) {
|
||||
glGenVertexArrays(1, &_vao);
|
||||
}
|
||||
glBindVertexArray(_vao);
|
||||
|
||||
if (not _vbo) {
|
||||
glGenBuffers(1, &_vbo);
|
||||
float pos[] = { -1, -1, 1, -1, -1, 1, 1, 1 };
|
||||
static float pos[] = { -1, -1, 1, -1, -1, 1, 1, 1 };
|
||||
glGenBuffers(1, &_vbo);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(pos), pos, GL_STATIC_DRAW);
|
||||
}
|
||||
glBindBuffer(GL_ARRAY_BUFFER, _vbo);
|
||||
|
||||
glEnableVertexAttribArray(0);
|
||||
@ -89,28 +93,37 @@ GLFrameBuffer::Init(int width, int height) {
|
||||
glBindVertexArray(0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
||||
if (not _frameBuffer) {
|
||||
glGenFramebuffers(1, &_frameBuffer);
|
||||
glGenTextures(1, &_frameBufferColor);
|
||||
glGenTextures(1, &_frameBufferNormal);
|
||||
glGenTextures(1, &_frameBufferDepthTexture);
|
||||
|
||||
|
||||
if (not _frameBufferColor) {
|
||||
glGenTextures(1, &_frameBufferColor);
|
||||
glBindTexture(GL_TEXTURE_2D, _frameBufferColor);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameterf(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);
|
||||
}
|
||||
|
||||
if (not _frameBufferNormal) {
|
||||
glGenTextures(1, &_frameBufferNormal);
|
||||
glBindTexture(GL_TEXTURE_2D, _frameBufferNormal);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameterf(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);
|
||||
}
|
||||
|
||||
if (not _frameBufferDepthTexture) {
|
||||
glGenTextures(1, &_frameBufferDepthTexture);
|
||||
glBindTexture(GL_TEXTURE_2D, _frameBufferDepthTexture);
|
||||
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glTexParameterf(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);
|
||||
}
|
||||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
checkGLErrors("FrameBuffer::Init");
|
||||
|
@ -192,12 +192,6 @@ GLhud::Init(int width, int height)
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
||||
checkGLErrors("GLhud::Init");
|
||||
|
||||
_frameBuffer = new SSAOGLFrameBuffer;
|
||||
|
||||
_frameBuffer->Init(width, height);
|
||||
|
||||
_frameBuffer->BuildUI(this, 10, 600);
|
||||
}
|
||||
|
||||
void
|
||||
@ -214,7 +208,9 @@ GLhud::Rebuild(int width, int height)
|
||||
&getStaticVboSource()[0], GL_STATIC_DRAW);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
||||
if (GetFrameBuffer()) {
|
||||
GetFrameBuffer()->Reshape(width, height);
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -43,6 +43,14 @@ public:
|
||||
|
||||
virtual bool Flush();
|
||||
|
||||
void SetFrameBuffer(GLFrameBuffer * frameBuffer) {
|
||||
if (not _frameBuffer) {
|
||||
_frameBuffer = frameBuffer;
|
||||
_frameBuffer->Init(GetWidth(), GetHeight());
|
||||
_frameBuffer->BuildUI(this, 10, 600);
|
||||
}
|
||||
}
|
||||
|
||||
GLFrameBuffer * GetFrameBuffer() {
|
||||
return _frameBuffer;
|
||||
}
|
||||
|
@ -1726,8 +1726,12 @@ initHUD()
|
||||
// window size might not match framebuffer size on a high DPI display
|
||||
glfwGetWindowSize(g_window, &windowWidth, &windowHeight);
|
||||
#endif
|
||||
|
||||
|
||||
g_hud.Init(windowWidth, windowHeight);
|
||||
|
||||
g_hud.SetFrameBuffer(new SSAOGLFrameBuffer);
|
||||
|
||||
g_hud.AddCheckBox("Cage Edges (H)", g_drawCageEdges != 0,
|
||||
10, 10, callbackCheckBox, kHUD_CB_DISPLAY_CAGE_EDGES, 'h');
|
||||
g_hud.AddCheckBox("Cage Verts (J)", g_drawCageVertices != 0,
|
||||
|
Loading…
Reference in New Issue
Block a user