From 777b4bd2f3820569561546d2a3d73aabd469699c Mon Sep 17 00:00:00 2001 From: Joey Pollack Date: Mon, 15 Aug 2022 18:55:14 -0400 Subject: [PATCH] Multiple texture slots working in the quad shader --- docs/tasks/refactoring.todo | 2 +- src/renderer/renderer2D.cpp | 176 +++++------------- src/renderer/renderer2D.h | 4 +- src/renderer/shaders/quad.frag | 30 ++- src/renderer/shaders/quad.vert | 52 ++++-- src/renderer/texture.cpp | 5 +- .../testbed/scenes/simple_render_scene.cpp | 66 +++++-- .../testbed/scenes/simple_render_scene.h | 4 + 8 files changed, 168 insertions(+), 171 deletions(-) diff --git a/docs/tasks/refactoring.todo b/docs/tasks/refactoring.todo index ee32943..5bb7917 100644 --- a/docs/tasks/refactoring.todo +++ b/docs/tasks/refactoring.todo @@ -6,7 +6,7 @@ Renderer rewrite: ✔ Batch rendering minimally working @done(22-08-12 19:19) - ☐ See if it's possible/better to move the matrix math into the shaders @high + ✔ See if it's possible/better to move the matrix math into the shaders @high @done(22-08-15 14:23) ☐ Textures in batch renderer @high ☐ DrawSprite method ☐ Sprite shader diff --git a/src/renderer/renderer2D.cpp b/src/renderer/renderer2D.cpp index 45dee9b..dcbcf3c 100644 --- a/src/renderer/renderer2D.cpp +++ b/src/renderer/renderer2D.cpp @@ -56,7 +56,7 @@ namespace lunarium mQuadData.mBufferLayout.PushVertexAttribute(VertexAttribute { VertexAttributeType::FLOAT32, 3 }); // Position mQuadData.mBufferLayout.PushVertexAttribute(VertexAttribute { VertexAttributeType::FLOAT32, 2 }); // Tex_coords mQuadData.mBufferLayout.PushVertexAttribute(VertexAttribute { VertexAttributeType::FLOAT32, 4 }); // Color - mQuadData.mBufferLayout.PushVertexAttribute(VertexAttribute { VertexAttributeType::INT32, 1 }); // Texture Sampler Index + mQuadData.mBufferLayout.PushVertexAttribute(VertexAttribute { VertexAttributeType::FLOAT32, 1 }); // Texture Sampler Index mQuadData.mBufferLayout.PushVertexAttribute(VertexAttribute { VertexAttributeType::FLOAT32, 3 }); // translation mQuadData.mBufferLayout.PushVertexAttribute(VertexAttribute { VertexAttributeType::FLOAT32, 1 }); // angle mQuadData.mBufferLayout.PushVertexAttribute(VertexAttribute { VertexAttributeType::FLOAT32, 3 }); // Scale @@ -66,6 +66,14 @@ namespace lunarium mQuadData.mRawVertexBuffer = new QuadData::Vertex[mQuadData.MaxVertices]; mQuadData.mRawBufferIndex = 0; + int layout_size = mQuadData.mBufferLayout.GetLayoutSizeInBytes(); + int struct_size = sizeof(QuadData::Vertex); + if (struct_size != layout_size) + { + Logger::Error(LogCategory::GRAPHICS, + "Quad::Vertex struct size does not match the vertex layout size! struct: %d, layout: %d", struct_size, layout_size); + } + //mQuadData.mIndexBuffer = new IndexBuffer(mQuadData.MaxIndices * sizeof(u32)); std::string vert_source = File::ReadTextFile("quad.vert"); @@ -80,8 +88,9 @@ namespace lunarium // TODO: INIT DEBUG TEXTURE - u8 data[4] = {255, 128, 0, 0}; - mpDebugTexture = Texture::Create(data, 1, 1); + u8 data[4] = {255, 255, 255, 255}; + mpWhiteTexture = Texture::Create(data, 1, 1); + mLoadedTextures.push_back(mpWhiteTexture); // DEBUG: INIT TEST DATA // mTestData.mBufferLayout.PushVertexAttribute(VertexAttribute { VertexAttributeType::FLOAT32, 2}); // Position @@ -171,52 +180,28 @@ namespace lunarium ///////////////////////////////////////////////////////////////////// void Renderer2D::DrawQuad(Rectangle quad, Color color, Texture* texture, float angle) { - /* - mTestData.color = color; - //mTestData.mVertexBuffer->Bind(); - mTestData.mQuadShader->Use(); - - Uniform uni { "spriteColor", UniformType::F3, -1 }; - mTestData.mQuadShader->SetUniform(uni, color.arr).LogIfFailed(LogCategory::GRAPHICS, "Failed to set uniform for the test shader!"); - - //glBindVertexArray(mTVAO); - GLfloat vertices[6][2] = { - { -0.5f, 0.5f, }, - { 0.5f, -0.5f, }, - { -0.5f, -0.5f, }, - - { -0.5f, 0.5f, }, - { 0.5f, 0.5f, }, - { 0.5f, -0.5f, } - }; - mTestData.mVertexBuffer->PushVertices(vertices, 6); - mTestData.mVertexBuffer->Bind(); - // mTestData.mIndexBuffer->Bind(); - glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, nullptr); - //glDrawArrays(GL_TRIANGLES, 0, 6); - mTestData.mVertexBuffer->Clear(); - */ + int texture_slot = -1; + if (texture) + { + for (int i = 0; i < mLoadedTextures.size(); i++) + { + if (texture == mLoadedTextures[i]) + { + texture_slot = i; + break; + } + } - - int texture_slot = 0; - // int texture_slot = -1; - // if (texture) - // { - // for (int i = 0; i < mLoadedTextures.size(); i++) - // { - // if (texture == mLoadedTextures[i]) - // { - // texture_slot = i; - // break; - // } - // } - - // if (-1 == texture_slot) - // { - // mLoadedTextures.push_back(texture); - // texture_slot = mLoadedTextures.size() - 1; - // } - // } + if (-1 == texture_slot) + { + mLoadedTextures.push_back(texture); + texture_slot = mLoadedTextures.size() - 1; + } + } + else + { + texture_slot = 0; + } //unsigned char* vertices_wl = (unsigned char*)vertices; // vertices write location pointer @@ -228,7 +213,7 @@ namespace lunarium // glm::mat4 model = glm::mat4(1.0f); // model = glm::translate(model, glm::vec3(quad.X, quad.Y, 0.0f)); // model = glm::rotate(model, angle, glm::vec3(0.0f, 0.0f, 1.0f)); - // model = glm::scale(model, glm::vec3(quad.HalfWidth * 2, quad.HalfHeight * 2, 1.0f)); + // model = glm::scale(model, glm::vec3(quad.HalfWidth * 2, quad.HalfHeight * 2, 1.0f)); if (mQuadData.mRawBufferIndex + 4 > mQuadData.MaxVertices) { @@ -238,7 +223,7 @@ namespace lunarium // FIRST QuadData::Vertex v1; int vert_size = sizeof(QuadData::Vertex); - v1.pos = /*model * */mQuadData.vert_pos[0]; + v1.pos = mQuadData.vert_pos[0]; v1.tex_coord = mQuadData.vert_tex[0]; v1.color = color; v1.tex_slot = texture_slot; @@ -250,7 +235,7 @@ namespace lunarium // SECOND QuadData::Vertex v2; - v2.pos = /*model * */ mQuadData.vert_pos[1]; + v2.pos = mQuadData.vert_pos[1]; v2.tex_coord = mQuadData.vert_tex[1]; v2.color = color; v2.tex_slot = texture_slot; @@ -262,7 +247,7 @@ namespace lunarium // THIRD QuadData::Vertex v3; - v3.pos = /*model * */ mQuadData.vert_pos[2]; + v3.pos = mQuadData.vert_pos[2]; v3.tex_coord = mQuadData.vert_tex[2]; v3.color = color; v3.tex_slot = texture_slot; @@ -274,7 +259,7 @@ namespace lunarium // FOURTH QuadData::Vertex v4; - v4.pos = /*model * */ mQuadData.vert_pos[3]; + v4.pos = mQuadData.vert_pos[3]; v4.tex_coord = mQuadData.vert_tex[3]; v4.color = color; v4.tex_slot = texture_slot; @@ -308,81 +293,6 @@ namespace lunarium } - - void Renderer2D::DrawQuads(Rectangle* quads, u32 num_quads, Color* pColors) - { - for (int i = 0; i < num_quads; i++) - { - float vertices[40]; - unsigned char* vertices_wl = (unsigned char*)vertices; // vertices write location pointer - - // glm::mat4 model(1.0f); - // model = glm::translate(model, glm::vec3(quad.CenterPoint().x, quad.CenterPoint().y, 0.0f)); - // model = glm::rotate(model, angle, glm::vec3(0.0f, 0.0f, 1.0f)); - - glm::mat4 model = glm::mat4(1.0f); - model = glm::translate(model, glm::vec3(quads[i].X, quads[i].Y, 0.0f)); - model = glm::rotate(model, 1.0f, glm::vec3(0.0f, 0.0f, 1.0f)); - model = glm::scale(model, glm::vec3(quads[i].HalfWidth * 2, quads[i].HalfHeight * 2, 1.0f)); - - // FIRST - QuadData::Vertex v1; - int vert_size = sizeof(QuadData::Vertex); - v1.pos = model * mQuadData.vert_pos[0]; - v1.tex_coord = mQuadData.vert_tex[0]; - v1.color = pColors[i]; - v1.tex_slot = 0; - memcpy(vertices_wl, &v1, vert_size); - vertices_wl += vert_size; - - // SECOND - QuadData::Vertex v2; - v2.pos = model * mQuadData.vert_pos[1]; - v2.tex_coord = mQuadData.vert_tex[1]; - v2.color = pColors[i]; - v2.tex_slot = 0; - memcpy(vertices_wl, &v2, vert_size); - vertices_wl += vert_size; - - // THIRD - QuadData::Vertex v3; - v3.pos =model * mQuadData.vert_pos[2]; - v3.tex_coord = mQuadData.vert_tex[2]; - v3.color = pColors[i]; - v3.tex_slot = 0; - memcpy(vertices_wl, &v3, vert_size); - vertices_wl += vert_size; - - // FOURTH - QuadData::Vertex v4; - v4.pos = model * mQuadData.vert_pos[3]; - v4.tex_coord = mQuadData.vert_tex[3]; - v4.color = pColors[i]; - v4.tex_slot = 0; - memcpy(vertices_wl, &v4, vert_size); - - if (!mQuadData.mVertexBuffer->PushVertices(vertices, 4)) - { - //Logger::Info(LogCategory::GRAPHICS, "Quad VertexBuffer is full, flushing and retrying"); - Flush(); - i--; - continue; - } - - // INDICES - // if (!mQuadData.mVertexBuffer->PushIndices(mQuadData.indices, 6)) - // { - // Logger::Error(LogCategory::GRAPHICS, "Quad IndexBuffer is full - This shouldn't happen because the VertexBuffer should fill up first!"); - // return; - // } - - mQuadData.mNumQuads++; - mFrameStats.NumTris += 2; - } - - } - - void Renderer2D::DrawSprite(Texture& image, glm::vec2 position, Color color, float angle) { @@ -467,7 +377,7 @@ namespace lunarium //mQuadData.mQuadShader->SetUniform(umodel, (void*)glm::value_ptr(glm::mat4(1.0f))).LogIfFailed(LogCategory::GRAPHICS); mQuadData.mQuadShader->SetUniform(uprojview, (void*)glm::value_ptr(mpCamera->GetViewProjection())).LogIfFailed(LogCategory::GRAPHICS); - Uniform uni { "spriteColor", UniformType::F3, -1 }; + //Uniform uni { "spriteColor", UniformType::F3, -1 }; //Color c = ; //mQuadData.mQuadShader->SetUniform(uni, Color::Red().arr).LogIfFailed(LogCategory::GRAPHICS, "Failed to set uniform for the test shader!"); @@ -477,13 +387,17 @@ namespace lunarium mFrameStats.DrawCalls++; } // Reset drawing data + for (int i = 0; i < mLoadedTextures.size(); i++) + { + mLoadedTextures[i]->Unbind(); + } + mLoadedTextures.clear(); mQuadData.mVertexBuffer->Clear(); - //mQuadData.mIndexBuffer->Clear(); mQuadData.mNumQuads = 0; mQuadData.mRawBufferIndex = 0; // TODO: Add the debug texture back to the map - mLoadedTextures.push_back(mpDebugTexture); + mLoadedTextures.push_back(mpWhiteTexture); } } \ No newline at end of file diff --git a/src/renderer/renderer2D.h b/src/renderer/renderer2D.h index fed81a8..53448e8 100644 --- a/src/renderer/renderer2D.h +++ b/src/renderer/renderer2D.h @@ -94,7 +94,7 @@ namespace lunarium glm::vec3 pos; glm::vec2 tex_coord; glm::vec4 color; - int tex_slot; + float tex_slot; glm::vec3 translation; float angle; glm::vec3 scale; @@ -115,7 +115,7 @@ namespace lunarium FrameStats mFrameStats; OrthographicCamera* mpCamera; std::vector mLoadedTextures; - Texture* mpDebugTexture; + Texture* mpWhiteTexture; Color mClearColor; /// DEBUG STUFF diff --git a/src/renderer/shaders/quad.frag b/src/renderer/shaders/quad.frag index 25c3278..716d99c 100644 --- a/src/renderer/shaders/quad.frag +++ b/src/renderer/shaders/quad.frag @@ -1,12 +1,30 @@ #version 450 core -//in vec2 TexCoords; -in vec4 vert_color; -out vec4 color; +layout (location = 0) in vec2 f_tex_coords; +layout (location = 1) in vec4 f_vert_color; +layout (location = 2) flat in int f_tex_index; -//uniform sampler2D image; -uniform vec3 spriteColor; +out vec4 color; +layout (binding = 0) uniform sampler2D textures[32]; void main() { - color = vert_color; //vec4(spriteColor, 1.0); // * texture(image, TexCoords); + //color = f_vert_color * texture(textures[int(f_tex_index)], f_tex_coords); + //color = vec4(float(f_tex_index) * 0.01, 0.0 , 0.0, 1.0); + color = f_vert_color * texture(textures[f_tex_index], f_tex_coords); +// switch(f_tex_index) +// { +// case 0: color = vec4(1.0, 0.0, 0.0, 1.0); break; //texture(textures[ 0], f_tex_coords); break; +// case 1: color = vec4(0.0, 1.0, 0.0, 1.0); break; //texture(textures[ 1], f_tex_coords); break; +// case 2: color = vec4(0.0, 0.0, 1.0, 1.0); break; //texture(textures[ 1], f_tex_coords); break; +// default: color = vec4(1.0, 1.0, 1.0, 1.0); break; +// } + + // if (f_tex_index > 1000) + // { + // color = vec4(1.0, 0.0, 0.0, 1.0); + // } + // else + // { + // color = vec4(0.0, 0.0, 1.0, 1.0); + // } } \ No newline at end of file diff --git a/src/renderer/shaders/quad.vert b/src/renderer/shaders/quad.vert index 048153a..7ca71a2 100644 --- a/src/renderer/shaders/quad.vert +++ b/src/renderer/shaders/quad.vert @@ -3,24 +3,54 @@ layout(location = 0) in vec3 pos; layout(location = 1) in vec2 tex_coords; layout(location = 2) in vec4 color; -layout(location = 3) in int tex_slot; +layout(location = 3) in float tex_slot; layout(location = 4) in vec3 translation; layout(location = 5) in float angle; layout(location = 6) in vec3 scale; -//out vec2 TexCoords; -out vec4 vert_color; +layout (location = 0) out vec2 f_tex_coords; +layout (location = 1) out vec4 f_vert_color; +layout (location = 2) flat out int f_tex_index; uniform mat4 projview; void main() { - vert_color = color; - mat4 ModelTrans = mat4( - vec4( scale.x * cos(angle), scale.x * -sin(angle), 0.0, 0.0), - vec4( scale.y * sin(angle), scale.y * cos(angle), 0.0, 0.0), - vec4( 0.0, 0.0, scale.z, 0.0), - vec4( translation.xyz, 1.0) -); - gl_Position = projview * ModelTrans * vec4(pos, 1.0); + f_tex_index = int(tex_slot); + f_tex_coords = tex_coords; + f_vert_color = color; + // mat4 ModelTrans = mat4( + // vec4( scale.x * cos(angle), scale.x * -sin(angle), 0.0, 0.0), + // vec4( scale.y * sin(angle), scale.y * cos(angle), 0.0, 0.0), + // vec4( 0.0, 0.0, scale.z, 0.0), + // vec4( translation.xyz, 1.0) + // ); + + mat4 Translation = mat4( + vec4( 1.0, 0.0, 0.0, 0.0), + vec4( 0.0, 1.0, 0.0, 0.0), + vec4( 0.0, 0.0, 1.0, 0.0), + vec4( translation.xyz, 1.0)); + + mat4 Rotation = mat4( + vec4( cos(angle), -sin(angle), 0.0, 0.0), + vec4( sin(angle), cos(angle), 0.0, 0.0), + vec4( 0.0, 0.0, 1.0, 0.0), + vec4( 0.0, 0.0, 0.0, 1.0)); + + mat4 Scale = mat4( + vec4(scale.x, 0.0, 0.0, 0.0), + vec4(0.0, scale.y, 0.0, 0.0), + vec4(0.0, 0.0,scale.z, 0.0), + vec4(0.0, 0.0, 0.0, 1.0)); + + // mat4 model = Translation * RotationScale; + //gl_Position = Translation * vec4(pos, 1.0); + + mat4 model = mat4( vec4(1.0, 0.0, 0.0, 0.0), vec4(0.0, 1.0, 0.0, 0.0), vec4(0.0, 0.0, 1.0, 0.0), vec4(0.0, 0.0, 0.0, 1.0)); + model = model * Translation; + model = model * Rotation; + model = model * Scale; + + gl_Position = projview * model * vec4(pos, 1.0); } \ No newline at end of file diff --git a/src/renderer/texture.cpp b/src/renderer/texture.cpp index acc2be0..99dcb7d 100644 --- a/src/renderer/texture.cpp +++ b/src/renderer/texture.cpp @@ -64,8 +64,9 @@ namespace lunarium void Texture::Bind(u32 slot) const { - glBindTextureUnit(slot, mGLID); - + // glBindTextureUnit(slot, mGLID); + glActiveTexture(slot + GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, mGLID); } void Texture::Unbind() const diff --git a/src/run_modes/testbed/scenes/simple_render_scene.cpp b/src/run_modes/testbed/scenes/simple_render_scene.cpp index d79e287..63f6915 100644 --- a/src/run_modes/testbed/scenes/simple_render_scene.cpp +++ b/src/run_modes/testbed/scenes/simple_render_scene.cpp @@ -18,6 +18,9 @@ #include #include +#include +#include + #include #include @@ -49,18 +52,30 @@ namespace lunarium mFrameBufferTwo = FrameBuffer::Create(1024, 1024); //Core::Graphics().CreateRenderTexture(1024, 1024, 4); // Load test image - // int w, h, n; - // stbi_set_flip_vertically_on_load(1); - // unsigned char* buffer = stbi_load("LinkToThePast1_sized.png", &w, &h, &n, 0); - - // TextureFormat format = TextureFormat::RGBA; - // if (n == 3) - // { - // format = TextureFormat::RGB; - // } - // mpTestImageLoad = Texture::Create(buffer, w, h, format); - // mSrcWidth = w; - // mSrcHeight = h; + int w, h, n; + stbi_set_flip_vertically_on_load(1); + unsigned char* buffer = stbi_load("LinkToThePast1_sized.png", &w, &h, &n, 0); + + TextureFormat format = TextureFormat::RGBA; + if (n == 3) + { + format = TextureFormat::RGB; + } + mpTestImageLoad = Texture::Create(buffer, w, h, format); + mSrcWidth = w; + mSrcHeight = h; + + //delete[] buffer; + stbi_set_flip_vertically_on_load(1); + buffer = stbi_load("lunarium_test_image.png", &w, &h, &n, 0); + + format = TextureFormat::RGBA; + if (n == 3) + { + format = TextureFormat::RGB; + } + mpTestImageLoad2 = Texture::Create(buffer, w, h, format); + //delete[] buffer; mQuads = new Rectangle[NUM_QUADS]; for (int i = 0; i < NUM_QUADS; i++) @@ -74,9 +89,11 @@ namespace lunarium } mQuadColors = new Color[NUM_QUADS]; + mQuadTexures = new Texture*[NUM_QUADS]; for (int i = 0; i < NUM_QUADS; i++) { + mQuadTexures[i] = (i % 2 == 0) ? mpTestImageLoad : mpTestImageLoad2; mQuadColors[i].R = ((float)(rand() % 10000)) / 10000.0f; mQuadColors[i].G = ((float)(rand() % 10000)) / 10000.0f; mQuadColors[i].B = ((float)(rand() % 10000)) / 10000.0f; @@ -198,13 +215,14 @@ namespace lunarium // g.DrawQuad(Rectangle(300, 300, 150, 150), Color::Red()); + // g.DrawQuad(Rectangle(200, 300, 100, 100), Color(0.2f, 0.5f, 0.4f, 1.0f), nullptr, 45.0f); // //g.DrawFilledEllipse(glm::vec2(600, 300), glm::vec2(100, 150), Color(1.0f, 0.0f, 1.0f, 1.0f), 100); // // g.DrawString("This is a test of the text renderer!", Rectangle::MakeFromTopLeft(100, 200, mTextBoxWidth, 300), // // Color(0.0f, 1.0f, 1.0f, 1.0f), 0.5f, g.DefaultFont()); // //mpRenderedImage = Core::GetInstance().EndRenderToTexture(); // g.EndDraw(); - mpRenderedImage = mFrameBufferOne->GetTexture(); + // mpRenderedImage = mFrameBufferOne->GetTexture(); box_angle += 0.01f; int w, h; @@ -232,6 +250,7 @@ namespace lunarium mNumFrames++; mRenderStats = Core::Graphics().GetFrameStats(); Core::Graphics().ResetFrameStats(); + //std::this_thread::sleep_for (std::chrono::seconds(2)); } void SimpleRenderScene::RenderScene(Renderer2D& g) @@ -264,17 +283,19 @@ namespace lunarium void SimpleRenderScene::RenderBatchStressTest(Renderer2D& g) { - for (int i = 0; i < NUM_QUADS; i++) + for (int i = 0; i < mNumQuadsToRender; i++) { - g.DrawQuad(mQuads[i], mQuadColors[i], nullptr, box_angle + (i / 10.0f)); + Texture* t = mUseTextures ? mQuadTexures[i] : nullptr; + g.DrawQuad(mQuads[i], mQuadColors[i], t, box_angle + (i / 10.0f)); } + } void SimpleRenderScene::DrawStatsGUI() { ImGui::SetNextWindowPos(ImVec2(0, 0), ImGuiCond_FirstUseEver); - ImGui::SetNextWindowSize(ImVec2(400, 300)); + ImGui::SetNextWindowSize(ImVec2(400, 600)); ImGui::Begin("RENDER INFO"); ImGui::BeginChild("Per Frame", ImVec2(ImGui::GetWindowSize().x - 15, ImGui::GetFrameHeightWithSpacing() * 3.5f), true); ImGui::Text("Per Frame"); @@ -282,12 +303,21 @@ namespace lunarium ImGui::Text("Number of triangles: %d", mRenderStats.NumTris); ImGui::Text("Draw calls: %d", mRenderStats.DrawCalls); ImGui::EndChild(); - ImGui::BeginChild("General", ImVec2(ImGui::GetWindowSize().x - 15, ImGui::GetFrameHeightWithSpacing() * 3.5f), true); + ImGui::BeginChild("General", ImVec2(ImGui::GetWindowSize().x - 15, ImGui::GetFrameHeightWithSpacing() * 4.5f), true); ImGui::Text("General Info"); ImGui::Separator(); - ImGui::Text("Average Render time: %f", mFrameTime/ mNumFrames); + ImGui::Text("Average Render time: %f", Core::GetInstance().GetFrameData().AverageFrameTime); ImGui::Text("FPS: %d", Core::GetInstance().GetFrameData().CurrentFPS); + ImGui::Text("Frame Number: %d", mNumFrames); + ImGui::EndChild(); + ImGui::BeginChild("Settings", ImVec2(ImGui::GetWindowSize().x - 15, ImGui::GetFrameHeightWithSpacing() * 3.5f), true); + ImGui::Text("Settings"); + ImGui::Separator(); + ImGui::InputInt("Number of Quads to draw", &mNumQuadsToRender); + ImGui::Checkbox("Draw Textures", &mUseTextures); ImGui::EndChild(); ImGui::End(); + + mNumQuadsToRender = Math::ClampI(mNumQuadsToRender, 0, NUM_QUADS); } } \ No newline at end of file diff --git a/src/run_modes/testbed/scenes/simple_render_scene.h b/src/run_modes/testbed/scenes/simple_render_scene.h index 77a38c2..bac9692 100644 --- a/src/run_modes/testbed/scenes/simple_render_scene.h +++ b/src/run_modes/testbed/scenes/simple_render_scene.h @@ -35,6 +35,7 @@ namespace lunarium Sizei mImageSize; Texture* mpRenderedImage; Texture* mpTestImageLoad; + Texture* mpTestImageLoad2; FrameBuffer* mFrameBufferOne; FrameBuffer* mFrameBufferTwo; float angle; @@ -50,9 +51,12 @@ namespace lunarium bool mStressTest; + int mNumQuadsToRender = 500; + bool mUseTextures = false; const int NUM_QUADS = 50000; Color* mQuadColors; Rectangle* mQuads; + Texture** mQuadTexures; struct GridTestObj {