summaryrefslogtreecommitdiff
path: root/source/tests/win32/01-window/03_sub_menu.cpp
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2019-05-11 12:08:45 +0800
committerchai <chaifix@163.com>2019-05-11 12:08:45 +0800
commitf6c0498c9728a286c13980ed3b60763d02e1b3a0 (patch)
treec07b283cb2183b320730cf3811b130eca3d90353 /source/tests/win32/01-window/03_sub_menu.cpp
parent59a0e32991b5b714b6bdba504b6fbacdcd4b907a (diff)
*misc
Diffstat (limited to 'source/tests/win32/01-window/03_sub_menu.cpp')
-rw-r--r--source/tests/win32/01-window/03_sub_menu.cpp25
1 files changed, 9 insertions, 16 deletions
diff --git a/source/tests/win32/01-window/03_sub_menu.cpp b/source/tests/win32/01-window/03_sub_menu.cpp
index 9ddc8d7..41023ea 100644
--- a/source/tests/win32/01-window/03_sub_menu.cpp
+++ b/source/tests/win32/01-window/03_sub_menu.cpp
@@ -33,15 +33,13 @@ string vert = R"(
in vec2 position;
in vec2 uv;
-uniform mat4 asura_projection_matrix;
-uniform mat4 asura_model_matrix;
-uniform mat4 asura_view_matrix;
+uniform mat4 asura_mvp;
out vec2 texCoord;
void main()
{
- gl_Position = asura_projection_matrix * asura_view_matrix * asura_model_matrix * vec4(position, 0, 1);
+ gl_Position = asura_mvp * vec4(position, 0, 1);
texCoord = uv;
}
)";
@@ -64,9 +62,7 @@ struct
{
int pos;
int tex;
- int m;
- int v;
- int p;
+ int mvp;
int color;
} locs;
@@ -170,13 +166,12 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg,
gl.SetMatrixMode(MATRIX_MODE_MODEL);
gl.LoadIdentity();
gl.Translate(100, 100);
- shader->SetUniformMatrix44(locs.m, gl.GetMatrix(MATRIX_MODE_MODEL));
- shader->SetUniformMatrix44(locs.v, gl.GetMatrix(MATRIX_MODE_VIEW));
- shader->SetUniformMatrix44(locs.p, gl.GetMatrix(MATRIX_MODE_PROJECTION));
+ gl.SetDrawColor(1, 1, 1, 1);
+ shader->SetBuiltInMVPMatrix(locs.mvp);
+ shader->SetBuiltInDrawColor(locs.color);
shader->SetAttribute(locs.pos, vb, 0, 4);
shader->SetAttribute(locs.tex, vb, 2, 4);
- gl.SetDrawColor(1, 1, 0, 1);
- shader->SetUniformColor(locs.color, gl.GetDrawColor());
+
//glLineWidth(1);
gl.DrawArrays(GL_LINE_STRIP, 0, 5);
//gl.DrawArrays(GL_TRIANGLE_STRIP, 0, 4);
@@ -216,7 +211,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg,
wglMakeCurrent(hdc, glc);
RECT rect;
- GetWindowRect(hwnd, &rect);
+ GetClientRect(hwnd, &rect);
viewport.Set(0, 0, rect.right - rect.left, rect.bottom - rect.top);
if (!gl.Init(viewport))
return 0;
@@ -255,9 +250,7 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg,
vb = new VertexBuffer(BUFFER_USAGE_STATIC, BUFFER_DATA_TYPE_FLOAT, sizeof(v));
vb->Fill(v, sizeof(v));
};
- locs.m = shader->GetUniformLocation("asura_model_matrix");
- locs.v = shader->GetUniformLocation("asura_view_matrix");
- locs.p = shader->GetUniformLocation("asura_projection_matrix");
+ locs.mvp = shader->GetUniformLocation("asura_mvp");
locs.color = shader->GetUniformLocation("color");
locs.pos = shader->GetAttributeLocation("position");
locs.tex = shader->GetAttributeLocation("uv");