| 1 | // This file can be included several times. |
| 2 | #if (!defined(BACKEND_AS_OPENGL_ES) && !defined(ENGINE_CLIENT_BACKEND_OPENGL_BACKEND_OPENGL3_H)) || \ |
| 3 | (defined(BACKEND_AS_OPENGL_ES) && !defined(ENGINE_CLIENT_BACKEND_OPENGL_BACKEND_OPENGL3_H_AS_ES)) |
| 4 | |
| 5 | #if !defined(BACKEND_AS_OPENGL_ES) && !defined(ENGINE_CLIENT_BACKEND_OPENGL_BACKEND_OPENGL3_H) |
| 6 | #define ENGINE_CLIENT_BACKEND_OPENGL_BACKEND_OPENGL3_H |
| 7 | #endif |
| 8 | |
| 9 | #if defined(BACKEND_AS_OPENGL_ES) && !defined(ENGINE_CLIENT_BACKEND_OPENGL_BACKEND_OPENGL3_H_AS_ES) |
| 10 | #define ENGINE_CLIENT_BACKEND_OPENGL_BACKEND_OPENGL3_H_AS_ES |
| 11 | #endif |
| 12 | |
| 13 | #include "backend_opengl.h" |
| 14 | |
| 15 | class CGLSLPrimitiveExProgram; |
| 16 | class CGLSLQuadProgram; |
| 17 | class CGLSLSpriteMultipleProgram; |
| 18 | class CGLSLTextProgram; |
| 19 | |
| 20 | #define MAX_STREAM_BUFFER_COUNT 10 |
| 21 | |
| 22 | // takes care of opengl 3.3+ related rendering |
| 23 | class CCommandProcessorFragment_OpenGL3_3 : public CCommandProcessorFragment_OpenGL3 |
| 24 | { |
| 25 | protected: |
| 26 | int m_MaxQuadsAtOnce; |
| 27 | static const int ms_MaxQuadsPossible = 256; |
| 28 | |
| 29 | CGLSLPrimitiveProgram *m_pPrimitiveProgram; |
| 30 | CGLSLPrimitiveProgram *m_pPrimitiveProgramTextured; |
| 31 | CGLSLQuadProgram *m_pQuadProgram; |
| 32 | CGLSLQuadProgram *m_pQuadProgramTextured; |
| 33 | CGLSLQuadProgram *m_pQuadProgramGrouped; |
| 34 | CGLSLQuadProgram *m_pQuadProgramTexturedGrouped; |
| 35 | CGLSLTextProgram *m_pTextProgram; |
| 36 | CGLSLPrimitiveExProgram *m_pPrimitiveExProgram; |
| 37 | CGLSLPrimitiveExProgram *m_pPrimitiveExProgramTextured; |
| 38 | CGLSLPrimitiveExProgram *m_pPrimitiveExProgramRotationless; |
| 39 | CGLSLPrimitiveExProgram *m_pPrimitiveExProgramTexturedRotationless; |
| 40 | CGLSLSpriteMultipleProgram *m_pSpriteProgramMultiple; |
| 41 | |
| 42 | TWGLuint m_LastProgramId; |
| 43 | |
| 44 | TWGLuint m_aPrimitiveDrawVertexId[MAX_STREAM_BUFFER_COUNT]; |
| 45 | TWGLuint m_PrimitiveDrawVertexIdTex3D; |
| 46 | TWGLuint m_aPrimitiveDrawBufferId[MAX_STREAM_BUFFER_COUNT]; |
| 47 | TWGLuint m_PrimitiveDrawBufferIdTex3D; |
| 48 | |
| 49 | TWGLuint m_aLastIndexBufferBound[MAX_STREAM_BUFFER_COUNT]; |
| 50 | |
| 51 | int m_LastStreamBuffer; |
| 52 | |
| 53 | TWGLuint m_QuadDrawIndexBufferId; |
| 54 | unsigned int m_CurrentIndicesInBuffer; |
| 55 | |
| 56 | void DestroyBufferContainer(int Index, bool DeleteBOs = true); |
| 57 | |
| 58 | void AppendIndices(unsigned int NewIndicesCount); |
| 59 | |
| 60 | struct SBufferContainer |
| 61 | { |
| 62 | SBufferContainer() : |
| 63 | m_VertArrayId(0), m_LastIndexBufferBound(0) {} |
| 64 | TWGLuint m_VertArrayId; |
| 65 | TWGLuint m_LastIndexBufferBound; |
| 66 | SBufferContainerInfo m_ContainerInfo; |
| 67 | }; |
| 68 | std::vector<SBufferContainer> m_vBufferContainers; |
| 69 | |
| 70 | std::vector<TWGLuint> m_vBufferObjectIndices; |
| 71 | |
| 72 | CCommandBuffer::SColorf m_ClearColor; |
| 73 | |
| 74 | void InitPrimExProgram(CGLSLPrimitiveExProgram *pProgram, class CGLSLCompiler *pCompiler, class IStorage *pStorage, bool Textured, bool Rotationless); |
| 75 | |
| 76 | bool IsNewApi() override { return true; } |
| 77 | |
| 78 | void UseProgram(CGLSLTWProgram *pProgram); |
| 79 | void UploadStreamBufferData(EPrimitiveType PrimitiveType, const void *pVertices, size_t VertSize, unsigned int PrimitiveCount, bool AsTex3D = false); |
| 80 | void RenderText(const CCommandBuffer::SState &State, int DrawNum, int TextTextureIndex, int TextOutlineTextureIndex, int TextureSize, const ColorRGBA &TextColor, const ColorRGBA &TextOutlineColor); |
| 81 | |
| 82 | void TextureUpdate(int Slot, int X, int Y, int Width, int Height, int GLFormat, uint8_t *pTexData); |
| 83 | void TextureCreate(int Slot, int Width, int Height, int GLFormat, int GLStoreFormat, int Flags, uint8_t *pTexData); |
| 84 | |
| 85 | bool Cmd_Init(const SCommand_Init *pCommand) override; |
| 86 | void Cmd_Shutdown(const SCommand_Shutdown *pCommand) override; |
| 87 | void Cmd_Texture_Destroy(const CCommandBuffer::SCommand_Texture_Destroy *pCommand) override; |
| 88 | void Cmd_Texture_Create(const CCommandBuffer::SCommand_Texture_Create *pCommand) override; |
| 89 | void Cmd_TextTexture_Update(const CCommandBuffer::SCommand_TextTexture_Update *pCommand) override; |
| 90 | void Cmd_TextTextures_Destroy(const CCommandBuffer::SCommand_TextTextures_Destroy *pCommand) override; |
| 91 | void Cmd_TextTextures_Create(const CCommandBuffer::SCommand_TextTextures_Create *pCommand) override; |
| 92 | void Cmd_Clear(const CCommandBuffer::SCommand_Clear *pCommand) override; |
| 93 | void Cmd_Render(const CCommandBuffer::SCommand_Render *pCommand) override; |
| 94 | void Cmd_RenderTex3D(const CCommandBuffer::SCommand_RenderTex3D *pCommand) override; |
| 95 | |
| 96 | void Cmd_CreateBufferObject(const CCommandBuffer::SCommand_CreateBufferObject *pCommand) override; |
| 97 | void Cmd_RecreateBufferObject(const CCommandBuffer::SCommand_RecreateBufferObject *pCommand) override; |
| 98 | void Cmd_UpdateBufferObject(const CCommandBuffer::SCommand_UpdateBufferObject *pCommand) override; |
| 99 | void Cmd_CopyBufferObject(const CCommandBuffer::SCommand_CopyBufferObject *pCommand) override; |
| 100 | void Cmd_DeleteBufferObject(const CCommandBuffer::SCommand_DeleteBufferObject *pCommand) override; |
| 101 | |
| 102 | void Cmd_CreateBufferContainer(const CCommandBuffer::SCommand_CreateBufferContainer *pCommand) override; |
| 103 | void Cmd_UpdateBufferContainer(const CCommandBuffer::SCommand_UpdateBufferContainer *pCommand) override; |
| 104 | void Cmd_DeleteBufferContainer(const CCommandBuffer::SCommand_DeleteBufferContainer *pCommand) override; |
| 105 | void Cmd_IndicesRequiredNumNotify(const CCommandBuffer::SCommand_IndicesRequiredNumNotify *pCommand) override; |
| 106 | |
| 107 | void Cmd_RenderTileLayer(const CCommandBuffer::SCommand_RenderTileLayer *pCommand) override; |
| 108 | void Cmd_RenderBorderTile(const CCommandBuffer::SCommand_RenderBorderTile *pCommand) override; |
| 109 | void Cmd_RenderQuadLayer(const CCommandBuffer::SCommand_RenderQuadLayer *pCommand, bool Grouped) override; |
| 110 | void Cmd_RenderText(const CCommandBuffer::SCommand_RenderText *pCommand) override; |
| 111 | void Cmd_RenderQuadContainer(const CCommandBuffer::SCommand_RenderQuadContainer *pCommand) override; |
| 112 | void Cmd_RenderQuadContainerEx(const CCommandBuffer::SCommand_RenderQuadContainerEx *pCommand) override; |
| 113 | void Cmd_RenderQuadContainerAsSpriteMultiple(const CCommandBuffer::SCommand_RenderQuadContainerAsSpriteMultiple *pCommand) override; |
| 114 | |
| 115 | public: |
| 116 | CCommandProcessorFragment_OpenGL3_3() = default; |
| 117 | }; |
| 118 | |
| 119 | #endif |
| 120 | |