Compare commits

..
Author SHA1 Message Date
BZLZHH 7618ff27f4 [Docs] (README): Add an important note about rewriting this project. 2025-06-30 12:09:14 +08:00
BZLZHH 05493e5e15 [Docs] (README): Update third-party components info. 2025-06-30 12:02:40 +08:00
swung0x48 c7a8d7e785 [Fix]: fix glx macro name 2025-06-20 17:54:55 +08:00
swung0x48 22b6254a16 Merge branch 'dev-es' of https://github.com/MobileGL-Dev/MobileGL into dev-es 2025-06-20 17:50:00 +08:00
swung0x48 db1879d098 [Fix]: fix GLX GetProcAddress not exported properly 2025-06-20 17:48:30 +08:00
BZLZHH 5c0b675ca8 [Feat] (Debug): Add log target control with bitmask flags. 2025-06-20 13:22:57 +08:00
BZLZHH 47cd496e6d [Fix] (Init): Refactor MG_Initialize/MG_Destroy for multi-platform compatibility. 2025-06-05 07:57:07 +08:00
BZLZHH aa491bb801 [Fix] (BufferState): Convert access in AcquireBufferMemory. 2025-05-17 14:31:03 +08:00
BZLZHH 605c5daf54 [Chore] (Global): Upgrade target GL version to 3.2.0. 2025-05-17 13:10:55 +08:00
BZLZHH 223ae1e33f [Feat] (Getter): Handle more pnames in GetIntegerv. 2025-05-17 13:10:20 +08:00
BZLZHH 33e4b6d8de Merge branch 'Feat/dev-es-shittily-draw' into dev-es without ShittilyDraw
# Conflict:
#	MG/Includes.h

# Changes:
#      Remove ShittilyDraw, ready to implement MG_RHI...
#      Update progress.
2025-05-17 11:50:47 +08:00
BZLZHH 3b1ab8d9d9 Revert "a bunch of junk, merging 'shitty' branch"
This reverts commit c68cbfa37b.
2025-05-17 11:13:31 +08:00
BZLZHH 9297542dcf Revert "use unordered_dense to mitigate __next_prime overflow error"
This reverts commit b082e2e06b.
2025-05-17 11:13:19 +08:00
BZLZHH c848255b43 [Docs] (README): Fix the wrong Minecraft version. 2025-05-16 16:47:27 +08:00
swung0x48 b082e2e06b use unordered_dense to mitigate __next_prime overflow error 2025-05-07 10:57:26 +08:00
swung0x48 96774ef3da don't force compile Release profile 2025-05-07 09:10:29 +08:00
swung0x48 12cedbae0e fix compilation on android 2025-05-06 17:53:22 +08:00
swung0x48 4e239832a6 fixing windows compile error WIP 2025-05-06 17:27:15 +08:00
swung0x48 c68cbfa37b a bunch of junk, merging 'shitty' branch 2025-05-06 16:20:18 +08:00
18 changed files with 166 additions and 1260 deletions
+5
View File
@@ -0,0 +1,5 @@
################################################################################
# 此 .gitignore 文件已由 Microsoft(R) Visual Studio 自动创建。
################################################################################
/build
+4 -1
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,6 +25,9 @@ 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
+14 -7
View File
@@ -31,11 +31,18 @@ namespace ankerl {
namespace MG_Constants {
namespace Common {
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;
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;
}
namespace Blend {
@@ -175,8 +182,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";
+9 -8
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 = "-ShittilyDraw";
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";
}
namespace Backend {
@@ -21,13 +21,14 @@ 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 LogLevel = MG_Constants::Common::LOG_LEVEL_INFO;
inline constexpr int LogTarget = MG_Constants::Common::LOG_TARGET_ALL;
#ifdef __ANDROID__
inline const char* LOG_FILE_PATH = "/sdcard/MG/latest.log";
+4
View File
@@ -113,6 +113,10 @@
#include "MG_Include/UncertainBool.hpp"
#ifdef _WIN32
#include <Windows.h>
#endif
#ifndef _WIN32
#include <dlfcn.h>
#include <unistd.h>
+32 -3
View File
@@ -4,14 +4,43 @@
#include "Includes.h"
__attribute__((constructor)) void MG_Initialize() {
void MG_Initialize() {
MG_Util::Debug::LogInit();
MG_Util::Debug::LogI("MobileGL Initializing...");
MG_State::Init();
MG_GL::BackendLoader::Init();
}
__attribute__((destructor)) void MG_Destroy() {
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,6 +5,16 @@
#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,6 +5,7 @@
#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,4 +65,9 @@ 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
}
}
@@ -0,0 +1,13 @@
//
// 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);
}
@@ -0,0 +1,10 @@
//
// 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,6 +8,7 @@
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) {
+14 -6
View File
@@ -71,14 +71,22 @@ namespace MG_Util::Debug {
std::string full_format = header + format + "\n";
#ifdef __ANDROID__
__android_log_vprint(androidLevel, MG_Constants::RenderName, full_format.c_str(), args);
if (MG_Global::Common::LogTarget & MG_Constants::Common::LOG_TARGET_ANDROID) {
__android_log_vprint(androidLevel, MG_Constants::RenderName, full_format.c_str(), args);
}
#endif
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);
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);
}
}
#define DECLARE_LOG_FUNCTION(name, level) \
+20 -11
View File
@@ -4,7 +4,7 @@
- [x] glGetAttribLocation
- [x] glGetBufferParameteriv
- [x] glGetError
- [ ] glGetIntegerv
- [x] glGetIntegerv
- [x] glGetProgramiv
- [x] glGetShaderiv
- [x] glGetString
@@ -33,6 +33,8 @@
- [x] glFramebufferTexture2D
- [x] glGenFramebuffers
  ~~glBlitFramebuffer~~
---
### **4. Shader & Program Management**
@@ -60,6 +62,10 @@
- [x] glUnmapBuffer
- [x] glVertexAttribIPointer
- [x] glVertexAttribPointer
- [x] glBufferSubData
- [x] glMapBufferRange
- [x] glFlushMappedBufferRange
- [x] glCopyBufferSubData
---
@@ -90,28 +96,27 @@
---
### **8. Drawing Commands**
- [ ] glDrawElements
- [ ] glDrawArrays
  ~~glDrawElements~~
## Abstraction Layer (MG_RHI)
### **1. Initialization & Query Functions**
glGetAttribLocation~~
  ~~glGetAttribLocation~~
glGetBufferParameteriv~~
  ~~glGetBufferParameteriv~~
glGetError~~
  ~~glGetError~~
- [ ] glGetIntegerv
  ~~glGetIntegerv~~
- [ ] glGetProgramiv
- [ ] glGetShaderiv
- [ ] glGetString
- [ ] glGetStringi
glGetTexLevelParameteriv~~
  ~~glGetTexLevelParameteriv~~
glGetUniformLocation~~
  ~~glGetUniformLocation~~
---
@@ -133,6 +138,7 @@ glGetUniformLocation~~
- [ ] glDeleteFramebuffers
- [ ] glFramebufferTexture2D
- [ ] glGenFramebuffers
- [ ] glBlitFramebuffer
---
@@ -161,6 +167,10 @@ glGetUniformLocation~~
- [ ] glUnmapBuffer
- [ ] glVertexAttribIPointer
- [ ] glVertexAttribPointer
- [ ] glBufferSubData
- [ ] glMapBufferRange
- [ ] glFlushMappedBufferRange
- [ ] glCopyBufferSubData
---
@@ -191,5 +201,4 @@ glGetUniformLocation~~
---
### **8. Drawing Commands**
- [ ] glDrawElements
- [ ] glDrawArrays
- [ ] glDrawElements
+18 -11
View File
@@ -1,12 +1,19 @@
# 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**: [github](https://github.com/KhronosGroup/SPIRV-Cross)
**SPIRV-Cross** by **KhronosGroup** - [Apache License 2.0](https://github.com/KhronosGroup/SPIRV-Cross/blob/master/LICENSE): [github](https://github.com/KhronosGroup/SPIRV-Cross)
**glslang** by **KhronosGroup**: [github](https://github.com/KhronosGroup/glslang)
**glslang** by **KhronosGroup** - [Various Licenses](https://github.com/KhronosGroup/glslang/blob/main/LICENSE.txt): [github](https://github.com/KhronosGroup/glslang)
**GlslOptimizerV2** by **aiekick**: [github](https://github.com/aiekick/GlslOptimizerV2)
*(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)
## Progress
@@ -21,13 +28,13 @@
---
**Target**: **OpenGL implementation compatible with Minecraft 1.17 to 1.21.1**
**Target**: **OpenGL implementation compatible with Minecraft 1.17 to 1.21.5**
| 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** |
| 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** |
\* *The number of functions that have been implemented*
* *The number of functions that have been implemented*