mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-12-04 09:09:54 +00:00
support to draw colored textures
This commit is contained in:
parent
8dc7a6cd92
commit
6d8cc0eadc
11
drawing.cpp
11
drawing.cpp
@ -598,10 +598,17 @@ void dqi_poly::gldraw() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(tinf) {
|
if(tinf) {
|
||||||
glhr::be_textured();
|
bool col = isize(tinf->colors);
|
||||||
|
if(col)
|
||||||
|
glhr::be_color_textured();
|
||||||
|
else
|
||||||
|
glhr::be_textured();
|
||||||
if(flags & POLY_SHADE_TEXTURE) current_display->next_shader_flags |= GF_TEXTURE_SHADED;
|
if(flags & POLY_SHADE_TEXTURE) current_display->next_shader_flags |= GF_TEXTURE_SHADED;
|
||||||
glBindTexture(GL_TEXTURE_2D, tinf->texture_id);
|
glBindTexture(GL_TEXTURE_2D, tinf->texture_id);
|
||||||
glhr::vertices_texture(v, tinf->tvertices, offset, offset_texture);
|
if(isize(tinf->colors))
|
||||||
|
glhr::vertices_texture_color(v, tinf->tvertices, tinf->colors, offset, offset_texture);
|
||||||
|
else
|
||||||
|
glhr::vertices_texture(v, tinf->tvertices, offset, offset_texture);
|
||||||
ioffset = 0;
|
ioffset = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -90,6 +90,7 @@ struct escher_floorshape : floorshape {
|
|||||||
struct basic_textureinfo {
|
struct basic_textureinfo {
|
||||||
int texture_id;
|
int texture_id;
|
||||||
vector<glvertex> tvertices;
|
vector<glvertex> tvertices;
|
||||||
|
vector<glvertex> colors;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** basic geometry parameters */
|
/** basic geometry parameters */
|
||||||
|
24
glhr.cpp
24
glhr.cpp
@ -729,6 +729,29 @@ EX void vertices_texture(const vector<glvertex>& v, const vector<glvertex>& t, i
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EX void vertices_texture_color(const vector<glvertex>& v, const vector<glvertex>& t, const vector<glvertex>& c, int vshift IS(0), int tshift IS(0)) {
|
||||||
|
#if CAP_VERTEXBUFFER
|
||||||
|
int q = min(isize(v)-vshift, isize(t)-tshift);
|
||||||
|
vector<ct_vertex> tv(q);
|
||||||
|
for(int i=0; i<q; i++)
|
||||||
|
tv[i].coords = v[vshift+i],
|
||||||
|
tv[i].texture[0] = t[tshift+i][0],
|
||||||
|
tv[i].texture[1] = t[tshift+i][1],
|
||||||
|
tv[i].color = c[tshift+i];
|
||||||
|
prepare(tv);
|
||||||
|
#else
|
||||||
|
vertices(v, vshift);
|
||||||
|
WITHSHADER({
|
||||||
|
glVertexAttribPointer(aTexture, SHDIM, GL_FLOAT, GL_FALSE, sizeof(glvertex), &t[tshift]);
|
||||||
|
glVertexAttribPointer(aColor, 4, GL_FLOAT, GL_FALSE, sizeof(glvertex), &c[tshift]);
|
||||||
|
}, {
|
||||||
|
glTexCoordPointer(SHDIM, GL_FLOAT, 0, &t[tshift]);
|
||||||
|
glColorPointer(4, GL_FLOAT, sizeof(colored_vertex), &c[0]);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
EX void prepare(vector<colored_vertex>& v) {
|
EX void prepare(vector<colored_vertex>& v) {
|
||||||
#if CAP_VERTEXBUFFER
|
#if CAP_VERTEXBUFFER
|
||||||
bindbuffer(v);
|
bindbuffer(v);
|
||||||
@ -835,6 +858,7 @@ EX void switch_to_text(const vector<glvertex>& v, const vector<glvertex>& t) {
|
|||||||
|
|
||||||
EX void be_nontextured() { current_display->next_shader_flags = 0; }
|
EX void be_nontextured() { current_display->next_shader_flags = 0; }
|
||||||
EX void be_textured() { current_display->next_shader_flags = GF_TEXTURE; }
|
EX void be_textured() { current_display->next_shader_flags = GF_TEXTURE; }
|
||||||
|
EX void be_color_textured() { current_display->next_shader_flags = GF_TEXTURE | GF_VARCOLOR; }
|
||||||
|
|
||||||
EX }
|
EX }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user