mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-02-08 23:20:12 +00:00
glhr::id is now a constant; streamlined applymatrix
This commit is contained in:
parent
babb8fbde4
commit
0412ea7b7c
@ -218,6 +218,16 @@ void stereo::set_projection(int ed) {
|
|||||||
stereo::scrdist_text = 0;
|
stereo::scrdist_text = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
||||||
|
if(hyperbolic && vid.alpha > -1) {
|
||||||
|
// Because of the transformation from H3 to the Minkowski hyperboloid,
|
||||||
|
// points with negative Z can be generated in some 3D settings.
|
||||||
|
// This happens for points below the camera, but above the plane.
|
||||||
|
// These points should still be viewed, though, so we disable the
|
||||||
|
// depth clipping
|
||||||
|
glhr::projection_multiply(glhr::scale(1,1,0));
|
||||||
|
}
|
||||||
|
|
||||||
glhr::projection_multiply(glhr::frustum(vid.xres * 1. / vid.yres, 1));
|
glhr::projection_multiply(glhr::frustum(vid.xres * 1. / vid.yres, 1));
|
||||||
|
|
||||||
GLfloat sc = vid.radius / (vid.yres/2.);
|
GLfloat sc = vid.radius / (vid.yres/2.);
|
||||||
@ -893,7 +903,7 @@ void drawCircle(int x, int y, int size, int color) {
|
|||||||
#if CAP_GL
|
#if CAP_GL
|
||||||
if(vid.usingGL) {
|
if(vid.usingGL) {
|
||||||
glhr::be_nontextured();
|
glhr::be_nontextured();
|
||||||
glhr::set_modelview(glhr::id());
|
glhr::id_modelview();
|
||||||
glcoords.clear();
|
glcoords.clear();
|
||||||
glhr::color2(color);
|
glhr::color2(color);
|
||||||
x -= vid.xcenter; y -= vid.ycenter;
|
x -= vid.xcenter; y -= vid.ycenter;
|
||||||
|
@ -2307,7 +2307,7 @@ void drawaura() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
glhr::switch_mode(glhr::gmVarColored);
|
glhr::switch_mode(glhr::gmVarColored);
|
||||||
glhr::set_modelview(glhr::id());
|
glhr::id_modelview();
|
||||||
glhr::prepare(auravertices);
|
glhr::prepare(auravertices);
|
||||||
glDrawArrays(GL_TRIANGLES, 0, size(auravertices));
|
glDrawArrays(GL_TRIANGLES, 0, size(auravertices));
|
||||||
|
|
||||||
|
15
polygons.cpp
15
polygons.cpp
@ -232,15 +232,10 @@ void glapplymatrix(const transmatrix& V) {
|
|||||||
for(int x=0; x<3; x++) mat[id++] = V[x][y];
|
for(int x=0; x<3; x++) mat[id++] = V[x][y];
|
||||||
mat[id++] = 0;
|
mat[id++] = 0;
|
||||||
}
|
}
|
||||||
{for(int x=0; x<3; x++) mat[id++] = 0;} mat[id++] = 1;
|
mat[12] = 0;
|
||||||
|
mat[13] = 0;
|
||||||
mat[14] = GLfloat(vid.alpha);
|
mat[14] = GLfloat(vid.alpha);
|
||||||
|
mat[15] = 1;
|
||||||
if(mat[10] + vid.alpha < 0 && !sphere && !euclid) {
|
|
||||||
for(int i=0; i<3; i++)
|
|
||||||
for(int j=0; j<16; j+=4)
|
|
||||||
mat[j+i] = -mat[j+i];
|
|
||||||
}
|
|
||||||
|
|
||||||
glhr::set_modelview(glhr::as_glmatrix(mat));
|
glhr::set_modelview(glhr::as_glmatrix(mat));
|
||||||
}
|
}
|
||||||
@ -259,7 +254,7 @@ void setmatrix(int useV, const transmatrix& V) {
|
|||||||
glhr::set_modelview(glhr::as_glmatrix(mat));
|
glhr::set_modelview(glhr::as_glmatrix(mat));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
glhr::set_modelview(glhr::id());
|
glhr::id_modelview();
|
||||||
}
|
}
|
||||||
|
|
||||||
void gldraw(int useV, const transmatrix& V, const vector<glvertex>& v, int ps, int pq, int col, int outline, int flags, textureinfo *tinf) {
|
void gldraw(int useV, const transmatrix& V, const vector<glvertex>& v, int ps, int pq, int col, int outline, int flags, textureinfo *tinf) {
|
||||||
@ -304,7 +299,7 @@ void gldraw(int useV, const transmatrix& V, const vector<glvertex>& v, int ps, i
|
|||||||
make_array<GLfloat>(-xx, +yy, stereo::scrdist)
|
make_array<GLfloat>(-xx, +yy, stereo::scrdist)
|
||||||
};
|
};
|
||||||
glhr::vertices(scr);
|
glhr::vertices(scr);
|
||||||
glhr::set_modelview(glhr::id());
|
glhr::id_modelview();
|
||||||
glDrawArrays(tinf ? GL_TRIANGLES : GL_TRIANGLE_FAN, 0, 4);
|
glDrawArrays(tinf ? GL_TRIANGLES : GL_TRIANGLE_FAN, 0, 4);
|
||||||
glhr::vertices(v);
|
glhr::vertices(v);
|
||||||
setmatrix(useV, V);
|
setmatrix(useV, V);
|
||||||
|
2
rug.cpp
2
rug.cpp
@ -1179,7 +1179,7 @@ void drawRugScene() {
|
|||||||
for(int t=0; t<size(triangles); t++)
|
for(int t=0; t<size(triangles); t++)
|
||||||
drawTriangle(triangles[t]);
|
drawTriangle(triangles[t]);
|
||||||
|
|
||||||
glhr::set_modelview(glhr::id());
|
glhr::id_modelview();
|
||||||
glhr::prepare(ct_array);
|
glhr::prepare(ct_array);
|
||||||
glDrawArrays(GL_TRIANGLES, 0, size(ct_array));
|
glDrawArrays(GL_TRIANGLES, 0, size(ct_array));
|
||||||
|
|
||||||
|
21
shaders.cpp
21
shaders.cpp
@ -73,13 +73,7 @@ glmatrix operator * (glmatrix m1, glmatrix m2) {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
glmatrix id() {
|
glmatrix id = {{{1,0,0,0}, {0,1,0,0}, {0,0,1,0}, {0,0,0,1}}};
|
||||||
glmatrix M;
|
|
||||||
for(int i=0; i<4; i++)
|
|
||||||
for(int j=0; j<4; j++)
|
|
||||||
M[i][j] = (i == j);
|
|
||||||
return M;
|
|
||||||
}
|
|
||||||
|
|
||||||
glmatrix scale(ld x, ld y, ld z) {
|
glmatrix scale(ld x, ld y, ld z) {
|
||||||
glmatrix tmp;
|
glmatrix tmp;
|
||||||
@ -141,6 +135,11 @@ void set_modelview(const glmatrix& m) {
|
|||||||
glLoadMatrixf(m.as_array());
|
glLoadMatrixf(m.as_array());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void id_modelview() {
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glLoadIdentity();
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// /* shaders */
|
// /* shaders */
|
||||||
@ -150,7 +149,7 @@ void set_modelview(const glmatrix& m) {
|
|||||||
glmatrix projection;
|
glmatrix projection;
|
||||||
|
|
||||||
void new_projection() {
|
void new_projection() {
|
||||||
projection = id();
|
projection = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void projection_multiply(const glmatrix& m) {
|
void projection_multiply(const glmatrix& m) {
|
||||||
@ -304,6 +303,10 @@ void set_modelview(const glmatrix& modelview) {
|
|||||||
// glUniformMatrix3fv(current->uniforms[UNIFORM_NORMAL_MATRIX], 1, 0, nm[0]);
|
// glUniformMatrix3fv(current->uniforms[UNIFORM_NORMAL_MATRIX], 1, 0, nm[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void id_modelview() {
|
||||||
|
glUniformMatrix4fv(current->uMVP, 1, 0, projection.as_array());
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void color2(int color, ld part = 1) {
|
void color2(int color, ld part = 1) {
|
||||||
@ -436,7 +439,7 @@ void init() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CAP_SHADER
|
#if CAP_SHADER
|
||||||
projection = id();
|
projection = id;
|
||||||
|
|
||||||
for(int i=0; i<4; i++) {
|
for(int i=0; i<4; i++) {
|
||||||
flagtype f = flags[i];
|
flagtype f = flags[i];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user