Compare commits

..
18 changed files with 1260 additions and 166 deletions
-5
View File
@@ -1,5 +0,0 @@
################################################################################
# 此 .gitignore 文件已由 Microsoft(R) Visual Studio 自动创建。
################################################################################
/build
+1 -4
View File
@@ -10,7 +10,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w -fvisibility=hidden -funwind-tables -g -D_THREAD_SAFE -fPIC -stdlib=libc++")
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w -g -std=gnu99 -funwind-tables -O3 -fvisibility=hidden")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w -g -std=gnu99 -funwind-tables -O3 -fvisibility=hidden")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++")
@@ -25,9 +25,6 @@ find_library(GLSLANG_LIB glslang PATHS ${CMAKE_SOURCE_DIR}/libraries/arm64-v8a/)
add_library(${CMAKE_PROJECT_NAME} SHARED
MG/Init.cpp
# MG_GL/Implementations/GLX
MG/MG_GL/Implementations/GLX/GLXFuncsDefinitions/GLXFuncsDefinitions.cpp
# MG_GL/Implementations/GL
MG/MG_GL/Implementations/GL/GLFuncsDefinitions/GLFuncsDefinitions.cpp
+7 -14
View File
@@ -31,18 +31,11 @@ namespace ankerl {
namespace MG_Constants {
namespace Common {
inline constexpr int LOG_LEVEL_DEBUG = 0x0010;
inline constexpr int LOG_LEVEL_WARN = 0x0011;
inline constexpr int LOG_LEVEL_ERROR = 0x0012;
inline constexpr int LOG_LEVEL_INFO = 0x0013;
inline constexpr int LOG_LEVEL_FATAL = 0x0014;
inline constexpr int LOG_TARGET_NONE = 0x00;
inline constexpr int LOG_TARGET_CONSOLE = 0x01;
inline constexpr int LOG_TARGET_FILE = 0x02;
inline constexpr int LOG_TARGET_ANDROID = 0x04; // Android logcat
inline constexpr int LOG_TARGET_ALL = LOG_TARGET_CONSOLE | LOG_TARGET_FILE | LOG_TARGET_ANDROID;
inline const int LOG_LEVEL_DEBUG = 0x0010;
inline const int LOG_LEVEL_WARN = 0x0011;
inline const int LOG_LEVEL_ERROR = 0x0012;
inline const int LOG_LEVEL_INFO = 0x0013;
inline const int LOG_LEVEL_FATAL = 0x0014;
}
namespace Blend {
@@ -182,8 +175,8 @@ namespace MG_Constants {
namespace Backend {
#define BACKEND_VULKAN 0x0015
#define BACKEND_METAL 0x0016
#define BACKEND_GLES 0x0017
#define BACKEND_METAL 0x0016
#define BACKEND_GLES 0x0017
}
inline const char* RenderName = "MobileGL";
+8 -9
View File
@@ -9,11 +9,11 @@
namespace MG_Global {
namespace MG {
inline const int VersionMajor = 1;
inline const int VersionMinor = 0;
inline const int VersionRevision = 0;
inline const int VersionPatch = 0;
inline const std::string VersionSuffix = "-Dev";
inline const int VersionMajor = 1;
inline const int VersionMinor = 0;
inline const int VersionRevision = 0;
inline const int VersionPatch = 0;
inline const std::string VersionSuffix = "-ShittilyDraw";
}
namespace Backend {
@@ -21,14 +21,13 @@ namespace MG_Global {
}
namespace GL {
inline const int GLVersionMajor = 3;
inline const int GLVersionMinor = 2;
inline const int GLVersionMajor = 3;
inline const int GLVersionMinor = 2;
inline const int GLVersionRevision = 0;
}
namespace Common {
inline constexpr int LogLevel = MG_Constants::Common::LOG_LEVEL_INFO;
inline constexpr int LogTarget = MG_Constants::Common::LOG_TARGET_ALL;
inline constexpr int LogLevel = MG_Constants::Common::LOG_LEVEL_INFO;
#ifdef __ANDROID__
inline const char* LOG_FILE_PATH = "/sdcard/MG/latest.log";
-4
View File
@@ -113,10 +113,6 @@
#include "MG_Include/UncertainBool.hpp"
#ifdef _WIN32
#include <Windows.h>
#endif
#ifndef _WIN32
#include <dlfcn.h>
#include <unistd.h>
+3 -32
View File
@@ -4,43 +4,14 @@
#include "Includes.h"
void MG_Initialize() {
__attribute__((constructor)) void MG_Initialize() {
MG_Util::Debug::LogInit();
MG_Util::Debug::LogI("MobileGL Initializing...");
MG_State::Init();
MG_GL::BackendLoader::Init();
}
void MG_Destroy() {
__attribute__((destructor)) void MG_Destroy() {
MG_Util::Debug::LogI("MobileGL Exiting...");
MG_State::Destroy();
}
#if defined(__linux__) || defined(__APPLE__)
__attribute__((constructor)) static void AutoInit() {
MG_Initialize();
}
__attribute__((destructor)) static void AutoDestroy() {
MG_Destroy();
}
#endif
#ifdef _WIN32
BOOL WINAPI DllMain(HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
MG_Initialize();
break;
case DLL_PROCESS_DETACH:
MG_Destroy();
break;
}
return TRUE;
}
#endif
}
@@ -5,16 +5,6 @@
#include "GL_Common.h"
namespace MG_GL::GL {
void Clear(GLbitfield mask) {
MG_Util::Debug::LogD("glClear, mask: 0x%X", mask);
GLenum result = MG_State::glClear(mask);
if (result == GL_NO_ERROR) {
return;
}
MG_State::SetError(result);
MG_Util::Debug::LogE("Error clearing buffers: %s", MG_Util::Debug::GLEnumToString(result));
}
void Enable(GLenum cap) {
MG_Util::Debug::LogD("glEnable, cap: %s", MG_Util::Debug::GLEnumToString(cap));
GLenum result = MG_State::glEnable(cap);
File diff suppressed because it is too large Load Diff
@@ -5,7 +5,6 @@
#ifndef MOBILEGL_GL_DRAWING_H
#define MOBILEGL_GL_DRAWING_H
#include "../../../../Includes.h"
namespace MG_GL::GL {
void DrawElements(GLenum mode, GLsizei count, GLenum type, const void *indices);
void DrawArrays(GLenum mode, GLint first, GLsizei count);
@@ -65,9 +65,4 @@ namespace MG_GL::GL {
MG_Util::Debug::GLEnumToString(result));
return result;
}
void BlitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) {
// TODO
}
}
@@ -1,13 +0,0 @@
//
// Created by Swung 0x48 on 2025/6/20.
//
#include "GLXFuncsDefinitions.h"
MG_EXPORT void* glXGetProcAddress(const char *name) {
return MG_GL::GLX::GetProcAddress(name);
}
MG_EXPORT void* glXGetProcAddressARB(const char *name) {
return MG_GL::GLX::GetProcAddressARB(name);
}
@@ -1,10 +0,0 @@
//
// Created by Swung 0x48 on 2025/6/20.
//
#ifndef MOBILEGL_GLX_FUNCS_DEFINITIONS_H
#define MOBILEGL_GLX_FUNCS_DEFINITIONS_H
#include "../../../../Includes.h"
#endif //MOBILEGL_GLX_FUNCS_DEFINITIONS_H
@@ -8,7 +8,6 @@
namespace MG_GL::GLX {
void* GetProcAddress(const char *name) {
MG_Util::Debug::LogD("glXGetProcAddress(\"%s\")", name);
void* proc = dlsym(RTLD_DEFAULT, (const char*)name);
if (!proc) {
+6 -14
View File
@@ -71,22 +71,14 @@ namespace MG_Util::Debug {
std::string full_format = header + format + "\n";
#ifdef __ANDROID__
if (MG_Global::Common::LogTarget & MG_Constants::Common::LOG_TARGET_ANDROID) {
__android_log_vprint(androidLevel, MG_Constants::RenderName, full_format.c_str(), args);
}
__android_log_vprint(androidLevel, MG_Constants::RenderName, full_format.c_str(), args);
#endif
if (MG_Global::Common::LogTarget & MG_Constants::Common::LOG_TARGET_CONSOLE) {
vprintf(full_format.c_str(), args);
}
if ((MG_Global::Common::LogTarget & MG_Constants::Common::LOG_TARGET_FILE) &&
MG_Global::Common::LOG_FILE_PATH != nullptr) {
va_list args_copy;
va_copy(args_copy, args);
LogWrite(full_format.c_str(), args_copy);
va_end(args_copy);
}
vprintf(full_format.c_str(), args);
va_list args_copy;
va_copy(args_copy, args);
LogWrite(full_format.c_str(), args_copy);
va_end(args_copy);
}
#define DECLARE_LOG_FUNCTION(name, level) \
+11 -20
View File
@@ -4,7 +4,7 @@
- [x] glGetAttribLocation
- [x] glGetBufferParameteriv
- [x] glGetError
- [x] glGetIntegerv
- [ ] glGetIntegerv
- [x] glGetProgramiv
- [x] glGetShaderiv
- [x] glGetString
@@ -33,8 +33,6 @@
- [x] glFramebufferTexture2D
- [x] glGenFramebuffers
  ~~glBlitFramebuffer~~
---
### **4. Shader & Program Management**
@@ -62,10 +60,6 @@
- [x] glUnmapBuffer
- [x] glVertexAttribIPointer
- [x] glVertexAttribPointer
- [x] glBufferSubData
- [x] glMapBufferRange
- [x] glFlushMappedBufferRange
- [x] glCopyBufferSubData
---
@@ -96,27 +90,28 @@
---
### **8. Drawing Commands**
  ~~glDrawElements~~
- [ ] glDrawElements
- [ ] glDrawArrays
## Abstraction Layer (MG_RHI)
### **1. Initialization & Query Functions**
  ~~glGetAttribLocation~~
glGetAttribLocation~~
  ~~glGetBufferParameteriv~~
glGetBufferParameteriv~~
  ~~glGetError~~
glGetError~~
  ~~glGetIntegerv~~
- [ ] glGetIntegerv
- [ ] glGetProgramiv
- [ ] glGetShaderiv
- [ ] glGetString
- [ ] glGetStringi
  ~~glGetTexLevelParameteriv~~
glGetTexLevelParameteriv~~
  ~~glGetUniformLocation~~
glGetUniformLocation~~
---
@@ -138,7 +133,6 @@
- [ ] glDeleteFramebuffers
- [ ] glFramebufferTexture2D
- [ ] glGenFramebuffers
- [ ] glBlitFramebuffer
---
@@ -167,10 +161,6 @@
- [ ] glUnmapBuffer
- [ ] glVertexAttribIPointer
- [ ] glVertexAttribPointer
- [ ] glBufferSubData
- [ ] glMapBufferRange
- [ ] glFlushMappedBufferRange
- [ ] glCopyBufferSubData
---
@@ -201,4 +191,5 @@
---
### **8. Drawing Commands**
- [ ] glDrawElements
- [ ] glDrawElements
- [ ] glDrawArrays
+11 -18
View File
@@ -1,19 +1,12 @@
# MobileGL
> [!NOTE]
> **Important Note**: This project will undergo a complete redesign and rewrite in several weeks. The current implementation will be replaced completely.
## Third party components
**SPIRV-Cross** by **KhronosGroup** - [Apache License 2.0](https://github.com/KhronosGroup/SPIRV-Cross/blob/master/LICENSE): [github](https://github.com/KhronosGroup/SPIRV-Cross)
**SPIRV-Cross** by **KhronosGroup**: [github](https://github.com/KhronosGroup/SPIRV-Cross)
**glslang** by **KhronosGroup** - [Various Licenses](https://github.com/KhronosGroup/glslang/blob/main/LICENSE.txt): [github](https://github.com/KhronosGroup/glslang)
**glslang** by **KhronosGroup**: [github](https://github.com/KhronosGroup/glslang)
*(Unused Currently)* **GlslOptimizerV2** by **aiekick** - [Apache License 2.0](https://github.com/aiekick/GlslOptimizerV2/blob/master/LICENSE): [github](https://github.com/aiekick/GlslOptimizerV2)
**unordered_dense** by **Martin Leitner-Ankerl** - [MIT License](https://github.com/martinus/unordered_dense/blob/main/LICENSE): [github](https://github.com/martinus/unordered_dense)
**OpenGL Mathematics (*GLM*)** by **G-Truc Creation** - [MIT License](https://github.com/g-truc/glm/blob/master/copying.txt): [github](https://github.com/g-truc/glm)
**GlslOptimizerV2** by **aiekick**: [github](https://github.com/aiekick/GlslOptimizerV2)
## Progress
@@ -28,13 +21,13 @@
---
**Target**: **OpenGL implementation compatible with Minecraft 1.17 to 1.21.5**
**Target**: **OpenGL implementation compatible with Minecraft 1.17 to 1.21.1**
| Component | Development Progress* |
|--------------------------------|-----------------------|
| **OpenGL State Manager** | **65 / 65** |
| **Abstraction Layer (MG_RHI)** | **0 / 61** |
| **OpenGL ES Backend** | **N/A** (of MG_RHI) |
| **Vulkan Backend** | **planned** |
| Component | Development Progress\* |
|--------------------------------|------------------------|
| **OpenGL State Manager** | **59 / 62** |
| **Abstraction Layer (MG_RHI)** | **0 / 57** |
| **OpenGL ES Backend** | **N/A** (of MG_RHI) |
| **Vulkan Backend** | **planned** |
* *The number of functions that have been implemented*
\* *The number of functions that have been implemented*