triangle strips

This commit is contained in:
gazer 2016-01-04 19:43:05 +03:00
parent 6c95d1f7d6
commit 57002757b7
1 changed files with 15 additions and 21 deletions

View File

@ -313,7 +313,7 @@ class SolidFillProgram : GLProgram {
glEnableVertexAttribArray(vertexLocation);
glEnableVertexAttribArray(colAttrLocation);
checkgl!glDrawArrays(GL_TRIANGLES, 0, cast(int)vertices.length/3);
checkgl!glDrawArrays(GL_TRIANGLE_STRIP, 0, cast(int)vertices.length/3);
destroy(vbo);
destroy(vao);
@ -405,7 +405,7 @@ class TextureProgram : SolidFillProgram {
glEnableVertexAttribArray(colAttrLocation);
glEnableVertexAttribArray(texCoordLocation);
checkgl!glDrawArrays(GL_TRIANGLES, 0, cast(int)vertices.length/3);
checkgl!glDrawArrays(GL_TRIANGLE_STRIP, 0, cast(int)vertices.length/3);
destroy(vbo);
destroy(vao);
@ -625,13 +625,11 @@ class GLSupport {
static immutable float Z_2D = -2.0f;
void drawSolidFillRect(Rect rc, uint color1, uint color2, uint color3, uint color4) {
Color[6] colors;
Color[4] colors;
FillColor(color1, colors[0..1]);
FillColor(color4, colors[1..2]);
FillColor(color2, colors[1..2]);
FillColor(color3, colors[2..3]);
FillColor(color1, colors[3..4]);
FillColor(color3, colors[4..5]);
FillColor(color2, colors[5..6]);
FillColor(color4, colors[3..4]);
float x0 = cast(float)(rc.left);
float y0 = cast(float)(bufferDy-rc.top);
float x1 = cast(float)(rc.right);
@ -643,13 +641,11 @@ class GLSupport {
y1 = cast(float)(rc.bottom);
}
float[3 * 6] vertices = [
float[3 * 4] vertices = [
x0,y0,Z_2D,
x0,y1,Z_2D,
x1,y1,Z_2D,
x0,y0,Z_2D,
x1,y1,Z_2D,
x1,y0,Z_2D];
x1,y0,Z_2D,
x1,y1,Z_2D];
if (_legacyMode) {
glColor4f(1,1,1,1);
@ -662,7 +658,7 @@ class GLSupport {
checkgl!glVertexPointer(3, GL_FLOAT, 0, cast(void*)vertices.ptr);
checkgl!glColorPointer(4, GL_FLOAT, 0, cast(void*)colors);
checkgl!glDrawArrays(GL_TRIANGLES, 0, 6);
checkgl!glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
@ -681,7 +677,7 @@ class GLSupport {
}
void drawColorAndTextureRect(Tex2D texture, int tdx, int tdy, int srcx, int srcy, int srcdx, int srcdy, int xx, int yy, int dx, int dy, uint color, bool linear) {
Color[6] colors;
Color[4] colors;
FillColor(color, colors);
float dstx0 = cast(float)xx;
float dsty0 = cast(float)(bufferDy - (yy));
@ -698,14 +694,12 @@ class GLSupport {
float srcy0 = srcy / cast(float)tdy;
float srcx1 = (srcx + srcdx) / cast(float)tdx;
float srcy1 = (srcy + srcdy) / cast(float)tdy;
float[3 * 6] vertices = [
float[3 * 4] vertices = [
dstx0,dsty0,Z_2D,
dstx0,dsty1,Z_2D,
dstx1,dsty1,Z_2D,
dstx0,dsty0,Z_2D,
dstx1,dsty1,Z_2D,
dstx1,dsty0,Z_2D];
float[2 * 6] texcoords = [srcx0,srcy0, srcx0,srcy1, srcx1,srcy1, srcx0,srcy0, srcx1,srcy1, srcx1,srcy0];
dstx1,dsty0,Z_2D,
dstx1,dsty1,Z_2D];
float[2 * 4] texcoords = [srcx0,srcy0, srcx0,srcy1, srcx1,srcy0, srcx1,srcy1];
if (_legacyMode) {
glDisable(GL_CULL_FACE);
@ -726,7 +720,7 @@ class GLSupport {
checkgl!glTexCoordPointer(2, GL_FLOAT, 0, cast(void*)texcoords.ptr);
checkgl!glColorPointer(4, GL_FLOAT, 0, cast(void*)colors.ptr);
checkgl!glDrawArrays(GL_TRIANGLES, 0, 6);
checkgl!glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);