Simplify ogl_ubitblt_i GL array initialization
- Avoid zero-filling arrays that can be directly initialized with real values. - Hold color_array const so it can be stored statically.
This commit is contained in:
parent
eca189e8aa
commit
73bcfb6d63
|
@ -1141,9 +1141,6 @@ void g3_draw_bitmap(grs_canvas &canvas, const vms_vector &pos, const fix iwidth,
|
||||||
bool ogl_ubitblt_i(unsigned dw,unsigned dh,unsigned dx,unsigned dy, unsigned sw, unsigned sh, unsigned sx, unsigned sy, const grs_bitmap &src, grs_bitmap &dest, const opengl_texture_filter texfilt)
|
bool ogl_ubitblt_i(unsigned dw,unsigned dh,unsigned dx,unsigned dy, unsigned sw, unsigned sh, unsigned sx, unsigned sy, const grs_bitmap &src, grs_bitmap &dest, const opengl_texture_filter texfilt)
|
||||||
{
|
{
|
||||||
GLfloat xo,yo,xs,ys,u1,v1;
|
GLfloat xo,yo,xs,ys,u1,v1;
|
||||||
GLfloat color_array[] = { 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 };
|
|
||||||
GLfloat texcoord_array[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
|
|
||||||
GLfloat vertices[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
|
|
||||||
struct bitblt_free_ogl_texture
|
struct bitblt_free_ogl_texture
|
||||||
{
|
{
|
||||||
ogl_texture t;
|
ogl_texture t;
|
||||||
|
@ -1176,25 +1173,35 @@ bool ogl_ubitblt_i(unsigned dw,unsigned dh,unsigned dx,unsigned dy, unsigned sw,
|
||||||
|
|
||||||
ogl_texwrap(&tex,GL_CLAMP_TO_EDGE);
|
ogl_texwrap(&tex,GL_CLAMP_TO_EDGE);
|
||||||
|
|
||||||
vertices[0] = xo;
|
const GLfloat vertices[] = {
|
||||||
vertices[1] = yo;
|
xo,
|
||||||
vertices[2] = xo+xs;
|
yo,
|
||||||
vertices[3] = yo;
|
xo + xs,
|
||||||
vertices[4] = xo+xs;
|
yo,
|
||||||
vertices[5] = yo-ys;
|
xo + xs,
|
||||||
vertices[6] = xo;
|
yo - ys,
|
||||||
vertices[7] = yo-ys;
|
xo,
|
||||||
|
yo - ys
|
||||||
|
};
|
||||||
|
|
||||||
texcoord_array[0] = u1;
|
const GLfloat texcoord_array[] = {
|
||||||
texcoord_array[1] = v1;
|
u1,
|
||||||
texcoord_array[2] = tex.u;
|
v1,
|
||||||
texcoord_array[3] = v1;
|
tex.u,
|
||||||
texcoord_array[4] = tex.u;
|
v1,
|
||||||
texcoord_array[5] = tex.v;
|
tex.u,
|
||||||
texcoord_array[6] = u1;
|
tex.v,
|
||||||
texcoord_array[7] = tex.v;
|
u1,
|
||||||
|
tex.v
|
||||||
|
};
|
||||||
|
|
||||||
glVertexPointer(2, GL_FLOAT, 0, vertices);
|
glVertexPointer(2, GL_FLOAT, 0, vertices);
|
||||||
|
static constexpr GLfloat color_array[] = {
|
||||||
|
1.0, 1.0, 1.0, 1.0,
|
||||||
|
1.0, 1.0, 1.0, 1.0,
|
||||||
|
1.0, 1.0, 1.0, 1.0,
|
||||||
|
1.0, 1.0, 1.0, 1.0
|
||||||
|
};
|
||||||
glColorPointer(4, GL_FLOAT, 0, color_array);
|
glColorPointer(4, GL_FLOAT, 0, color_array);
|
||||||
glTexCoordPointer(2, GL_FLOAT, 0, texcoord_array);
|
glTexCoordPointer(2, GL_FLOAT, 0, texcoord_array);
|
||||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);//replaced GL_QUADS
|
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);//replaced GL_QUADS
|
||||||
|
|
Loading…
Reference in a new issue