gldraw:: offset and texture_offset are now separate

This commit is contained in:
Zeno Rogue 2019-03-20 02:16:00 +01:00
parent eed92c5b96
commit 5116d745c4
5 changed files with 13 additions and 26 deletions

View File

@ -674,6 +674,7 @@ void draw_qfi(cell *c, const transmatrix& V, color_t col, PPR prio = PPR::DEFAUL
else if(qfi.tinf) {
auto& poly = queuetable(V * qfi.spin, qfi.tinf->vertices, isize(qfi.tinf->vertices), texture::config.mesh_color, texture::config.recolor(col), prio == PPR::DEFAULT ? PPR::FLOOR : prio);
poly.tinf = qfi.tinf;
poly.offset_texture = 0;
poly.flags = POLY_INVERSE;
}
#endif

View File

@ -4813,6 +4813,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
if(qfi.fshape && wmescher) {
auto& poly = queuepoly(V, shWall3D[a], darkena(wcol - d * get_darkval(a), 0, 0xFF));
poly.tinf = &qfi.fshape->tinf3;
poly.offset_texture = 0;
}
else
queuepoly(V, shPlainWall3D[a], darkena(wcol - d * get_darkval(a), 0, 0xFF));

View File

@ -2858,7 +2858,7 @@ struct dqi_poly : drawqueueitem {
ld band_shift;
transmatrix V;
const vector<glvertex> *tab;
int offset, cnt;
int offset, cnt, offset_texture;
color_t outline;
double linewidth;
int flags;

View File

@ -568,7 +568,7 @@ void dqi_poly::gldraw() {
glhr::be_textured();
glBindTexture(GL_TEXTURE_2D, tinf->texture_id);
current_display->set_projection(0, true);
glhr::vertices_texture(v, tinf->tvertices, offset);
glhr::vertices_texture(v, tinf->tvertices, offset, offset_texture);
ioffset = 0;
#endif
}
@ -905,11 +905,13 @@ void dqi_poly::draw() {
int i = cnt;
cnt = 3;
for(int j=0; j<i; j+=3) {
offset = j;
offset += j;
offset_texture += j;
draw();
offset -= j;
offset_texture -= j;
}
cnt = i;
offset = 0;
return;
}
@ -976,12 +978,6 @@ void dqi_poly::draw() {
if(cpha == 1) pha = 0;
}
}
vector<glvertex> tv;
if(tinf) {
for(int i=0; i<cnt; i++)
tv.push_back(tinf->tvertices[offset+i]);
swap(tinf->tvertices, tv);
}
dynamicval<eModel> d1(pmodel, mdUnchanged);
dynamicval<transmatrix> d2(V, Id);
dynamicval<int> d3(offset, 0);
@ -991,7 +987,6 @@ void dqi_poly::draw() {
tab = &phases[j];
draw();
}
if(tinf) swap(tinf->tvertices, tv);
return;
}
@ -1145,17 +1140,7 @@ void dqi_poly::draw() {
npoly.cnt = isize(glcoords);
if(nofill) npoly.color = 0, npoly.tinf = NULL;
npoly.flags = poly_flags;
if(npoly.tinf && offset) {
vector<glvertex> tv;
for(int i=0; i<cnt; i++)
tv.push_back(tinf->tvertices[offset+i]);
swap(tinf->tvertices, tv);
npoly.gldraw();
swap(tinf->tvertices, tv);
}
else {
npoly.gldraw();
}
npoly.gldraw();
continue;
}
#endif
@ -1181,7 +1166,7 @@ void dqi_poly::draw() {
#if CAP_TEXTURE
if(!(poly_flags & POLY_INVERSE))
for(int i=0; i<polyi; i += 3)
drawTexturedTriangle(s, polyx+i, polyy+i, &tinf->tvertices[offset + i], color);
drawTexturedTriangle(s, polyx+i, polyy+i, &tinf->tvertices[offset_texture + i], color);
#endif
}
else if(poly_flags & POLY_INVERSE) {

View File

@ -661,15 +661,15 @@ void vertices(const vector<glvertex>& v, int vshift = 0) {
#endif
}
void vertices_texture(const vector<glvertex>& v, const vector<glvertex>& t, int vshift = 0) {
void vertices_texture(const vector<glvertex>& v, const vector<glvertex>& t, int vshift = 0, int tshift = 0) {
#if CAP_VERTEXBUFFER
// not implemented!
#else
vertices(v, vshift);
#if CAP_SHADER
glVertexAttribPointer(aTexture, SHDIM, GL_FLOAT, GL_FALSE, sizeof(glvertex), &t[0]);
glVertexAttribPointer(aTexture, SHDIM, GL_FLOAT, GL_FALSE, sizeof(glvertex), &t[tshift]);
#else
glTexCoordPointer(SHDIM, GL_FLOAT, 0, &v[0]);
glTexCoordPointer(SHDIM, GL_FLOAT, 0, &t[tshift]);
#endif
#endif
}