hopefully fixed blackscreen 🙏

This commit is contained in:
Kolyah35
2026-03-16 23:16:16 +03:00
parent c7d6289781
commit 183487853c
8 changed files with 3561 additions and 858 deletions

0
glad/include/KHR/khrplatform.h Executable file → Normal file
View File

2941
glad/include/glad/glad.h Executable file → Normal file

File diff suppressed because it is too large Load Diff

1393
glad/src/glad.c Executable file → Normal file

File diff suppressed because it is too large Load Diff

69
src/AppPlatform_glfw.cpp Executable file → Normal file
View File

@@ -1,74 +1,5 @@
#include "AppPlatform_glfw.h"
#ifdef WIN32
#include <Windows.h>
#endif
// Loader that tries GLFW first, then falls back to opengl32.dll for any
// function that glfwGetProcAddress can't resolve.
void* winGLLoader(const char* name) {
void* p = (void*)glfwGetProcAddress(name);
#ifdef WIN32
if (!p) {
static HMODULE opengl32 = LoadLibraryA("opengl32.dll");
if (opengl32) p = (void*)GetProcAddress(opengl32, name);
}
#endif
return p;
}
// -----------------------------------------------------------------------
// Compatibility wrappers for OpenGL ES functions absent from desktop GL.
// The desktop equivalents use double parameters and are not declared in
// the GLES1 GLAD header, so look them up at runtime via winGLLoader.
// -----------------------------------------------------------------------
static void APIENTRY compat_glDepthRangef(GLfloat n, GLfloat f) {
typedef void(APIENTRY *fn_t)(double, double);
static fn_t fn = (fn_t)winGLLoader("glDepthRange");
if (fn) fn((double)n, (double)f);
}
static void APIENTRY compat_glClearDepthf(GLfloat d) {
typedef void(APIENTRY *fn_t)(double);
static fn_t fn = (fn_t)winGLLoader("glClearDepth");
if (fn) fn((double)d);
}
static void APIENTRY compat_glOrthof(GLfloat l, GLfloat r, GLfloat b,
GLfloat t, GLfloat n, GLfloat f) {
typedef void(APIENTRY *fn_t)(double,double,double,double,double,double);
static fn_t fn = (fn_t)winGLLoader("glOrtho");
if (fn) fn(l, r, b, t, n, f);
}
static void APIENTRY compat_glFrustumf(GLfloat l, GLfloat r, GLfloat b,
GLfloat t, GLfloat n, GLfloat f) {
typedef void(APIENTRY *fn_t)(double,double,double,double,double,double);
static fn_t fn = (fn_t)winGLLoader("glFrustum");
if (fn) fn(l, r, b, t, n, f);
}
// glFogx / glFogxv are OpenGL ES fixed-point variants that don't exist in
// desktop opengl32.dll. Wrap them via the float equivalents. For fog-mode
// enum params the GLfixed value IS the enum integer, so the cast is exact.
static void APIENTRY compat_glFogx(GLenum pname, GLfixed param) {
glFogf(pname, (GLfloat)param);
}
static void APIENTRY compat_glFogxv(GLenum pname, const GLfixed* params) {
// Only GL_FOG_COLOR uses an array; convert each element.
GLfloat fp[4] = {
(GLfloat)params[0], (GLfloat)params[1],
(GLfloat)params[2], (GLfloat)params[3]
};
glFogfv(pname, fp);
}
void glPatchDesktopCompat() {
if (!glad_glDepthRangef) glad_glDepthRangef = compat_glDepthRangef;
if (!glad_glClearDepthf) glad_glClearDepthf = compat_glClearDepthf;
if (!glad_glOrthof) glad_glOrthof = compat_glOrthof;
if (!glad_glFrustumf) glad_glFrustumf = compat_glFrustumf;
if (!glad_glFogx) glad_glFogx = compat_glFogx;
if (!glad_glFogxv) glad_glFogxv = compat_glFogxv;
}
float AppPlatform_glfw::getPixelsPerMillimeter() {
GLFWmonitor* monitor = glfwGetPrimaryMonitor();

View File

@@ -150,8 +150,4 @@ public:
private:
};
void* winGLLoader(const char* name);
void glPatchDesktopCompat();
#endif /*APPPLATFORM_GLFW_H__*/

View File

@@ -1,4 +1,5 @@
#include "Minecraft.h"
#include "client/Options.h"
#include "client/player/input/IBuildInput.h"
#include "platform/input/Keyboard.h"
#include "world/item/Item.h"
@@ -1139,7 +1140,7 @@ void Minecraft::init()
checkGlError("Init complete");
#endif
user = new User("TestUser", "");
user = new User(options.getStringValue(OPTIONS_USERNAME), "");
setIsCreativeMode(false); // false means it's Survival Mode
reloadOptions();

View File

@@ -21,6 +21,12 @@
#include <GLES/glext.h>
#else
#include <glad/glad.h>
// https://github.com/programmer1o1/MinecraftPE-v0.6.1/blob/main/handheld/src/client/renderer/gles.h#L135-L138
#define glFogx(a,b) glFogi(a,b)
#define glOrthof(a,b,c,d,e,f) glOrtho(a,b,c,d,e,f)
#define glClearDepthf(x) glClearDepth(x)
#define glDepthRangef(a,b) glDepthRange(a,b)
#endif
#else
// Uglyness to fix redeclaration issues

View File

@@ -143,9 +143,8 @@ int main(void) {
glfwSetWindowSizeCallback(window, window_size_callback);
glfwMakeContextCurrent(window);
gladLoadGLES1Loader((GLADloadproc)winGLLoader);
gladLoadGLLoader((GLADloadproc)glfwGetProcAddress);
glfwSwapInterval(0);
glPatchDesktopCompat();
#endif
App* app = new MAIN_CLASS();