diff options
author | chai <chaifix@163.com> | 2019-04-13 20:15:07 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-04-13 20:15:07 +0800 |
commit | 866e00474be3bfe0e7dac73b720af0b9ebf7109a (patch) | |
tree | 36c44e99352e2d582b4f2f1dbd4e9e672a54f2cf /source/tests | |
parent | b5b43bac50ad58949e70bcd1a34b1e6c4765fd51 (diff) |
*misc
Diffstat (limited to 'source/tests')
-rw-r--r-- | source/tests/win32/01-window/03_sub_menu.cpp | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/source/tests/win32/01-window/03_sub_menu.cpp b/source/tests/win32/01-window/03_sub_menu.cpp index be22665..ba384cb 100644 --- a/source/tests/win32/01-window/03_sub_menu.cpp +++ b/source/tests/win32/01-window/03_sub_menu.cpp @@ -6,6 +6,7 @@ #include <asura-core/graphics/image.h> #include <asura-core/graphics/shader.h> #include <asura-core/image/image_data.h> +#include <asura-core/graphics/vertex_buffer.h> #include <SDL2/SDL.h> #include <string> @@ -55,7 +56,7 @@ void main() )"; Shader* shader; -GPUBuffer* vb; +VertexBuffer* vb; struct Vert { @@ -76,7 +77,7 @@ int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR lpCmdLin wc.hCursor = LoadCursor(0, IDC_ARROW); RegisterClassW(&wc); - wnd = CreateWindowW(wc.lpszClassName, L"Asura v0.1", + wnd = CreateWindowW(wc.lpszClassName, L"Asura beta", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 200, 200, 550, 450, 0, 0, hInstance, 0); @@ -130,19 +131,19 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, //hdc = GetDC(hwnd); //glc = wglCreateContext(hdc); glClearColor(0.16, 0.16, 0.16, 1); - glColor4f(0.219, 0.219, 0.219, 1); + //glColor4f(0.219, 0.219, 0.219, 1); //glRectf(-0.5f, -0.5f, 0.5f, 0.5f); - glColor4f(1, 1, 1, 1); + //glColor4f(1, 1, 1, 1); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); tex = img->GetGLTexture(); glBindTexture(GL_TEXTURE_2D, tex); // - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); //Sͼ - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); //Tͼ - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); //Ŵ˷ʽ - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); //С˷ʽ + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); { int imgLoc = shader->GetUniformLocation("img"); @@ -153,10 +154,10 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, gl.LoadIdentity(); gl.Ortho(0, viewport.w, viewport.h, 0, -1, 1); gl.SetMatrixMode(MATRIX_MODE_MODEL); - gl.LoadIdentity(); + gl.Translate(1, 0); shader->SetBuiltInUniforms(); - shader->SetAttribPosition(2, vb, 0, 4 * sizeof(float)); - shader->SetAttribTexcoord0(2, vb, 2 * sizeof(float), 4 * sizeof(float)); + shader->SetAttribPosition(vb, 0, 4); + shader->SetAttribTexcoord0(vb, 2, 4); gl.DrawArrays(GL_TRIANGLE_STRIP, 0, 4); gl.UnuseShader(); } @@ -216,12 +217,12 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, int w = img->GetWidth(); int h = img->GetHeight(); Vert v[] = { - { 0, 0, 0, 0 }, - { 0, h, 0, 1 }, - { w, 0, 1, 0 }, - { w, h, 1, 1 }, + { 0.5f, 0.5f, 0, 0 }, + { 0.5f, h + 0.5f, 0, 1 }, + { w + 0.5f, 0.5f, 1, 0 }, + { w + 0.5f, h + 0.5f, 1, 1 }, }; - vb = new GPUBuffer(BUFFER_TYPE_VERTEX, BUFFER_USAGE_STATIC, BUFFER_DATA_TYPE_FLOAT, sizeof(v)); + vb = new VertexBuffer(BUFFER_USAGE_STATIC, BUFFER_DATA_TYPE_FLOAT, sizeof(v)); vb->Fill(v, sizeof(v)); }; |