Fix vertex preview when framebuf is an odd size.

The previous stuff was wrong, just happened to work.
This commit is contained in:
Unknown W. Brackets 2013-11-17 15:05:11 -08:00
parent ed16e42ca8
commit 6d6dff6041
2 changed files with 10 additions and 2 deletions

View File

@ -77,6 +77,14 @@ struct SimpleGLWindow {
return h_;
}
int TexWidth() {
return tw_;
}
int TexHeight() {
return th_;
}
void GetContentSize(float &x, float &y, float &fw, float &fh);
static void RegisterClass();

View File

@ -177,12 +177,12 @@ void CGEDebugger::UpdatePrimPreview(u32 op) {
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBlendEquation(GL_FUNC_ADD);
glBindTexture(GL_TEXTURE_2D, 0);
glViewport(x, -y, fw, fh);
glViewport(x, y, fw, fh);
glScissor(x, y, fw, fh);
BindPreviewProgram(previewProgram);
Matrix4x4 ortho;
ortho.setOrtho(0, fw, fh, 0, -1, 1);
ortho.setOrtho(0, frameWindow->TexWidth(), frameWindow->TexHeight(), 0, -1, 1);
glUniformMatrix4fv(previewProgram->u_viewproj, 1, GL_FALSE, ortho.getReadPtr());
glEnableVertexAttribArray(previewProgram->a_position);
glVertexAttribPointer(previewProgram->a_position, 3, GL_FLOAT, GL_FALSE, sizeof(GPUDebugVertex), (float *)vertices.data() + 2);