diff --git a/include/boo/graphicsdev/IGraphicsCommandQueue.hpp b/include/boo/graphicsdev/IGraphicsCommandQueue.hpp index ae5fd6a..f3c0c72 100644 --- a/include/boo/graphicsdev/IGraphicsCommandQueue.hpp +++ b/include/boo/graphicsdev/IGraphicsCommandQueue.hpp @@ -23,7 +23,8 @@ struct IGraphicsCommandQueue virtual void setShaderDataBinding(IShaderDataBinding* binding)=0; virtual void setRenderTarget(ITextureR* target)=0; virtual void setViewport(const SWindowRect& rect)=0; - + virtual void setScissor(const SWindowRect& rect)=0; + /** * @brief Which dynamic buffer slot is being populated for pending command list * @return Index [0,2] indicating the buffer slot diff --git a/include/boo/graphicsdev/IGraphicsDataFactory.hpp b/include/boo/graphicsdev/IGraphicsDataFactory.hpp index 4878cee..32e978d 100644 --- a/include/boo/graphicsdev/IGraphicsDataFactory.hpp +++ b/include/boo/graphicsdev/IGraphicsDataFactory.hpp @@ -101,10 +101,13 @@ struct IVertexFormat {}; enum class VertexSemantic { None = 0, - Position, - Normal, + Position3, + Position4, + Normal3, + Normal4, Color, - UV, + ColorUNorm, + UV2, UV4, Weight, ModelView, diff --git a/lib/graphicsdev/GL.cpp b/lib/graphicsdev/GL.cpp index b1374ed..4f69449 100644 --- a/lib/graphicsdev/GL.cpp +++ b/lib/graphicsdev/GL.cpp @@ -554,10 +554,14 @@ static const GLint SEMANTIC_COUNT_TABLE[] = { 0, 3, + 4, 3, 4, + 4, + 4, 2, 4, + 4, 4 }; @@ -565,10 +569,14 @@ static const size_t SEMANTIC_SIZE_TABLE[] = { 0, 12, + 16, 12, + 16, + 16, 4, 8, 16, + 16, 16 }; @@ -577,9 +585,13 @@ static const GLenum SEMANTIC_TYPE_TABLE[] = GL_INVALID_ENUM, GL_FLOAT, GL_FLOAT, + GL_FLOAT, + GL_FLOAT, + GL_FLOAT, GL_UNSIGNED_BYTE, GL_FLOAT, GL_FLOAT, + GL_FLOAT, GL_FLOAT }; @@ -596,6 +608,7 @@ struct GLCommandQueue : IGraphicsCommandQueue SetShaderDataBinding, SetRenderTarget, SetViewport, + SetScissor, SetClearColor, ClearTarget, SetDrawPrimitive, @@ -791,6 +804,16 @@ struct GLCommandQueue : IGraphicsCommandQueue glViewport(cmd.rect.location[0], cmd.rect.location[1], cmd.rect.size[0], cmd.rect.size[1]); break; + case Command::Op::SetScissor: + if (cmd.rect.size[0] == 0 && cmd.rect.size[1] == 0) + glDisable(GL_SCISSOR_TEST); + else + { + glEnable(GL_SCISSOR_TEST); + glScissor(cmd.rect.location[0], cmd.rect.location[1], + cmd.rect.size[0], cmd.rect.size[1]); + } + break; case Command::Op::SetClearColor: glClearColor(cmd.rgba[0], cmd.rgba[1], cmd.rgba[2], cmd.rgba[3]); break; @@ -868,6 +891,13 @@ struct GLCommandQueue : IGraphicsCommandQueue cmds.emplace_back(Command::Op::SetViewport); cmds.back().rect = rect; } + + void setScissor(const SWindowRect& rect) + { + std::vector& cmds = m_cmdBufs[m_fillBuf]; + cmds.emplace_back(Command::Op::SetScissor); + cmds.back().rect = rect; + } int pendingDynamicSlot() { diff --git a/test/main.cpp b/test/main.cpp index fd46f30..81cd880 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -256,8 +256,8 @@ struct TestApplicationCallback : IApplicationCallback /* Make vertex format */ VertexElementDescriptor descs[2] = { - {vbo, nullptr, VertexSemantic::Position}, - {vbo, nullptr, VertexSemantic::UV} + {vbo, nullptr, VertexSemantic::Position3}, + {vbo, nullptr, VertexSemantic::UV2} }; IVertexFormat* vfmt = factory->newVertexFormat(2, descs);