1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-06-29 16:43:22 +00:00

CAP_NOSHADER

This commit is contained in:
Zeno Rogue 2019-07-12 23:16:54 +02:00
parent 2e77224c56
commit 31c99e486f
2 changed files with 27 additions and 15 deletions

View File

@ -21,10 +21,14 @@ void glError(const char* GLcall, const char* file, const int line) {
#define CAP_VERTEXBUFFER (ISWEB) #define CAP_VERTEXBUFFER (ISWEB)
#endif #endif
#if CAP_SHADER #if CAP_SHADER && CAP_NOSHADER
#define WITHSHADER(x, y) if(noshaders) y else x #define WITHSHADER(x, y) if(noshaders) y else x
#else #else
#define WITHSHADER(x, y) y #if CAP_NOSHADER
#define WITHSHADER(x, y) if(1) y
#else
#define WITHSHADER(x, y) if(1) x
#endif
#endif #endif
namespace glhr { namespace glhr {
@ -147,7 +151,7 @@ void new_projection() {
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadIdentity(); glLoadIdentity();
return; return;
}); })
} }
void projection_multiply(const glmatrix& m) { void projection_multiply(const glmatrix& m) {
@ -156,7 +160,7 @@ void projection_multiply(const glmatrix& m) {
}, { }, {
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glMultMatrixf(m.as_array()); glMultMatrixf(m.as_array());
}); })
} }
void init(); void init();
@ -312,11 +316,13 @@ bool operator != (const glmatrix& m1, const glmatrix& m2) {
bool uses_mvp(shader_projection sp) { return among(sp, shader_projection::standard, shader_projection::flatten); } bool uses_mvp(shader_projection sp) { return among(sp, shader_projection::standard, shader_projection::flatten); }
void set_modelview(const glmatrix& modelview) { void set_modelview(const glmatrix& modelview) {
#if CAP_NOSHADER
if(noshaders) { if(noshaders) {
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glLoadMatrixf(modelview.as_array()); glLoadMatrixf(modelview.as_array());
return; return;
} }
#endif
if(!current) return; if(!current) return;
if(!uses_mvp(current_shader_projection)) { if(!uses_mvp(current_shader_projection)) {
if(modelview != current_modelview) { if(modelview != current_modelview) {
@ -341,11 +347,13 @@ void set_modelview(const glmatrix& modelview) {
} }
void id_modelview() { void id_modelview() {
#if CAP_NOSHADER
if(noshaders) { if(noshaders) {
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); glLoadIdentity();
return; return;
} }
#endif
if(!current) return; if(!current) return;
if(!uses_mvp(current_shader_projection)) { set_modelview(id); return; } if(!uses_mvp(current_shader_projection)) { set_modelview(id); return; }
#if MINIMIZE_GL_CALLS #if MINIMIZE_GL_CALLS
@ -407,7 +415,7 @@ void switch_mode(eMode m, shader_projection sp) {
glDisableClientState(GL_TEXTURE_COORD_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisable(GL_TEXTURE_2D); glDisable(GL_TEXTURE_2D);
GLERR("xsm"); GLERR("xsm");
}); })
} }
if(newflags & GF_VARCOLOR) { if(newflags & GF_VARCOLOR) {
WITHSHADER({ WITHSHADER({
@ -417,7 +425,7 @@ void switch_mode(eMode m, shader_projection sp) {
GLERR("xsm"); GLERR("xsm");
glEnableClientState(GL_COLOR_ARRAY); glEnableClientState(GL_COLOR_ARRAY);
GLERR("xsm"); GLERR("xsm");
}); })
} }
if(oldflags & GF_VARCOLOR) { if(oldflags & GF_VARCOLOR) {
WITHSHADER({ WITHSHADER({
@ -426,7 +434,7 @@ void switch_mode(eMode m, shader_projection sp) {
}, { }, {
glDisableClientState(GL_COLOR_ARRAY); glDisableClientState(GL_COLOR_ARRAY);
GLERR("xsm"); GLERR("xsm");
}); })
} }
if(newflags & GF_LIGHTFOG) { if(newflags & GF_LIGHTFOG) {
WITHSHADER({}, { WITHSHADER({}, {
@ -451,14 +459,14 @@ void switch_mode(eMode m, shader_projection sp) {
glFogi(GL_FOG_MODE, GL_LINEAR); glFogi(GL_FOG_MODE, GL_LINEAR);
#endif #endif
glFogf(GL_FOG_START, 0); glFogf(GL_FOG_START, 0);
}); })
} }
if(oldflags & GF_LIGHTFOG) { if(oldflags & GF_LIGHTFOG) {
WITHSHADER({}, {glDisable(GL_FOG);}); WITHSHADER({}, {glDisable(GL_FOG);})
} }
WITHSHADER({ WITHSHADER({
glUniform1f(current->uFogBase, 1); fogbase = 1; glUniform1f(current->uFogBase, 1); fogbase = 1;
}, {}); }, {})
mode = m; mode = m;
current_shader_projection = sp; current_shader_projection = sp;
GLERR("after_switch_mode"); GLERR("after_switch_mode");
@ -467,7 +475,7 @@ void switch_mode(eMode m, shader_projection sp) {
current_matrix[0][0] = -1e8; // invalid current_matrix[0][0] = -1e8; // invalid
current_modelview[0][0] = -1e8; current_modelview[0][0] = -1e8;
current_projection[0][0] = -1e8; current_projection[0][0] = -1e8;
}, {}); }, {})
id_modelview(); id_modelview();
current_linewidth = -1; current_linewidth = -1;
/* if(current_depthwrite) glDepthMask(GL_TRUE); /* if(current_depthwrite) glDepthMask(GL_TRUE);
@ -485,7 +493,7 @@ void fog_max(ld fogmax, color_t fogcolor) {
glUniform4f(current->uFogColor, cols[0], cols[1], cols[2], cols[3]); glUniform4f(current->uFogColor, cols[0], cols[1], cols[2], cols[3]);
}, { }, {
glFogf(GL_FOG_END, fogmax); glFogf(GL_FOG_END, fogmax);
}); })
} }
void set_fogbase(ld _fogbase) { void set_fogbase(ld _fogbase) {
@ -494,13 +502,13 @@ void set_fogbase(ld _fogbase) {
fogbase = _fogbase; fogbase = _fogbase;
glUniform1f(current->uFogBase, fogbase); glUniform1f(current->uFogBase, fogbase);
} }
}, {}); }, {})
} }
void set_ualpha(ld alpha) { void set_ualpha(ld alpha) {
WITHSHADER({ WITHSHADER({
glUniform1f(current->uAlpha, alpha); glUniform1f(current->uAlpha, alpha);
}, {}); }, {})
} }
void init() { void init() {
@ -768,7 +776,7 @@ void prepare(vector<textured_vertex>& v) {
}, { }, {
glVertexPointer(SHDIM, GL_FLOAT, sizeof(textured_vertex), &v[0].coords); glVertexPointer(SHDIM, GL_FLOAT, sizeof(textured_vertex), &v[0].coords);
glTexCoordPointer(2, GL_FLOAT, sizeof(textured_vertex), &v[0].texture); glTexCoordPointer(2, GL_FLOAT, sizeof(textured_vertex), &v[0].texture);
}); })
#endif #endif
// color2(col); // color2(col);
} }

View File

@ -80,6 +80,10 @@
#define CAP_SHADER CAP_GL #define CAP_SHADER CAP_GL
#endif #endif
#ifndef CAP_NOSHADER
#define CAP_NOSHADER (!ISMOBILE && !ISWEB)
#endif
#ifndef CAP_ANIMATIONS #ifndef CAP_ANIMATIONS
#define CAP_ANIMATIONS (!ISMINI) #define CAP_ANIMATIONS (!ISMINI)
#endif #endif