mirror of https://github.com/adamdruppe/arsd.git
Replace broken OpenGL solution with working one
Previous one was utter nonsense upon closer inspection. The one in glnvg__finishClip is tested, the one in glnvg__copyFBOToFrom is not because I couldn't figure out how to reach it. Same code however so, eh.
This commit is contained in:
parent
c52fb47084
commit
5d6e320a77
50
nanovega.d
50
nanovega.d
|
@ -13109,21 +13109,14 @@ void glnvg__copyFBOToFrom (GLNVGcontext* gl, int didx, int sidx) nothrow @truste
|
||||||
enum y = 0;
|
enum y = 0;
|
||||||
immutable int w = gl.fboWidth;
|
immutable int w = gl.fboWidth;
|
||||||
immutable int h = gl.fboHeight;
|
immutable int h = gl.fboHeight;
|
||||||
immutable(int[8]) vertices =
|
immutable(NVGVertex[4]) vertices =
|
||||||
[x, y, // top-left
|
[NVGVertex(x, y), // top-left
|
||||||
w, y, // top-right
|
NVGVertex(w, y), // top-right
|
||||||
w, h, // bottom-right
|
NVGVertex(w, h), // bottom-right
|
||||||
x, h]; // bottom-left
|
NVGVertex(x, h)]; // bottom-left
|
||||||
uint vbo;
|
|
||||||
glGenBuffers(1, &vbo); //TODO: figure out if allocating a new buffer each time is a good idea
|
glBufferSubData(GL_ARRAY_BUFFER, 0, vertices.sizeof, &vertices);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, vbo);
|
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||||
glBufferData(GL_ARRAY_BUFFER, vertices.sizeof, &vertices, GL_STREAM_DRAW);
|
|
||||||
uint vao;
|
|
||||||
glGenVertexArrays(1, &vao);
|
|
||||||
glBindVertexArray(vao);
|
|
||||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 3);
|
|
||||||
glDeleteBuffers(1, &vbo);
|
|
||||||
glDeleteVertexArrays(1, &vao);
|
|
||||||
|
|
||||||
// restore state (but don't unbind FBO)
|
// restore state (but don't unbind FBO)
|
||||||
static if (NANOVG_GL_USE_STATE_FILTER) glBindTexture(GL_TEXTURE_2D, gl.boundTexture);
|
static if (NANOVG_GL_USE_STATE_FILTER) glBindTexture(GL_TEXTURE_2D, gl.boundTexture);
|
||||||
|
@ -13723,21 +13716,15 @@ void glnvg__finishClip (GLNVGcontext* gl, NVGClipMode clipmode) nothrow @trusted
|
||||||
glnvg__stencilFunc(gl, GL_NOTEQUAL, 0x00, 0xff);
|
glnvg__stencilFunc(gl, GL_NOTEQUAL, 0x00, 0xff);
|
||||||
glStencilOp(GL_ZERO, GL_ZERO, GL_ZERO);
|
glStencilOp(GL_ZERO, GL_ZERO, GL_ZERO);
|
||||||
}
|
}
|
||||||
immutable(int[8]) vertices =
|
|
||||||
[0, 0,
|
immutable(NVGVertex[4]) vertices =
|
||||||
0, gl.fboHeight,
|
[NVGVertex(0, 0, 0, 0),
|
||||||
gl.fboWidth, gl.fboHeight,
|
NVGVertex(0, gl.fboHeight, 0, 0),
|
||||||
gl.fboWidth, 0];
|
NVGVertex(gl.fboWidth, gl.fboHeight, 0, 0),
|
||||||
uint vbo;
|
NVGVertex(gl.fboWidth, 0, 0, 0)];
|
||||||
glGenBuffers(1, &vbo); //TODO: figure out if allocating a new buffer each time is a good idea
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, vbo);
|
glBufferSubData(GL_ARRAY_BUFFER, 0, vertices.sizeof, &vertices);
|
||||||
glBufferData(GL_ARRAY_BUFFER, vertices.sizeof, &vertices, GL_STREAM_DRAW);
|
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||||
uint vao;
|
|
||||||
glGenVertexArrays(1, &vao);
|
|
||||||
glBindVertexArray(vao);
|
|
||||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 3);
|
|
||||||
glDeleteBuffers(1, &vbo);
|
|
||||||
glDeleteVertexArrays(1, &vao);
|
|
||||||
|
|
||||||
//glnvg__restoreAffine(gl);
|
//glnvg__restoreAffine(gl);
|
||||||
}
|
}
|
||||||
|
@ -14177,7 +14164,8 @@ void glnvg__renderFlush (void* uptr) nothrow @trusted @nogc {
|
||||||
|
|
||||||
// Upload vertex data
|
// Upload vertex data
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, gl.vertBuf);
|
glBindBuffer(GL_ARRAY_BUFFER, gl.vertBuf);
|
||||||
glBufferData(GL_ARRAY_BUFFER, gl.nverts*NVGVertex.sizeof, gl.verts, GL_STREAM_DRAW);
|
// ensure that there's space for at least 4 vertices in case we need to draw a quad (e. g. framebuffer copy)
|
||||||
|
glBufferData(GL_ARRAY_BUFFER, (gl.nverts < 4 ? 4 : gl.nverts) * NVGVertex.sizeof, gl.verts, GL_STREAM_DRAW);
|
||||||
glEnableVertexAttribArray(0);
|
glEnableVertexAttribArray(0);
|
||||||
glEnableVertexAttribArray(1);
|
glEnableVertexAttribArray(1);
|
||||||
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, NVGVertex.sizeof, cast(const(GLvoid)*)cast(usize)0);
|
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, NVGVertex.sizeof, cast(const(GLvoid)*)cast(usize)0);
|
||||||
|
|
Loading…
Reference in New Issue