mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-09-09 15:30:42 +02:00
Restore previously bound FBO in renderer functions
This commit is contained in:
@@ -34,17 +34,20 @@ extern "C"
|
|||||||
void Renderer::clearScreen(float alpha)
|
void Renderer::clearScreen(float alpha)
|
||||||
{
|
{
|
||||||
#ifdef OGLR
|
#ifdef OGLR
|
||||||
|
GLint prevFbo;
|
||||||
if(alpha > 0.999f)
|
if(alpha > 0.999f)
|
||||||
{
|
{
|
||||||
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &prevFbo);
|
||||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, partsFbo);
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, partsFbo);
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, prevFbo);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
glBlendEquation(GL_FUNC_REVERSE_SUBTRACT);
|
glBlendEquation(GL_FUNC_REVERSE_SUBTRACT);
|
||||||
glColor4f(1.0f, 1.0f, 1.0f, alpha);
|
glColor4f(1.0f, 1.0f, 1.0f, alpha);
|
||||||
|
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &prevFbo);
|
||||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, partsFbo);
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, partsFbo);
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
glVertex2f(0, 0);
|
glVertex2f(0, 0);
|
||||||
@@ -52,7 +55,7 @@ void Renderer::clearScreen(float alpha)
|
|||||||
glVertex2f(XRES, YRES);
|
glVertex2f(XRES, YRES);
|
||||||
glVertex2f(0, YRES);
|
glVertex2f(0, YRES);
|
||||||
glEnd();
|
glEnd();
|
||||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, prevFbo);
|
||||||
glBlendEquation(GL_FUNC_ADD);
|
glBlendEquation(GL_FUNC_ADD);
|
||||||
}
|
}
|
||||||
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
@@ -486,6 +489,8 @@ void Renderer::DrawSigns()
|
|||||||
int i, j, x, y, w, h, dx, dy,mx,my,b=1,bq;
|
int i, j, x, y, w, h, dx, dy,mx,my,b=1,bq;
|
||||||
std::vector<sign> signs = sim->signs;
|
std::vector<sign> signs = sim->signs;
|
||||||
#ifdef OGLR
|
#ifdef OGLR
|
||||||
|
GLint prevFbo;
|
||||||
|
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &prevFbo);
|
||||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, partsFbo);
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, partsFbo);
|
||||||
glTranslated(0, MENUSIZE, 0);
|
glTranslated(0, MENUSIZE, 0);
|
||||||
#endif
|
#endif
|
||||||
@@ -563,7 +568,7 @@ void Renderer::DrawSigns()
|
|||||||
}
|
}
|
||||||
#ifdef OGLR
|
#ifdef OGLR
|
||||||
glTranslated(0, -MENUSIZE, 0);
|
glTranslated(0, -MENUSIZE, 0);
|
||||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, prevFbo);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -746,10 +751,11 @@ void Renderer::render_parts()
|
|||||||
int cflatV = 0, cflatC = 0, cflat = 0;
|
int cflatV = 0, cflatC = 0, cflat = 0;
|
||||||
int caddV = 0, caddC = 0, cadd = 0;
|
int caddV = 0, caddC = 0, cadd = 0;
|
||||||
int clineV = 0, clineC = 0, cline = 0;
|
int clineV = 0, clineC = 0, cline = 0;
|
||||||
GLint origBlendSrc, origBlendDst;
|
GLint origBlendSrc, origBlendDst, prevFbo;
|
||||||
|
|
||||||
glGetIntegerv(GL_BLEND_SRC, &origBlendSrc);
|
glGetIntegerv(GL_BLEND_SRC, &origBlendSrc);
|
||||||
glGetIntegerv(GL_BLEND_DST, &origBlendDst);
|
glGetIntegerv(GL_BLEND_DST, &origBlendDst);
|
||||||
|
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &prevFbo);
|
||||||
//Render to the particle FBO
|
//Render to the particle FBO
|
||||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, partsFbo);
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, partsFbo);
|
||||||
glTranslated(0, MENUSIZE, 0);
|
glTranslated(0, MENUSIZE, 0);
|
||||||
@@ -1659,7 +1665,7 @@ void Renderer::render_parts()
|
|||||||
|
|
||||||
//Reset FBO
|
//Reset FBO
|
||||||
glTranslated(0, -MENUSIZE, 0);
|
glTranslated(0, -MENUSIZE, 0);
|
||||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, prevFbo);
|
||||||
|
|
||||||
glBlendFunc(origBlendSrc, origBlendDst);
|
glBlendFunc(origBlendSrc, origBlendDst);
|
||||||
#endif
|
#endif
|
||||||
@@ -1676,6 +1682,8 @@ void Renderer::draw_other() // EMP effect
|
|||||||
if (emp_decor>0)
|
if (emp_decor>0)
|
||||||
{
|
{
|
||||||
#ifdef OGLR
|
#ifdef OGLR
|
||||||
|
GLint prevFbo;
|
||||||
|
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &prevFbo);
|
||||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, partsFbo);
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, partsFbo);
|
||||||
glTranslated(0, MENUSIZE, 0);
|
glTranslated(0, MENUSIZE, 0);
|
||||||
float femp_decor = ((float)emp_decor)/255.0f;
|
float femp_decor = ((float)emp_decor)/255.0f;
|
||||||
@@ -1693,7 +1701,7 @@ void Renderer::draw_other() // EMP effect
|
|||||||
glVertex2f(0, YRES+MENUSIZE);
|
glVertex2f(0, YRES+MENUSIZE);
|
||||||
glEnd();
|
glEnd();
|
||||||
glTranslated(0, -MENUSIZE, 0);
|
glTranslated(0, -MENUSIZE, 0);
|
||||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, prevFbo);
|
||||||
#else
|
#else
|
||||||
int r=emp_decor*2.5, g=100+emp_decor*1.5, b=255;
|
int r=emp_decor*2.5, g=100+emp_decor*1.5, b=255;
|
||||||
int a=(1.0*emp_decor/110)*255;
|
int a=(1.0*emp_decor/110)*255;
|
||||||
@@ -1810,6 +1818,7 @@ void Renderer::draw_air()
|
|||||||
#else
|
#else
|
||||||
int sdl_scale = 1;
|
int sdl_scale = 1;
|
||||||
GLuint airProg;
|
GLuint airProg;
|
||||||
|
GLint prevFbo;
|
||||||
if(display_mode & DISPLAY_AIRC)
|
if(display_mode & DISPLAY_AIRC)
|
||||||
{
|
{
|
||||||
airProg = airProg_Cracker;
|
airProg = airProg_Cracker;
|
||||||
@@ -1828,6 +1837,7 @@ void Renderer::draw_air()
|
|||||||
}
|
}
|
||||||
|
|
||||||
glEnable( GL_TEXTURE_2D );
|
glEnable( GL_TEXTURE_2D );
|
||||||
|
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &prevFbo);
|
||||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, partsFbo);
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, partsFbo);
|
||||||
glTranslated(0, MENUSIZE, 0);
|
glTranslated(0, MENUSIZE, 0);
|
||||||
|
|
||||||
@@ -1862,7 +1872,7 @@ void Renderer::draw_air()
|
|||||||
glUseProgram(0);
|
glUseProgram(0);
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
glTranslated(0, -MENUSIZE, 0);
|
glTranslated(0, -MENUSIZE, 0);
|
||||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, prevFbo);
|
||||||
glDisable( GL_TEXTURE_2D );
|
glDisable( GL_TEXTURE_2D );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user