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 | CGLSLTextProgram *m_pTextProgram; |
34 | CGLSLPrimitiveExProgram *m_pPrimitiveExProgram; |
35 | CGLSLPrimitiveExProgram *m_pPrimitiveExProgramTextured; |
36 | CGLSLPrimitiveExProgram *m_pPrimitiveExProgramRotationless; |
37 | CGLSLPrimitiveExProgram *m_pPrimitiveExProgramTexturedRotationless; |
38 | CGLSLSpriteMultipleProgram *m_pSpriteProgramMultiple; |
39 | |
40 | TWGLuint m_LastProgramId; |
41 | |
42 | TWGLuint m_aPrimitiveDrawVertexId[MAX_STREAM_BUFFER_COUNT]; |
43 | TWGLuint m_PrimitiveDrawVertexIdTex3D; |
44 | TWGLuint m_aPrimitiveDrawBufferId[MAX_STREAM_BUFFER_COUNT]; |
45 | TWGLuint m_PrimitiveDrawBufferIdTex3D; |
46 | |
47 | TWGLuint m_aLastIndexBufferBound[MAX_STREAM_BUFFER_COUNT]; |
48 | |
49 | int m_LastStreamBuffer; |
50 | |
51 | TWGLuint m_QuadDrawIndexBufferId; |
52 | unsigned int m_CurrentIndicesInBuffer; |
53 | |
54 | void DestroyBufferContainer(int Index, bool DeleteBOs = true); |
55 | |
56 | void AppendIndices(unsigned int NewIndicesCount); |
57 | |
58 | struct SBufferContainer |
59 | { |
60 | SBufferContainer() : |
61 | m_VertArrayId(0), m_LastIndexBufferBound(0) {} |
62 | TWGLuint m_VertArrayId; |
63 | TWGLuint m_LastIndexBufferBound; |
64 | SBufferContainerInfo m_ContainerInfo; |
65 | }; |
66 | std::vector<SBufferContainer> m_vBufferContainers; |
67 | |
68 | std::vector<TWGLuint> m_vBufferObjectIndices; |
69 | |
70 | CCommandBuffer::SColorf m_ClearColor; |
71 | |
72 | void InitPrimExProgram(CGLSLPrimitiveExProgram *pProgram, class CGLSLCompiler *pCompiler, class IStorage *pStorage, bool Textured, bool Rotationless); |
73 | |
74 | bool IsNewApi() override { return true; } |
75 | |
76 | void UseProgram(CGLSLTWProgram *pProgram); |
77 | void UploadStreamBufferData(unsigned int PrimitiveType, const void *pVertices, size_t VertSize, unsigned int PrimitiveCount, bool AsTex3D = false); |
78 | void RenderText(const CCommandBuffer::SState &State, int DrawNum, int TextTextureIndex, int TextOutlineTextureIndex, int TextureSize, const ColorRGBA &TextColor, const ColorRGBA &TextOutlineColor); |
79 | |
80 | void TextureUpdate(int Slot, int X, int Y, int Width, int Height, int GLFormat, uint8_t *pTexData); |
81 | void TextureCreate(int Slot, int Width, int Height, int GLFormat, int GLStoreFormat, int Flags, uint8_t *pTexData); |
82 | |
83 | bool Cmd_Init(const SCommand_Init *pCommand) override; |
84 | void Cmd_Shutdown(const SCommand_Shutdown *pCommand) override; |
85 | void Cmd_Texture_Update(const CCommandBuffer::SCommand_Texture_Update *pCommand) override; |
86 | void Cmd_Texture_Destroy(const CCommandBuffer::SCommand_Texture_Destroy *pCommand) override; |
87 | void Cmd_Texture_Create(const CCommandBuffer::SCommand_Texture_Create *pCommand) override; |
88 | void Cmd_TextTexture_Update(const CCommandBuffer::SCommand_TextTexture_Update *pCommand) override; |
89 | void Cmd_TextTextures_Destroy(const CCommandBuffer::SCommand_TextTextures_Destroy *pCommand) override; |
90 | void Cmd_TextTextures_Create(const CCommandBuffer::SCommand_TextTextures_Create *pCommand) override; |
91 | void Cmd_Clear(const CCommandBuffer::SCommand_Clear *pCommand) override; |
92 | void Cmd_Render(const CCommandBuffer::SCommand_Render *pCommand) override; |
93 | void Cmd_RenderTex3D(const CCommandBuffer::SCommand_RenderTex3D *pCommand) override; |
94 | |
95 | void Cmd_CreateBufferObject(const CCommandBuffer::SCommand_CreateBufferObject *pCommand) override; |
96 | void Cmd_RecreateBufferObject(const CCommandBuffer::SCommand_RecreateBufferObject *pCommand) override; |
97 | void Cmd_UpdateBufferObject(const CCommandBuffer::SCommand_UpdateBufferObject *pCommand) override; |
98 | void Cmd_CopyBufferObject(const CCommandBuffer::SCommand_CopyBufferObject *pCommand) override; |
99 | void Cmd_DeleteBufferObject(const CCommandBuffer::SCommand_DeleteBufferObject *pCommand) override; |
100 | |
101 | void Cmd_CreateBufferContainer(const CCommandBuffer::SCommand_CreateBufferContainer *pCommand) override; |
102 | void Cmd_UpdateBufferContainer(const CCommandBuffer::SCommand_UpdateBufferContainer *pCommand) override; |
103 | void Cmd_DeleteBufferContainer(const CCommandBuffer::SCommand_DeleteBufferContainer *pCommand) override; |
104 | void Cmd_IndicesRequiredNumNotify(const CCommandBuffer::SCommand_IndicesRequiredNumNotify *pCommand) override; |
105 | |
106 | void Cmd_RenderTileLayer(const CCommandBuffer::SCommand_RenderTileLayer *pCommand) override; |
107 | void Cmd_RenderBorderTile(const CCommandBuffer::SCommand_RenderBorderTile *pCommand) override; |
108 | void Cmd_RenderQuadLayer(const CCommandBuffer::SCommand_RenderQuadLayer *pCommand) override; |
109 | void Cmd_RenderText(const CCommandBuffer::SCommand_RenderText *pCommand) override; |
110 | void Cmd_RenderQuadContainer(const CCommandBuffer::SCommand_RenderQuadContainer *pCommand) override; |
111 | void Cmd_RenderQuadContainerEx(const CCommandBuffer::SCommand_RenderQuadContainerEx *pCommand) override; |
112 | void Cmd_RenderQuadContainerAsSpriteMultiple(const CCommandBuffer::SCommand_RenderQuadContainerAsSpriteMultiple *pCommand) override; |
113 | |
114 | public: |
115 | CCommandProcessorFragment_OpenGL3_3() = default; |
116 | }; |
117 | |
118 | #endif |
119 | |