implement multithreaded rendering with context switch, gl state save/restore, add progress bar ui node, implement stencil texture for brush, implement multithreaded canvas load/save/export pano. Missing multithread in windows.
This commit is contained in:
@@ -111,4 +111,55 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
struct gl_state
|
||||
{
|
||||
GLboolean blend;
|
||||
GLboolean depth_test;
|
||||
GLboolean scissor_test;
|
||||
GLint vp[4];
|
||||
GLfloat cc[4];
|
||||
GLint tex[10];
|
||||
GLint cube;
|
||||
GLint sampler[10];
|
||||
GLint program;
|
||||
GLint fb;
|
||||
GLint active_tex;
|
||||
void save()
|
||||
{
|
||||
blend = glIsEnabled(GL_BLEND);
|
||||
depth_test = glIsEnabled(GL_DEPTH_TEST);
|
||||
scissor_test = glIsEnabled(GL_SCISSOR_TEST);
|
||||
glGetIntegerv(GL_VIEWPORT, vp);
|
||||
glGetFloatv(GL_COLOR_CLEAR_VALUE, cc);
|
||||
glGetIntegerv(GL_CURRENT_PROGRAM, &program);
|
||||
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &fb);
|
||||
glGetIntegerv(GL_ACTIVE_TEXTURE, &active_tex);
|
||||
glGetIntegerv(GL_TEXTURE_BINDING_CUBE_MAP, &cube);
|
||||
for (int i = 0; i < 10; ++i)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0 + i);
|
||||
glGetIntegerv(GL_TEXTURE_BINDING_2D, tex + i);
|
||||
glGetIntegerv(GL_SAMPLER_BINDING, sampler + i);
|
||||
}
|
||||
}
|
||||
void restore()
|
||||
{
|
||||
blend ? glEnable(GL_BLEND) : glDisable(GL_BLEND);
|
||||
depth_test ? glEnable(GL_DEPTH_TEST) : glDisable(GL_DEPTH_TEST);
|
||||
scissor_test ? glEnable(GL_SCISSOR_TEST) : glDisable(GL_SCISSOR_TEST);
|
||||
glViewport(vp[0], vp[1], vp[2], vp[3]);
|
||||
glClearColor(cc[0], cc[1], cc[2], cc[3]);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fb);
|
||||
glUseProgram(program);
|
||||
for (int i = 0; i < 10; ++i)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0 + i);
|
||||
glBindTexture(GL_TEXTURE_2D, tex[i]);
|
||||
glBindSampler(i, sampler[i]);
|
||||
}
|
||||
glActiveTexture(active_tex);
|
||||
glBindTexture(GL_TEXTURE_BINDING_CUBE_MAP, cube);
|
||||
}
|
||||
};
|
||||
|
||||
NS_END
|
||||
|
||||
Reference in New Issue
Block a user