[Refactor] (...): Optimize code file structure.

This commit is contained in:
BZLZHH
2025-05-01 09:22:50 +08:00
parent 8ab90e8e60
commit 04976daa9f
35 changed files with 65 additions and 66 deletions
+23 -24
View File
@@ -25,25 +25,35 @@ find_library(GLSLANG_LIB glslang PATHS ${CMAKE_SOURCE_DIR}/libraries/arm64-v8a/)
add_library(${CMAKE_PROJECT_NAME} SHARED
MG/Init.cpp
# MG_GL/GL
MG/MG_GL/GL/Getter/GL_Getter.cpp
MG/MG_GL/GL/Getter/BackendInfo.cpp
# MG_GL/Implementations/GL
MG/MG_GL/Implementations/GL/GLFuncsDefinitions/GLFuncsDefinitions.cpp
MG/MG_GL/GL/Framebuffer/GL_Framebuffer.cpp
MG/MG_GL/Implementations/GL/Getter/GL_Getter.cpp
MG/MG_GL/Implementations/GL/Getter/BackendInfo.cpp
MG/MG_GL/GL/Common/GL_Common.cpp
MG/MG_GL/Implementations/GL/Framebuffer/GL_Framebuffer.cpp
MG/MG_GL/GL/Buffer/GL_Buffer.cpp
MG/MG_GL/Implementations/GL/Common/GL_Common.cpp
MG/MG_GL/GL/Drawing/GL_Drawing.cpp
MG/MG_GL/Implementations/GL/Buffer/GL_Buffer.cpp
MG/MG_GL/GL/Program/GL_Program.cpp
MG/MG_GL/Implementations/GL/Drawing/GL_Drawing.cpp
MG/MG_GL/GL/Shader/GL_Shader.cpp
MG/MG_GL/Implementations/GL/Program/GL_Program.cpp
MG/MG_GL/GL/Texture/GL_Texture.cpp
MG/MG_GL/Implementations/GL/Shader/GL_Shader.cpp
MG/MG_GL/GL/VertexArray/GL_VertexArray.cpp
MG/MG_GL/Implementations/GL/Texture/GL_Texture.cpp
MG/MG_GL/Implementations/GL/VertexArray/GL_VertexArray.cpp
# MG_GL/Implementations/GLX
MG/MG_GL/Implementations/GLX/LookUp/LookUp.cpp
# MG_GL/Implementations/EGL
MG/MG_GL/Implementations/EGL/VK/EGL_EMU.cpp
MG/MG_GL/Implementations/EGL/GLES/EGL_WRAP.cpp
# MG_GL/State
MG/MG_GL/State/Core/GLState.cpp
@@ -52,23 +62,12 @@ add_library(${CMAKE_PROJECT_NAME} SHARED
MG/MG_GL/State/Texture/TextureState.cpp
# MG_GL/GLX
MG/MG_GL/GLX/LookUp/LookUp.cpp
# MG_GL/GL_Def
MG/MG_GL/GL_Def/GL_Def.cpp
# MG_GL/BackendLoader
MG/MG_GL/BackendLoader/GLES/Loader.cpp
# MG_UTIL/Debug
MG/MG_UTIL/Debug/Debug.cpp
# MG_GL/EGL
MG/MG_GL/EGL/VK/EGL_EMU.cpp
MG/MG_GL/EGL/GLES/EGL_WRAP.cpp
# MG_GL/BackendLoader
MG/MG_GL/BackendLoader/GLES/Loader.cpp
# MG_RHI/GLES
MG/MG_RHI/GLES/Test/TestDrawing.cpp
)
+1 -1
View File
@@ -27,7 +27,7 @@ namespace MG_Global {
}
namespace Common {
inline const int LogLevel = MG_Constants::Common::LOG_LEVEL_DEBUG;
inline const int LogLevel = MG_Constants::Common::LOG_LEVEL_INFO;
#ifdef __ANDROID__
inline const char* LOG_FILE_PATH = "/sdcard/MG/latest.log";
+14 -14
View File
@@ -9,31 +9,31 @@
#include "MG_GL/BackendLoader/GLES/Loader.h"
#endif
#ifndef MOBILEGL_GL_FRAMEBUFFER_H
#include "MG_GL/GL/Framebuffer/GL_Framebuffer.h"
#include "MG_GL/Implementations/GL/Framebuffer/GL_Framebuffer.h"
#endif
#ifndef MOBILEGL_GL_GETTER_H
#include "MG_GL/GL/Getter/GL_Getter.h"
#include "MG_GL/Implementations/GL/Getter/GL_Getter.h"
#endif
#ifndef MOBILEGL_BACKENDINFO_H
#include "MG_GL/GL/Getter/BackendInfo.h"
#include "MG_GL/Implementations/GL/Getter/BackendInfo.h"
#endif
#ifndef MOBILEGL_GL_BUFFER_H
#include "MG_GL/GL/Buffer/GL_Buffer.h"
#include "MG_GL/Implementations/GL/Buffer/GL_Buffer.h"
#endif
#ifndef MOBILEGL_GL_DRAWING_H
#include "MG_GL/GL/Drawing/GL_Drawing.h"
#include "MG_GL/Implementations/GL/Drawing/GL_Drawing.h"
#endif
#ifndef MOBILEGL_GL_PROGRAM_H
#include "MG_GL/GL/Program/GL_Program.h"
#include "MG_GL/Implementations/GL/Program/GL_Program.h"
#endif
#ifndef MOBILEGL_GL_SHADER_H
#include "MG_GL/GL/Shader/GL_Shader.h"
#include "MG_GL/Implementations/GL/Shader/GL_Shader.h"
#endif
#ifndef MOBILEGL_GL_TEXTURE_H
#include "MG_GL/GL/Texture/GL_Texture.h"
#include "MG_GL/Implementations/GL/Texture/GL_Texture.h"
#endif
#ifndef MOBILEGL_GL_VERTEXARRAY_H
#include "MG_GL/GL/VertexArray/GL_VertexArray.h"
#include "MG_GL/Implementations/GL/VertexArray/GL_VertexArray.h"
#endif
#ifndef MOBILEGL_GLSTATE_H
#include "MG_GL/State/Core/GLState.h"
@@ -45,19 +45,19 @@
#include "MG_GL/State/Texture/TextureState.h"
#endif
#ifndef MOBILEGL_LOOKUP_H
#include "MG_GL/GLX/LookUp/LookUp.h"
#include "MG_GL/Implementations/GLX/LookUp/LookUp.h"
#endif
#ifndef MOBILEGL_DEBUG_H
#include "MG_UTIL/Debug/Debug.h"
#endif
#ifndef MOBILEGL_GL_DEPTH_H
#include "MG_GL/GL/Common/GL_Common.h"
#ifndef MOBILEGL_GL_COMMON_H
#include "MG_GL/Implementations/GL/Common/GL_Common.h"
#endif
#ifndef MOBILEGL_EGL_VK_EMU_H
#include "MG_GL/EGL/VK/EGL_EMU.h"
#include "MG_GL/Implementations/EGL/VK/EGL_EMU.h"
#endif
#ifndef MOBILEGL_EGL_GLES_EGL_WRAP_H
#include "MG_GL/EGL/GLES/EGL_WRAP.h"
#include "MG_GL/Implementations/EGL/GLES/EGL_WRAP.h"
#endif
#ifndef MOBILEGL_TESTDRAWING_H
#include "MG_RHI/GLES/Test/TestDrawing.h"
+1
View File
@@ -6,6 +6,7 @@
#if BACKEND_TYPE == BACKEND_GLES
// TODO: Take this code file apart into multiple files.
#define GL_FUNC_DECL(name) \
name##_PTR name;
-10
View File
@@ -1,10 +0,0 @@
//
// Created by BZLZHH on 2025/3/15.
//
#ifndef MOBILEGL_GL_DEF_H
#define MOBILEGL_GL_DEF_H
#include "../../Includes.h"
#endif //MOBILEGL_GL_DEF_H
@@ -5,7 +5,7 @@
#ifndef MOBILEGL_EGL_GLES_EGL_WRAP_H
#define MOBILEGL_EGL_GLES_EGL_WRAP_H
#include "../../../Includes.h"
#include "../../../../Includes.h"
#if BACKEND_TYPE == BACKEND_GLES
@@ -5,7 +5,7 @@
#ifndef MOBILEGL_EGL_VK_EMU_H
#define MOBILEGL_EGL_VK_EMU_H
#include "../../../Includes.h"
#include "../../../../Includes.h"
#if BACKEND_TYPE == BACKEND_VULKAN
@@ -5,7 +5,7 @@
#ifndef MOBILEGL_GL_BUFFER_H
#define MOBILEGL_GL_BUFFER_H
#include "../../../Includes.h"
#include "../../../../Includes.h"
namespace MG_GL::GL {
@@ -5,7 +5,7 @@
#ifndef MOBILEGL_GL_COMMON_H
#define MOBILEGL_GL_COMMON_H
#include "../../../Includes.h"
#include "../../../../Includes.h"
namespace MG_GL::GL {
void ClearDepth(::GLdouble depth);
@@ -5,7 +5,7 @@
#ifndef MOBILEGL_GL_DRAWING_H
#define MOBILEGL_GL_DRAWING_H
#include "../../../Includes.h"
#include "../../../../Includes.h"
namespace MG_GL::GL {
void DrawElements(GLenum mode, GLsizei count, GLenum type, const void *indices);
@@ -5,7 +5,7 @@
#ifndef MOBILEGL_GL_FRAMEBUFFER_H
#define MOBILEGL_GL_FRAMEBUFFER_H
#include "../../../Includes.h"
#include "../../../../Includes.h"
namespace MG_GL::GL {
GLenum CheckFramebufferStatus(GLenum target);
@@ -2,7 +2,7 @@
// Created by BZLZHH on 2025/3/15.
//
#include "GL_Def.h"
#include "GLFuncsDefinitions.h"
#define DECLARE_GL_FUNCTION_STUB_HEAD(type,name,...) \
MG_EXPORT type gl##name(__VA_ARGS__) {
@@ -0,0 +1,10 @@
//
// Created by BZLZHH on 2025/3/15.
//
#ifndef MOBILEGL_GL_FUNCS_DEFINITIONS_H
#define MOBILEGL_GL_FUNCS_DEFINITIONS_H
#include "../../../../Includes.h"
#endif //MOBILEGL_GL_FUNCS_DEFINITIONS_H
@@ -5,7 +5,7 @@
#ifndef MOBILEGL_BACKENDINFO_H
#define MOBILEGL_BACKENDINFO_H
#include "../../../Includes.h"
#include "../../../../Includes.h"
namespace MG_GL::Getter {
const std::string GetBackendName();
@@ -5,7 +5,7 @@
#ifndef MOBILEGL_GL_GETTER_H
#define MOBILEGL_GL_GETTER_H
#include "../../../Includes.h"
#include "../../../../Includes.h"
namespace MG_GL::GL {
const ::GLubyte* GetString(GLenum name);
@@ -5,7 +5,7 @@
#ifndef MOBILEGL_GL_PROGRAM_H
#define MOBILEGL_GL_PROGRAM_H
#include "../../../Includes.h"
#include "../../../../Includes.h"
namespace MG_GL::GL {
void GetProgramiv(GLuint program, GLenum pname, GLint *params);
@@ -5,7 +5,7 @@
#ifndef MOBILEGL_GL_SHADER_H
#define MOBILEGL_GL_SHADER_H
#include "../../../Includes.h"
#include "../../../../Includes.h"
namespace MG_GL::GL {
void GetShaderiv(GLuint shader, GLenum pname, GLint *params);
@@ -5,7 +5,7 @@
#ifndef MOBILEGL_GL_TEXTURE_H
#define MOBILEGL_GL_TEXTURE_H
#include "../../../Includes.h"
#include "../../../../Includes.h"
namespace MG_GL::GL {
void ActiveTexture(GLenum texture);
@@ -5,7 +5,7 @@
#ifndef MOBILEGL_GL_VERTEXARRAY_H
#define MOBILEGL_GL_VERTEXARRAY_H
#include "../../../Includes.h"
#include "../../../../Includes.h"
namespace MG_GL::GL {
@@ -4,9 +4,7 @@
#include "LookUp.h"
#include "../../../Includes.h"
#define DEBUG 0
#include "../../../../Includes.h"
namespace MG_GL::GLX {
void* GetProcAddress(const char *name) {
+1 -1
View File
@@ -12,7 +12,7 @@ struct MG_State_T {
static TextureState* textureState;
static CommonState* commonState;
};
namespace MG_State {
extern MG_State_T* MG_State_O;
+1
View File
@@ -37,6 +37,7 @@ namespace MG_RHI::GLES::Test {
return true;
}
// TODO: Use the textures state from MG_RHI(another state?) rather than directly from MG_State
void DrawAllTextures() {
::GLES::glClearColor(1,1,1,1);
::GLES::glClear(GL_COLOR_BUFFER_BIT);