mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-11-27 14:37:16 +00:00
more changes to make it work on iOS
This commit is contained in:
parent
90d477d3dc
commit
d01d772669
@ -255,20 +255,28 @@ void stereo::set_viewport(int ed) {
|
|||||||
|
|
||||||
void setGLProjection(int col) {
|
void setGLProjection(int col) {
|
||||||
DEBB(DF_GRAPH, (debugfile,"setGLProjection\n"));
|
DEBB(DF_GRAPH, (debugfile,"setGLProjection\n"));
|
||||||
|
GLERR("pre_setGLProjection");
|
||||||
|
|
||||||
unsigned char *c = (unsigned char*) (&col);
|
unsigned char *c = (unsigned char*) (&col);
|
||||||
glClearColor(c[2] / 255.0, c[1] / 255.0, c[0]/255.0, 1);
|
glClearColor(c[2] / 255.0, c[1] / 255.0, c[0]/255.0, 1);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
|
GLERR("setGLProjection #1");
|
||||||
|
|
||||||
|
#ifndef GLES_ONLY
|
||||||
glEnable(GL_BLEND);
|
glEnable(GL_BLEND);
|
||||||
if(vid.antialias & AA_LINES) {
|
if(vid.antialias & AA_LINES) {
|
||||||
glEnable(GL_LINE_SMOOTH);
|
glEnable(GL_LINE_SMOOTH);
|
||||||
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
|
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
|
||||||
}
|
}
|
||||||
else glDisable(GL_LINE_SMOOTH);
|
else glDisable(GL_LINE_SMOOTH);
|
||||||
|
#endif
|
||||||
|
|
||||||
glLineWidth(vid.linewidth);
|
glLineWidth(vid.linewidth);
|
||||||
|
|
||||||
#if !ISMOBILE
|
GLERR("setGLProjection #2");
|
||||||
|
|
||||||
|
#ifndef GLES_ONLY
|
||||||
if(vid.antialias & AA_POLY) {
|
if(vid.antialias & AA_POLY) {
|
||||||
glEnable(GL_POLYGON_SMOOTH);
|
glEnable(GL_POLYGON_SMOOTH);
|
||||||
glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
|
glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
|
||||||
@ -276,6 +284,8 @@ void setGLProjection(int col) {
|
|||||||
else glDisable(GL_POLYGON_SMOOTH);
|
else glDisable(GL_POLYGON_SMOOTH);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
GLERR("setGLProjection #3");
|
||||||
|
|
||||||
//glLineWidth(1.0f);
|
//glLineWidth(1.0f);
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
@ -291,7 +301,10 @@ void setGLProjection(int col) {
|
|||||||
else
|
else
|
||||||
glDisable(GL_DEPTH_TEST);
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
|
GLERR("setGLProjection");
|
||||||
|
|
||||||
stereo::set_projection(0);
|
stereo::set_projection(0);
|
||||||
|
GLERR("after set_projection");
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int next_p2 (int a )
|
inline int next_p2 (int a )
|
||||||
@ -945,6 +958,8 @@ hookset<void(renderbuffer*)> *hooks_hqshot;
|
|||||||
#if CAP_SDL
|
#if CAP_SDL
|
||||||
void saveHighQualityShot(const char *fname, const char *caption, int fade) {
|
void saveHighQualityShot(const char *fname, const char *caption, int fade) {
|
||||||
|
|
||||||
|
resetbuffer rb;
|
||||||
|
|
||||||
int maxrange = getDistLimit() * 3/2;
|
int maxrange = getDistLimit() * 3/2;
|
||||||
|
|
||||||
dynamicval<int> v3(sightrange, (cheater && sightrange < maxrange) ? maxrange : sightrange);
|
dynamicval<int> v3(sightrange, (cheater && sightrange < maxrange) ? maxrange : sightrange);
|
||||||
@ -1014,7 +1029,7 @@ void saveHighQualityShot(const char *fname, const char *caption, int fade) {
|
|||||||
if(i == 0) addMessage(XLAT("Saved the high quality shot to %1", fname));
|
if(i == 0) addMessage(XLAT("Saved the high quality shot to %1", fname));
|
||||||
}
|
}
|
||||||
|
|
||||||
glbuf.disable();
|
rb.reset();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
9
hyper.h
9
hyper.h
@ -2552,10 +2552,16 @@ struct renderbuffer {
|
|||||||
renderbuffer(int x, int y, bool gl);
|
renderbuffer(int x, int y, bool gl);
|
||||||
~renderbuffer();
|
~renderbuffer();
|
||||||
void enable();
|
void enable();
|
||||||
void disable();
|
|
||||||
void clear(int col);
|
void clear(int col);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct resetbuffer {
|
||||||
|
GLint drawFboId, readFboId;
|
||||||
|
SDL_Surface *sreset;
|
||||||
|
resetbuffer();
|
||||||
|
void reset();
|
||||||
|
};
|
||||||
|
|
||||||
namespace stereo {
|
namespace stereo {
|
||||||
enum eStereo { sOFF, sAnaglyph, sLR, sODS };
|
enum eStereo { sOFF, sAnaglyph, sLR, sODS };
|
||||||
|
|
||||||
@ -2661,3 +2667,4 @@ extern void popGame();
|
|||||||
string helptitle(string s, int col);
|
string helptitle(string s, int col);
|
||||||
pair<int, int> cell_to_pair(cell *c);
|
pair<int, int> cell_to_pair(cell *c);
|
||||||
extern bool nohud, nofps;
|
extern bool nohud, nofps;
|
||||||
|
|
||||||
|
10
init.cpp
10
init.cpp
@ -645,6 +645,8 @@ int getticks();
|
|||||||
void shareScore(MOBPAR_FORMAL);
|
void shareScore(MOBPAR_FORMAL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int mobile_xres, mobile_yres;
|
||||||
|
|
||||||
void mobile_draw(MOBPAR_FORMAL) {
|
void mobile_draw(MOBPAR_FORMAL) {
|
||||||
|
|
||||||
optimizeview();
|
optimizeview();
|
||||||
@ -697,7 +699,13 @@ void mobile_draw(MOBPAR_FORMAL) {
|
|||||||
lmouseover = mousedest.d >= 0 ? cwt.c->mov[(cwt.spin + mousedest.d) % cwt.c->type] : cwt.c;
|
lmouseover = mousedest.d >= 0 ? cwt.c->mov[(cwt.spin + mousedest.d) % cwt.c->type] : cwt.c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mouseh = gethyper(mousex, mousey);
|
|
||||||
|
#if CAP_RUG
|
||||||
|
if(rug::rugged)
|
||||||
|
mouseh = rug::gethyper(mousex, mousey);
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
mouseh = gethyper(mousex, mousey);
|
||||||
|
|
||||||
// if(debfile) fprintf(debfile, "d1\n"), fflush(debfile);
|
// if(debfile) fprintf(debfile, "d1\n"), fflush(debfile);
|
||||||
frames++;
|
frames++;
|
||||||
|
@ -43,38 +43,52 @@ renderbuffer::renderbuffer(int x, int y, bool gl) : x(x), y(y) {
|
|||||||
|
|
||||||
# if CAP_GL
|
# if CAP_GL
|
||||||
if(gl) {
|
if(gl) {
|
||||||
|
resetbuffer rb;
|
||||||
tx = next_p2(x);
|
tx = next_p2(x);
|
||||||
ty = next_p2(y);
|
ty = next_p2(y);
|
||||||
|
|
||||||
FramebufferName = renderedTexture = depth_stencil_rb = 0;
|
FramebufferName = renderedTexture = depth_stencil_rb = 0;
|
||||||
|
GLERR("even before");
|
||||||
glGenFramebuffers(1, &FramebufferName); //
|
glGenFramebuffers(1, &FramebufferName); //
|
||||||
|
GLERR("GenFramebuffer");
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, FramebufferName);
|
glBindFramebuffer(GL_FRAMEBUFFER, FramebufferName);
|
||||||
|
GLERR("BindFramebuffer");
|
||||||
|
|
||||||
glGenTextures(1, &renderedTexture);
|
glGenTextures(1, &renderedTexture);
|
||||||
glBindTexture(GL_TEXTURE_2D, renderedTexture);
|
glBindTexture(GL_TEXTURE_2D, renderedTexture);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0,GL_RGB, tx, ty, 0,GL_RGB, GL_UNSIGNED_BYTE, 0);
|
glTexImage2D(GL_TEXTURE_2D, 0,GL_RGB, tx, ty, 0,GL_RGB, GL_UNSIGNED_BYTE, 0);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
|
GLERR("GenTextures");
|
||||||
|
|
||||||
#ifdef TEX
|
#ifdef TEX
|
||||||
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, renderedTexture, 0);
|
glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, renderedTexture, 0);
|
||||||
#else
|
#else
|
||||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, renderedTexture, 0);
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, renderedTexture, 0);
|
||||||
#endif
|
#endif
|
||||||
|
GLERR("FramebufferTexture");
|
||||||
// GLenum DrawBuffers[1] = {GL_COLOR_ATTACHMENT0};
|
// GLenum DrawBuffers[1] = {GL_COLOR_ATTACHMENT0};
|
||||||
// glDrawBuffers(1, DrawBuffers);
|
// glDrawBuffers(1, DrawBuffers);
|
||||||
|
|
||||||
glGenRenderbuffers(1, &depth_stencil_rb);
|
glGenRenderbuffers(1, &depth_stencil_rb);
|
||||||
|
GLERR("GenRenderbuffer");
|
||||||
glBindRenderbuffer(GL_RENDERBUFFER, depth_stencil_rb);
|
glBindRenderbuffer(GL_RENDERBUFFER, depth_stencil_rb);
|
||||||
|
GLERR("BindRenderbuffer");
|
||||||
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, tx, ty);
|
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, tx, ty);
|
||||||
|
GLERR("RbS");
|
||||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depth_stencil_rb);
|
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depth_stencil_rb);
|
||||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, depth_stencil_rb);
|
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, depth_stencil_rb);
|
||||||
|
GLERR("FrRb");
|
||||||
|
|
||||||
if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
|
if(glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
|
||||||
FramebufferName = renderedTexture = 0;
|
FramebufferName = renderedTexture = 0;
|
||||||
else
|
else
|
||||||
valid = true;
|
valid = true;
|
||||||
|
|
||||||
|
printf("Framebuffer remains = %d (%d)\n", FramebufferName, valid);
|
||||||
GLERR("initialization");
|
GLERR("initialization");
|
||||||
|
|
||||||
|
rb.reset();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -94,6 +108,7 @@ SDL_Surface *renderbuffer::render() {
|
|||||||
make_surface() ;
|
make_surface() ;
|
||||||
if(FramebufferName) {
|
if(FramebufferName) {
|
||||||
glReadPixels(0, 0, vid.xres, vid.yres, GL_BGRA, GL_UNSIGNED_BYTE, srf->pixels);
|
glReadPixels(0, 0, vid.xres, vid.yres, GL_BGRA, GL_UNSIGNED_BYTE, srf->pixels);
|
||||||
|
GLERR("readPixels");
|
||||||
for(int y=0; y<vid.yres/2; y++)
|
for(int y=0; y<vid.yres/2; y++)
|
||||||
for(int x=0; x<vid.xres; x++)
|
for(int x=0; x<vid.xres; x++)
|
||||||
swap(qpixel(srf,x,y), qpixel(srf,x,vid.yres-1-y));
|
swap(qpixel(srf,x,y), qpixel(srf,x,vid.yres-1-y));
|
||||||
@ -105,8 +120,9 @@ SDL_Surface *renderbuffer::render() {
|
|||||||
void renderbuffer::enable() {
|
void renderbuffer::enable() {
|
||||||
#if CAP_GL
|
#if CAP_GL
|
||||||
if(FramebufferName) {
|
if(FramebufferName) {
|
||||||
|
GLERR("prebind");
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, FramebufferName);
|
glBindFramebuffer(GL_FRAMEBUFFER, FramebufferName);
|
||||||
glViewport(0,0,x,y);
|
GLERR("bind");
|
||||||
vid.usingGL = true;
|
vid.usingGL = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -118,21 +134,6 @@ void renderbuffer::enable() {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void renderbuffer::disable() {
|
|
||||||
#if CAP_GL
|
|
||||||
if(FramebufferName) {
|
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
|
||||||
#if CAP_SDL
|
|
||||||
glViewport(0,0,s_screen->w,s_screen->h);
|
|
||||||
#endif
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#if CAP_SDL
|
|
||||||
s = s_screen;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#if CAP_GL
|
#if CAP_GL
|
||||||
void renderbuffer::use_as_texture() {
|
void renderbuffer::use_as_texture() {
|
||||||
if(!renderedTexture) {
|
if(!renderedTexture) {
|
||||||
@ -185,3 +186,24 @@ void renderbuffer::clear(int col) {
|
|||||||
SDL_FillRect(srf, NULL, col);
|
SDL_FillRect(srf, NULL, col);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resetbuffer::resetbuffer() {
|
||||||
|
#if CAP_GL
|
||||||
|
drawFboId = 0, readFboId = 0;
|
||||||
|
glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &drawFboId);
|
||||||
|
glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &readFboId);
|
||||||
|
#endif
|
||||||
|
#if CAP_SDL
|
||||||
|
sreset = s;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void resetbuffer::reset() {
|
||||||
|
#if CAP_GL
|
||||||
|
glBindFramebuffer(GL_FRAMEBUFFER, drawFboId);
|
||||||
|
#endif
|
||||||
|
#if CAP_SDL
|
||||||
|
s = sreset;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
13
rug.cpp
13
rug.cpp
@ -1090,13 +1090,17 @@ void drawTriangle(triangle& t) {
|
|||||||
renderbuffer *glbuf;
|
renderbuffer *glbuf;
|
||||||
|
|
||||||
void prepareTexture() {
|
void prepareTexture() {
|
||||||
|
resetbuffer rb;
|
||||||
|
|
||||||
videopar svid = vid;
|
videopar svid = vid;
|
||||||
|
|
||||||
setVidParam();
|
setVidParam();
|
||||||
dynamicval<stereo::eStereo> d(stereo::mode, stereo::sOFF);
|
dynamicval<stereo::eStereo> d(stereo::mode, stereo::sOFF);
|
||||||
|
|
||||||
glbuf->enable();
|
glbuf->enable();
|
||||||
|
stereo::set_viewport(0);
|
||||||
|
stereo::set_projection(0);
|
||||||
|
stereo::set_mask(0);
|
||||||
glbuf->clear(0);
|
glbuf->clear(0);
|
||||||
|
|
||||||
ptds.clear();
|
ptds.clear();
|
||||||
@ -1113,7 +1117,7 @@ void prepareTexture() {
|
|||||||
}
|
}
|
||||||
drawqueue();
|
drawqueue();
|
||||||
vid = svid;
|
vid = svid;
|
||||||
glbuf->disable();
|
rb.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
double xview, yview;
|
double xview, yview;
|
||||||
@ -1219,6 +1223,7 @@ transmatrix currentrot;
|
|||||||
void init() {
|
void init() {
|
||||||
if(rugged) return;
|
if(rugged) return;
|
||||||
when_enabled = ticks;
|
when_enabled = ticks;
|
||||||
|
GLERR("before init");
|
||||||
glbuf = new renderbuffer(TEXTURESIZE, TEXTURESIZE, vid.usingGL && !rendernogl);
|
glbuf = new renderbuffer(TEXTURESIZE, TEXTURESIZE, vid.usingGL && !rendernogl);
|
||||||
if(!glbuf->valid) {
|
if(!glbuf->valid) {
|
||||||
addMessage(XLAT("Failed to enable"));
|
addMessage(XLAT("Failed to enable"));
|
||||||
@ -1341,7 +1346,9 @@ transmatrix last_orientation;
|
|||||||
|
|
||||||
void actDraw() {
|
void actDraw() {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
if(!renderonce) prepareTexture();
|
if(!renderonce) prepareTexture();
|
||||||
|
stereo::set_viewport(0);
|
||||||
physics();
|
physics();
|
||||||
drawRugScene();
|
drawRugScene();
|
||||||
|
|
||||||
@ -1512,7 +1519,7 @@ hyperpoint gethyper(ld x, ld y) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void show() {
|
void show() {
|
||||||
cmode = sm::SIDE | sm::MAYDARK;
|
cmode = sm::SIDE;
|
||||||
gamescreen(0);
|
gamescreen(0);
|
||||||
dialog::init(XLAT("hypersian rug mode"), iinf[itPalace].color, 150, 100);
|
dialog::init(XLAT("hypersian rug mode"), iinf[itPalace].color, 150, 100);
|
||||||
|
|
||||||
|
51
shaders.cpp
51
shaders.cpp
@ -2,7 +2,7 @@
|
|||||||
// If CAP_SHADER is 0, OpenGL 1.0 is used.
|
// If CAP_SHADER is 0, OpenGL 1.0 is used.
|
||||||
// If CAP_SHADER is 1, GLSL is used.
|
// If CAP_SHADER is 1, GLSL is used.
|
||||||
|
|
||||||
#define DEBUG_GL 0
|
#define DEBUG_GL 1
|
||||||
|
|
||||||
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
|
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
|
||||||
|
|
||||||
@ -202,6 +202,14 @@ struct GLprogram {
|
|||||||
|
|
||||||
GLprogram(string vsh, string fsh) {
|
GLprogram(string vsh, string fsh) {
|
||||||
_program = glCreateProgram();
|
_program = glCreateProgram();
|
||||||
|
|
||||||
|
#ifndef GLES_ONLY
|
||||||
|
while(vsh.find("mediump ") != string::npos)
|
||||||
|
vsh.replace(vsh.find("mediump "), 7, "");
|
||||||
|
while(fsh.find("mediump ") != string::npos)
|
||||||
|
fsh.replace(fsh.find("mediump "), 7, "");
|
||||||
|
#endif
|
||||||
|
|
||||||
// printf("creating program %d\n", _program);
|
// printf("creating program %d\n", _program);
|
||||||
vertShader = compileShader(GL_VERTEX_SHADER, vsh.c_str());
|
vertShader = compileShader(GL_VERTEX_SHADER, vsh.c_str());
|
||||||
fragShader = compileShader(GL_FRAGMENT_SHADER, fsh.c_str());
|
fragShader = compileShader(GL_FRAGMENT_SHADER, fsh.c_str());
|
||||||
@ -336,39 +344,52 @@ void be_textured() { switch_mode(gmTextured); }
|
|||||||
|
|
||||||
void switch_mode(eMode m) {
|
void switch_mode(eMode m) {
|
||||||
if(m == mode) return;
|
if(m == mode) return;
|
||||||
|
GLERR("pre_switch_mode");
|
||||||
#if CAP_SHADER
|
#if CAP_SHADER
|
||||||
programs[m]->enable();
|
programs[m]->enable();
|
||||||
|
GLERR("after_enable");
|
||||||
#endif
|
#endif
|
||||||
flagtype newflags = flags[m] &~ flags[mode];
|
flagtype newflags = flags[m] &~ flags[mode];
|
||||||
flagtype oldflags = flags[mode] &~ flags[m];
|
flagtype oldflags = flags[mode] &~ flags[m];
|
||||||
if(newflags & GF_TEXTURE) {
|
if(newflags & GF_TEXTURE) {
|
||||||
glEnable(GL_TEXTURE_2D);
|
GLERR("xsm");
|
||||||
#if CAP_SHADER
|
#if CAP_SHADER
|
||||||
glEnableVertexAttribArray(aTexture);
|
glEnableVertexAttribArray(aTexture);
|
||||||
|
GLERR("xsm");
|
||||||
#else
|
#else
|
||||||
|
glEnable(GL_TEXTURE_2D);
|
||||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
|
GLERR("xsm");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if(oldflags & GF_TEXTURE) {
|
if(oldflags & GF_TEXTURE) {
|
||||||
glDisable(GL_TEXTURE_2D);
|
GLERR("xsm");
|
||||||
#if CAP_SHADER
|
#if CAP_SHADER
|
||||||
glDisableVertexAttribArray(aTexture);
|
glDisableVertexAttribArray(aTexture);
|
||||||
|
GLERR("xsm");
|
||||||
#else
|
#else
|
||||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
|
glDisable(GL_TEXTURE_2D);
|
||||||
|
GLERR("xsm");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if(newflags & GF_VARCOLOR) {
|
if(newflags & GF_VARCOLOR) {
|
||||||
#if CAP_SHADER
|
#if CAP_SHADER
|
||||||
|
GLERR("xsm");
|
||||||
glEnableVertexAttribArray(aColor);
|
glEnableVertexAttribArray(aColor);
|
||||||
#else
|
#else
|
||||||
|
GLERR("xsm");
|
||||||
glEnableClientState(GL_COLOR_ARRAY);
|
glEnableClientState(GL_COLOR_ARRAY);
|
||||||
|
GLERR("xsm");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if(oldflags & GF_VARCOLOR) {
|
if(oldflags & GF_VARCOLOR) {
|
||||||
#if CAP_SHADER
|
#if CAP_SHADER
|
||||||
glDisableVertexAttribArray(aColor);
|
glDisableVertexAttribArray(aColor);
|
||||||
|
GLERR("xsm");
|
||||||
#else
|
#else
|
||||||
glDisableClientState(GL_COLOR_ARRAY);
|
glDisableClientState(GL_COLOR_ARRAY);
|
||||||
|
GLERR("xsm");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if(newflags & GF_LIGHTFOG) {
|
if(newflags & GF_LIGHTFOG) {
|
||||||
@ -399,6 +420,7 @@ void switch_mode(eMode m) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
mode = m;
|
mode = m;
|
||||||
|
GLERR("after_switch_mode");
|
||||||
}
|
}
|
||||||
|
|
||||||
void fog_max(ld fogmax) {
|
void fog_max(ld fogmax) {
|
||||||
@ -434,17 +456,18 @@ void init() {
|
|||||||
bool varcol = f & GF_VARCOLOR;
|
bool varcol = f & GF_VARCOLOR;
|
||||||
|
|
||||||
programs[i] = new GLprogram(stringbuilder(
|
programs[i] = new GLprogram(stringbuilder(
|
||||||
1, "attribute vec4 aPosition;",
|
|
||||||
texture, "attribute vec2 aTexture;",
|
1, "attribute mediump vec4 aPosition;",
|
||||||
varcol, "attribute vec4 aColor;",
|
texture, "attribute mediump vec2 aTexture;",
|
||||||
|
varcol, "attribute mediump vec4 aColor;",
|
||||||
// "attribute vec3 normal;"
|
// "attribute vec3 normal;"
|
||||||
|
|
||||||
1, "varying vec4 vColor;",
|
1, "varying mediump vec4 vColor;",
|
||||||
texture, "varying vec2 vTexCoord;",
|
texture, "varying mediump vec2 vTexCoord;",
|
||||||
|
|
||||||
1, "uniform mat4 uMVP;",
|
1, "uniform mediump mat4 uMVP;",
|
||||||
1, "uniform float uFog;",
|
1, "uniform mediump float uFog;",
|
||||||
!varcol, "uniform vec4 uColor;",
|
!varcol, "uniform mediump vec4 uColor;",
|
||||||
|
|
||||||
1, "void main() {",
|
1, "void main() {",
|
||||||
texture, "vTexCoord = aTexture;",
|
texture, "vTexCoord = aTexture;",
|
||||||
@ -456,9 +479,9 @@ void init() {
|
|||||||
|
|
||||||
stringbuilder(
|
stringbuilder(
|
||||||
|
|
||||||
1, "uniform sampler2D tTexture;",
|
1, "uniform mediump sampler2D tTexture;",
|
||||||
1, "varying vec4 vColor;",
|
1, "varying mediump vec4 vColor;",
|
||||||
texture, "varying vec2 vTexCoord;",
|
texture, "varying mediump vec2 vTexCoord;",
|
||||||
1, "void main() {",
|
1, "void main() {",
|
||||||
texture, "gl_FragColor = vColor * texture2D(tTexture, vTexCoord);",
|
texture, "gl_FragColor = vColor * texture2D(tTexture, vTexCoord);",
|
||||||
!texture, "gl_FragColor = vColor;",
|
!texture, "gl_FragColor = vColor;",
|
||||||
|
Loading…
Reference in New Issue
Block a user