mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-08 04:08:32 +09:00
Compare commits
19
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7618ff27f4 | ||
|
|
05493e5e15 | ||
|
|
c7a8d7e785 | ||
|
|
22b6254a16 | ||
|
|
db1879d098 | ||
|
|
5c0b675ca8 | ||
|
|
47cd496e6d | ||
|
|
aa491bb801 | ||
|
|
605c5daf54 | ||
|
|
223ae1e33f | ||
|
|
33e4b6d8de | ||
|
|
3b1ab8d9d9 | ||
|
|
9297542dcf | ||
|
|
c848255b43 | ||
|
|
b082e2e06b | ||
|
|
96774ef3da | ||
|
|
12cedbae0e | ||
|
|
4e239832a6 | ||
|
|
c68cbfa37b |
@@ -0,0 +1,5 @@
|
||||
################################################################################
|
||||
# 此 .gitignore 文件已由 Microsoft(R) Visual Studio 自动创建。
|
||||
################################################################################
|
||||
|
||||
/build
|
||||
+4
-1
@@ -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
@@ -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
@@ -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";
|
||||
|
||||
@@ -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
@@ -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) {
|
||||
|
||||
@@ -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
@@ -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
|
||||
@@ -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*
|
||||
|
||||
Reference in New Issue
Block a user