made stage shader rules take a pointer to the FBO instead of an index

This commit is contained in:
Andrei "Akari" Alexeyev 2017-04-16 00:19:30 +03:00
parent e9a32b6436
commit 82c9b733fa
6 changed files with 20 additions and 19 deletions

View file

@ -13,6 +13,7 @@
#include "boss.h"
#include "progress.h"
#include "difficulty.h"
#include "fbo.h"
/* taisei's strange macro language.
*
@ -47,7 +48,7 @@
#define GO_TO(obj, p, f) (obj)->pos += (f)*((p) - (obj)->pos);
typedef void (*StageProc)(void);
typedef void (*ShaderRule)(int);
typedef void (*ShaderRule)(FBO*);
// two highest bits of uint16_t, WAY higher than the amount of spells in this game can ever possibly be
#define STAGE_SPELL_BIT 0x8000

View file

@ -13,7 +13,7 @@
static int apply_shaderrules(ShaderRule *shaderrules, int fbonum) {
for(ShaderRule *rule = shaderrules; *rule; ++rule) {
glBindFramebuffer(GL_FRAMEBUFFER, resources.fbo.bg[!fbonum].fbo);
(*rule)(fbonum);
(*rule)(resources.fbo.bg + fbonum);
fbonum = !fbonum;
}

View file

@ -102,7 +102,7 @@ Vector **stage1_smoke_pos(Vector p, float maxrange) {
return linear3dpos(p, maxrange/2.0, q, r);
}
void stage1_fog(int fbonum) {
void stage1_fog(FBO *fbo) {
Shader *shader = get_shader("zbuf_fog");
glUseProgram(shader->prog);
@ -114,10 +114,10 @@ void stage1_fog(int fbonum) {
glUniform1f(uniloc(shader, "exponent"), 3.0);
glUniform1f(uniloc(shader, "sphereness"), 0.2);
glActiveTexture(GL_TEXTURE0 + 1);
glBindTexture(GL_TEXTURE_2D, resources.fbo.bg[fbonum].depth);
glBindTexture(GL_TEXTURE_2D, fbo->depth);
glActiveTexture(GL_TEXTURE0);
draw_fbo_viewport(&resources.fbo.bg[fbonum]);
draw_fbo_viewport(fbo);
glUseProgram(0);
}

View file

@ -131,7 +131,7 @@ Vector **stage2_bg_grass_pos2(Vector pos, float maxrange) {
return linear3dpos(pos, maxrange, p, r);
}
static void stage2_fog(int fbonum) {
static void stage2_fog(FBO *fbo) {
Shader *shader = get_shader("zbuf_fog");
glUseProgram(shader->prog);
@ -142,21 +142,21 @@ static void stage2_fog(int fbonum) {
glUniform1f(uniloc(shader, "exponent"),3.0);
glUniform1f(uniloc(shader, "sphereness"),0);
glActiveTexture(GL_TEXTURE0 + 2);
glBindTexture(GL_TEXTURE_2D, resources.fbo.bg[fbonum].depth);
glBindTexture(GL_TEXTURE_2D, fbo->depth);
glActiveTexture(GL_TEXTURE0);
draw_fbo_viewport(&resources.fbo.bg[fbonum]);
draw_fbo_viewport(fbo);
glUseProgram(0);
}
static void stage2_bloom(int fbonum) {
static void stage2_bloom(FBO *fbo) {
Shader *shader = get_shader("bloom");
glUseProgram(shader->prog);
glUniform1i(uniloc(shader, "samples"), 10);
glUniform1f(uniloc(shader, "intensity"), 0.05);
glUniform1f(uniloc(shader, "radius"), 0.03);
draw_fbo_viewport(&resources.fbo.bg[fbonum]);
draw_fbo_viewport(fbo);
glUseProgram(0);
}

View file

@ -64,21 +64,21 @@ void stage3_bg_tunnel_draw(Vector pos) {
glDisable(GL_TEXTURE_2D);
}
void stage3_tunnel(int fbonum) {
void stage3_tunnel(FBO *fbo) {
Shader *shader = get_shader("tunnel");
glColor4f(1,1,1,1);
glUseProgram(shader->prog);
glUniform3f(uniloc(shader, "color"),stgstate.clr_r,stgstate.clr_g,stgstate.clr_b);
glActiveTexture(GL_TEXTURE0 + 2);
glBindTexture(GL_TEXTURE_2D, resources.fbo.bg[fbonum].depth);
glBindTexture(GL_TEXTURE_2D, fbo->depth);
glActiveTexture(GL_TEXTURE0);
draw_fbo_viewport(&resources.fbo.bg[fbonum]);
draw_fbo_viewport(fbo);
glUseProgram(0);
}
void stage3_fog(int fbonum) {
void stage3_fog(FBO *fbo) {
Shader *shader = get_shader("zbuf_fog");
glColor4f(1,1,1,1);
@ -90,10 +90,10 @@ void stage3_fog(int fbonum) {
glUniform1f(uniloc(shader, "exponent"), stgstate.fog_exp/2);
glUniform1f(uniloc(shader, "sphereness"),0);
glActiveTexture(GL_TEXTURE0 + 2);
glBindTexture(GL_TEXTURE_2D, resources.fbo.bg[fbonum].depth);
glBindTexture(GL_TEXTURE_2D, fbo->depth);
glActiveTexture(GL_TEXTURE0);
draw_fbo_viewport(&resources.fbo.bg[fbonum]);
draw_fbo_viewport(fbo);
glUseProgram(0);
}

View file

@ -13,7 +13,7 @@
static Stage3D bgcontext;
void stage4_fog(int fbonum) {
void stage4_fog(FBO *fbo) {
Shader *shader = get_shader("zbuf_fog");
float f = 0;
@ -30,10 +30,10 @@ void stage4_fog(int fbonum) {
glUniform1f(uniloc(shader, "exponent"),4.0);
glUniform1f(uniloc(shader, "sphereness"),0);
glActiveTexture(GL_TEXTURE0 + 2);
glBindTexture(GL_TEXTURE_2D, resources.fbo.bg[fbonum].depth);
glBindTexture(GL_TEXTURE_2D, fbo->depth);
glActiveTexture(GL_TEXTURE0);
draw_fbo_viewport(&resources.fbo.bg[fbonum]);
draw_fbo_viewport(fbo);
glUseProgram(0);
}