From fbb7b304c8a86c4c171b618cbaaa5f0f0a42562a Mon Sep 17 00:00:00 2001 From: JuiceyDev Date: Thu, 26 Mar 2026 00:12:59 +0100 Subject: [PATCH] first batch & fix with new files (very hacky & uncleaned state); state: game runs but broken rendering every chunks is at 0,0,0 @n@ --- .../Platform/Linux/Iggy/gdraw/gdraw.c | 818 ++++++++++++++++++ .../Linux/Iggy/gdraw/{gdraw_sdl.h => gdraw.h} | 9 +- .../Platform/Linux/Iggy/gdraw/gdraw_sdl.c | 240 ----- Minecraft.Client/Platform/Linux/LinuxGL.cpp | 200 +++-- .../Platform/Linux/Linux_UIController.cpp | 52 +- Minecraft.Client/Platform/stdafx.h | 251 +++--- Minecraft.Client/Platform/stubs.h | 334 ++++--- 7 files changed, 1250 insertions(+), 654 deletions(-) create mode 100644 Minecraft.Client/Platform/Linux/Iggy/gdraw/gdraw.c rename Minecraft.Client/Platform/Linux/Iggy/gdraw/{gdraw_sdl.h => gdraw.h} (94%) delete mode 100644 Minecraft.Client/Platform/Linux/Iggy/gdraw/gdraw_sdl.c diff --git a/Minecraft.Client/Platform/Linux/Iggy/gdraw/gdraw.c b/Minecraft.Client/Platform/Linux/Iggy/gdraw/gdraw.c new file mode 100644 index 000000000..0c2cea4d5 --- /dev/null +++ b/Minecraft.Client/Platform/Linux/Iggy/gdraw/gdraw.c @@ -0,0 +1,818 @@ +#define GDRAW_ASSERTS + +#include "../../../Windows64/Iggy/include/iggy.h" +#include "../../../Windows64/Iggy/include/gdraw.h" +#include "gdraw.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define true 1 +#define false 0 + + +#ifndef _ENABLEIGGY +void* IggyGDrawMallocAnnotated(SINTa size, const char* file, int line) { + (void)file; + (void)line; + return malloc((size_t)size); +} + +void IggyGDrawFree(void* ptr) { free(ptr); } + +void IggyGDrawSendWarning(Iggy* f, char const* message, ...) { + (void)f; + va_list args; + va_start(args, message); + fprintf(stderr, "[Iggy GDraw Warning] "); + vfprintf(stderr, message, args); + fprintf(stderr, "\n"); + va_end(args); +} + +void IggyDiscardVertexBufferCallback(void* owner, void* buf) { + (void)owner; + (void)buf; +} +#endif + +// We track all the extensions we use. +#define GDRAW_GL_EXTENSION_LIST \ + /* identifier import procname */ \ + /* GL_ARB_vertex_buffer_object */ \ + GLE(GenBuffers, "GenBuffersARB", GENBUFFERSARB) \ + GLE(DeleteBuffers, "DeleteBuffersARB", DELETEBUFFERSARB) \ + GLE(BindBuffer, "BindBufferARB", BINDBUFFERARB) \ + GLE(BufferData, "BufferDataARB", BUFFERDATAARB) \ + GLE(MapBuffer, "MapBufferARB", MAPBUFFERARB) \ + GLE(UnmapBuffer, "UnmapBufferARB", UNMAPBUFFERARB) \ + GLE(VertexAttribPointer, "VertexAttribPointerARB", VERTEXATTRIBPOINTERARB) \ + GLE(EnableVertexAttribArray, "EnableVertexAttribArrayARB", \ + ENABLEVERTEXATTRIBARRAYARB) \ + GLE(DisableVertexAttribArray, "DisableVertexAttribArrayARB", \ + DISABLEVERTEXATTRIBARRAYARB) \ + /* GL_ARB_shader_objects */ \ + GLE(CreateShader, "CreateShaderObjectARB", CREATESHADEROBJECTARB) \ + GLE(DeleteShader, "DeleteObjectARB", DELETEOBJECTARB) \ + GLE(ShaderSource, "ShaderSourceARB", SHADERSOURCEARB) \ + GLE(CompileShader, "CompileShaderARB", COMPILESHADERARB) \ + GLE(GetShaderiv, "GetObjectParameterivARB", GETOBJECTPARAMETERIVARB) \ + GLE(GetShaderInfoLog, "GetInfoLogARB", GETINFOLOGARB) \ + GLE(CreateProgram, "CreateProgramObjectARB", CREATEPROGRAMOBJECTARB) \ + GLE(DeleteProgram, "DeleteObjectARB", DELETEOBJECTARB) \ + GLE(AttachShader, "AttachObjectARB", ATTACHOBJECTARB) \ + GLE(LinkProgram, "LinkProgramARB", LINKPROGRAMARB) \ + GLE(GetUniformLocation, "GetUniformLocationARB", GETUNIFORMLOCATIONARB) \ + GLE(UseProgram, "UseProgramObjectARB", USEPROGRAMOBJECTARB) \ + GLE(GetProgramiv, "GetObjectParameterivARB", GETOBJECTPARAMETERIVARB) \ + GLE(GetProgramInfoLog, "GetInfoLogARB", GETINFOLOGARB) \ + GLE(Uniform1i, "Uniform1iARB", UNIFORM1IARB) \ + GLE(Uniform4f, "Uniform4fARB", UNIFORM4FARB) \ + GLE(Uniform4fv, "Uniform4fvARB", UNIFORM4FVARB) \ + /* GL_ARB_vertex_shader */ \ + GLE(BindAttribLocation, "BindAttribLocationARB", BINDATTRIBLOCATIONARB) \ + /* Missing from WGL but needed by shared code */ \ + GLE(Uniform1f, "Uniform1fARB", UNIFORM1FARB) \ + /* GL_EXT_framebuffer_object */ \ + GLE(GenRenderbuffers, "GenRenderbuffersEXT", GENRENDERBUFFERSEXT) \ + GLE(DeleteRenderbuffers, "DeleteRenderbuffersEXT", DELETERENDERBUFFERSEXT) \ + GLE(BindRenderbuffer, "BindRenderbufferEXT", BINDRENDERBUFFEREXT) \ + GLE(RenderbufferStorage, "RenderbufferStorageEXT", RENDERBUFFERSTORAGEEXT) \ + GLE(GenFramebuffers, "GenFramebuffersEXT", GENFRAMEBUFFERSEXT) \ + GLE(DeleteFramebuffers, "DeleteFramebuffersEXT", DELETEFRAMEBUFFERSEXT) \ + GLE(BindFramebuffer, "BindFramebufferEXT", BINDFRAMEBUFFEREXT) \ + GLE(CheckFramebufferStatus, "CheckFramebufferStatusEXT", \ + CHECKFRAMEBUFFERSTATUSEXT) \ + GLE(FramebufferRenderbuffer, "FramebufferRenderbufferEXT", \ + FRAMEBUFFERRENDERBUFFEREXT) \ + GLE(FramebufferTexture2D, "FramebufferTexture2DEXT", \ + FRAMEBUFFERTEXTURE2DEXT) \ + GLE(GenerateMipmap, "GenerateMipmapEXT", GENERATEMIPMAPEXT) \ + /* GL_EXT_framebuffer_blit */ \ + GLE(BlitFramebuffer, "BlitFramebufferEXT", BLITFRAMEBUFFEREXT) \ + /* GL_EXT_framebuffer_multisample */ \ + GLE(RenderbufferStorageMultisample, "RenderbufferStorageMultisampleEXT", \ + RENDERBUFFERSTORAGEMULTISAMPLEEXT) \ + /* */ + + +// Shared .inl +#define gdraw_GLx_(id) gdraw_GL_##id +#define GDRAW_GLx_(id) GDRAW_GL_##id +#define GDRAW_SHADERS "gdraw_gl_shaders.inl" + +// GLhandleARB is void* but shader functions use GLuint values. +// homework stolen from gdraw_gl_shared.inl. +#define GDrawGLProgram GLuint +typedef GLuint GLhandle; +typedef gdraw_gl_resourcetype gdraw_resourcetype; + +#define GLE(id, import, procname) static PFNGL##procname##PROC gl##id; +GDRAW_GL_EXTENSION_LIST +#undef GLE + + +typedef const GLubyte*(APIENTRYP PFNGLGETSTRINGIPROC_)(GLenum name, + GLuint index); +static PFNGLGETSTRINGIPROC_ gdraw_glGetStringi = NULL; + +typedef void(APIENTRYP PFNGLGENVERTEXARRAYSPROC_)(GLsizei n, GLuint* arrays); +typedef void(APIENTRYP PFNGLBINDVERTEXARRAYPROC_)(GLuint array); +static PFNGLGENVERTEXARRAYSPROC_ gdraw_glGenVertexArrays = NULL; +static PFNGLBINDVERTEXARRAYPROC_ gdraw_glBindVertexArray = NULL; +static GLuint gdraw_vao = 0; + +typedef void(APIENTRYP gdraw_vtxattrib_fn)(GLuint, GLint, GLenum, GLboolean, + GLsizei, const void*); +static gdraw_vtxattrib_fn gdraw_real_vtxattrib = NULL; +static GLuint gdraw_screenvbo = 0; +static const void* gdraw_screenvbo_base = NULL; +static size_t gdraw_expected_vbo_size = 0; + + +typedef void(APIENTRYP gdraw_drawelements_fn)(GLenum mode, GLsizei count, + GLenum type, const void* indices); +static gdraw_drawelements_fn gdraw_real_drawelements = NULL; +static GLuint gdraw_screenibo = 0; + + +typedef GLuint(APIENTRYP gdraw_createshader_fn)(GLenum); +typedef void(APIENTRYP gdraw_shadersource_fn)(GLuint, GLsizei, const GLchar**, + const GLint*); +typedef void(APIENTRYP gdraw_compileshader_fn)(GLuint); +typedef void(APIENTRYP gdraw_linkprogram_fn)(GLuint); +static gdraw_createshader_fn gdraw_real_createshader = NULL; +static gdraw_shadersource_fn gdraw_real_shadersource = NULL; +static gdraw_compileshader_fn gdraw_real_compileshader = NULL; +static gdraw_linkprogram_fn gdraw_real_linkprogram = NULL; + +// some core reject p0 + +typedef void(APIENTRYP gdraw_useprogram_fn)(GLuint); +static gdraw_useprogram_fn gdraw_real_useprogram = NULL; +static GLuint gdraw_null_program = 0; + + +typedef void(APIENTRYP gdraw_teximage2d_fn)(GLenum, GLint, GLint, GLsizei, + GLsizei, GLint, GLenum, GLenum, + const void*); +typedef void(APIENTRYP gdraw_texsubimage2d_fn)(GLenum, GLint, GLint, GLint, + GLsizei, GLsizei, GLenum, GLenum, + const void*); +static gdraw_teximage2d_fn gdraw_real_teximage2d = NULL; +static gdraw_texsubimage2d_fn gdraw_real_texsubimage2d = NULL; + +#define TRY(ptr, arb, core) \ + do { \ + void* _p = SDL_GL_GetProcAddress(core); \ + if (!_p) _p = SDL_GL_GetProcAddress(arb); \ + *(void**)&(ptr) = _p; \ + } while (0) + +static void load_extensions(void) { +// gl_shared requires ts shit ugh +#define GLE(id, import, procname) \ + gl##id = (PFNGL##procname##PROC)SDL_GL_GetProcAddress("gl" import); + GDRAW_GL_EXTENSION_LIST +#undef GLE + + TRY(glCreateShader, "glCreateShaderObjectARB", "glCreateShader"); + TRY(glDeleteShader, "glDeleteObjectARB", "glDeleteShader"); + TRY(glShaderSource, "glShaderSourceARB", "glShaderSource"); + TRY(glCompileShader, "glCompileShaderARB", "glCompileShader"); + TRY(glGetShaderiv, "glGetObjectParameterivARB", "glGetShaderiv"); + TRY(glGetShaderInfoLog, "glGetInfoLogARB", "glGetShaderInfoLog"); + TRY(glCreateProgram, "glCreateProgramObjectARB", "glCreateProgram"); + TRY(glDeleteProgram, "glDeleteObjectARB", "glDeleteProgram"); + TRY(glAttachShader, "glAttachObjectARB", "glAttachShader"); + TRY(glLinkProgram, "glLinkProgramARB", "glLinkProgram"); + TRY(glGetUniformLocation, "glGetUniformLocationARB", + "glGetUniformLocation"); + TRY(glUseProgram, "glUseProgramObjectARB", "glUseProgram"); + TRY(glGetProgramiv, "glGetObjectParameterivARB", "glGetProgramiv"); + TRY(glGetProgramInfoLog, "glGetInfoLogARB", "glGetProgramInfoLog"); + TRY(glUniform1i, "glUniform1iARB", "glUniform1i"); + TRY(glUniform4f, "glUniform4fARB", "glUniform4f"); + TRY(glUniform4fv, "glUniform4fvARB", "glUniform4fv"); + TRY(glUniform1f, "glUniform1fARB", "glUniform1f"); + TRY(glBindAttribLocation, "glBindAttribLocationARB", + "glBindAttribLocation"); + + TRY(glGenBuffers, "glGenBuffersARB", "glGenBuffers"); + TRY(glDeleteBuffers, "glDeleteBuffersARB", "glDeleteBuffers"); + TRY(glBindBuffer, "glBindBufferARB", "glBindBuffer"); + TRY(glBufferData, "glBufferDataARB", "glBufferData"); + TRY(glMapBuffer, "glMapBufferARB", "glMapBuffer"); + TRY(glUnmapBuffer, "glUnmapBufferARB", "glUnmapBuffer"); + TRY(glVertexAttribPointer, "glVertexAttribPointerARB", + "glVertexAttribPointer"); + TRY(glEnableVertexAttribArray, "glEnableVertexAttribArrayARB", + "glEnableVertexAttribArray"); + TRY(glDisableVertexAttribArray, "glDisableVertexAttribArrayARB", + "glDisableVertexAttribArray"); + + TRY(glGenRenderbuffers, "glGenRenderbuffersEXT", "glGenRenderbuffers"); + TRY(glDeleteRenderbuffers, "glDeleteRenderbuffersEXT", + "glDeleteRenderbuffers"); + TRY(glBindRenderbuffer, "glBindRenderbufferEXT", "glBindRenderbuffer"); + TRY(glRenderbufferStorage, "glRenderbufferStorageEXT", + "glRenderbufferStorage"); + TRY(glGenFramebuffers, "glGenFramebuffersEXT", "glGenFramebuffers"); + TRY(glDeleteFramebuffers, "glDeleteFramebuffersEXT", + "glDeleteFramebuffers"); + TRY(glBindFramebuffer, "glBindFramebufferEXT", "glBindFramebuffer"); + TRY(glCheckFramebufferStatus, "glCheckFramebufferStatusEXT", + "glCheckFramebufferStatus"); + TRY(glFramebufferRenderbuffer, "glFramebufferRenderbufferEXT", + "glFramebufferRenderbuffer"); + TRY(glFramebufferTexture2D, "glFramebufferTexture2DEXT", + "glFramebufferTexture2D"); + TRY(glGenerateMipmap, "glGenerateMipmapEXT", "glGenerateMipmap"); + TRY(glBlitFramebuffer, "glBlitFramebufferEXT", "glBlitFramebuffer"); + TRY(glRenderbufferStorageMultisample, "glRenderbufferStorageMultisampleEXT", + "glRenderbufferStorageMultisample"); + + // Save raw pointers before we #define over the names below + gdraw_real_vtxattrib = (gdraw_vtxattrib_fn)(void*)glVertexAttribPointer; + gdraw_real_createshader = (gdraw_createshader_fn)(void*)glCreateShader; + gdraw_real_shadersource = (gdraw_shadersource_fn)(void*)glShaderSource; + gdraw_real_compileshader = (gdraw_compileshader_fn)(void*)glCompileShader; + gdraw_real_linkprogram = (gdraw_linkprogram_fn)(void*)glLinkProgram; + gdraw_real_teximage2d = (gdraw_teximage2d_fn)(void*)glTexImage2D; + gdraw_real_texsubimage2d = (gdraw_texsubimage2d_fn)(void*)glTexSubImage2D; + gdraw_real_useprogram = (gdraw_useprogram_fn)(void*)glUseProgram; + gdraw_real_drawelements = + (gdraw_drawelements_fn)SDL_GL_GetProcAddress("glDrawElements"); + + gdraw_glGetStringi = + (PFNGLGETSTRINGIPROC_)SDL_GL_GetProcAddress("glGetStringi"); + // VAO + gdraw_glGenVertexArrays = + (PFNGLGENVERTEXARRAYSPROC_)SDL_GL_GetProcAddress("glGenVertexArrays"); + gdraw_glBindVertexArray = + (PFNGLBINDVERTEXARRAYPROC_)SDL_GL_GetProcAddress("glBindVertexArray"); + + if (gdraw_glGenVertexArrays && gdraw_glBindVertexArray && gdraw_vao == 0) { + gdraw_glGenVertexArrays(1, &gdraw_vao); + gdraw_glBindVertexArray(gdraw_vao); + } +} + +#undef TRY + +// rebind vbo + +static void clear_renderstate_platform_specific(void) { + if (gdraw_glBindVertexArray && gdraw_vao) + gdraw_glBindVertexArray(gdraw_vao); +} + +static void error_msg_platform_specific(const char* msg) { + fprintf(stderr, "[GDraw] %s\n", msg); +} + +#define GDRAW_MULTISAMPLING + +// i wish i could improve this function +#ifdef RR_BREAK +#undef RR_BREAK +#endif +#define RR_BREAK() \ + do { \ + fprintf(stderr, "[GDraw] GL error at %s:%d\n", __FILE__, __LINE__); \ + } while (0) + + +// the magic number that tropical told me +#define GDRAW_MAX_SHADERS 64 +static struct { + GLuint handle; + GLenum type; +} gdraw_shader_types[GDRAW_MAX_SHADERS]; +static int gdraw_shader_type_count = 0; + +static GLenum gdraw_get_shader_type(GLuint shader) { + int i; + for (i = 0; i < gdraw_shader_type_count; i++) + if (gdraw_shader_types[i].handle == shader) + return gdraw_shader_types[i].type; + return GL_FRAGMENT_SHADER; +} + +static GLuint gdraw_CreateShaderTracked(GLenum type) { + GLuint h = gdraw_real_createshader(type); + if (h && gdraw_shader_type_count < GDRAW_MAX_SHADERS) { + gdraw_shader_types[gdraw_shader_type_count].handle = h; + gdraw_shader_types[gdraw_shader_type_count].type = type; + gdraw_shader_type_count++; + } + return h; +} + + + +static void gdraw_CompileShaderAndLog(GLuint shader) { + GLint status = 0; + gdraw_real_compileshader(shader); + glGetShaderiv(shader, GL_COMPILE_STATUS, &status); + if (!status) { + char log[2048]; + GLint len = 0; + glGetShaderInfoLog(shader, (GLsizei)sizeof(log) - 1, &len, log); + log[len] = '\0'; + fprintf(stderr, "[GDraw GLSL] compile FAILED shader=%u:\n%s\n", shader, + log); + fflush(stderr); + } +} + +static void gdraw_LinkProgramAndLog(GLuint program) { + GLint status = 0; + gdraw_real_linkprogram(program); + glGetProgramiv(program, GL_LINK_STATUS, &status); + if (!status) { + char log[2048]; + GLint len = 0; + glGetProgramInfoLog(program, (GLsizei)sizeof(log) - 1, &len, log); + log[len] = '\0'; + fprintf(stderr, "[GDraw GLSL] link FAILED program=%u:\n%s\n", program, + log); + fflush(stderr); + } +} + +#undef glCreateShader +#define glCreateShader gdraw_CreateShaderTracked + +// This is the part that turns the old ugly shaders to 330 +static char* gdraw_strreplace(char* src, const char* find, const char* rep) { + char* result; + char* pos; + char* base = src; + size_t find_len = strlen(find); + size_t rep_len = strlen(rep); + size_t count = 0; + char* tmp = src; + + while ((tmp = strstr(tmp, find))) { + count++; + tmp += find_len; + } + if (!count) return src; + + result = (char*)malloc(strlen(src) + count * (rep_len + 1) + 1); + if (!result) return src; + + tmp = result; + while ((pos = strstr(src, find))) { + size_t before = (size_t)(pos - src); + memcpy(tmp, src, before); + tmp += before; + memcpy(tmp, rep, rep_len); + tmp += rep_len; + src = pos + find_len; + } + strcpy(tmp, src); + free(base); + return result; +} + +static void gdraw_ShaderSourceUpgraded(GLuint shader, GLsizei count, + const GLchar** strings, + const GLint* lengths) { + int i; + size_t total = 0; + char* src; + char* patched; + int is_vert; + const GLchar* patched_ptr; + + for (i = 0; i < count; i++) + total += lengths ? (lengths[i] >= 0 ? (size_t)lengths[i] + : strlen(strings[i])) + : strlen(strings[i]); + + src = (char*)malloc(total + 1); + if (!src) { + gdraw_real_shadersource(shader, count, strings, lengths); + return; + } + + src[0] = '\0'; + for (i = 0; i < count; i++) { + size_t len = lengths ? (lengths[i] >= 0 ? (size_t)lengths[i] + : strlen(strings[i])) + : strlen(strings[i]); + strncat(src, strings[i], len); + } + + is_vert = (gdraw_get_shader_type(shader) == GL_VERTEX_SHADER); + + // Strip any existing #version directive as i'll add our own + { + char* vp = strstr(src, "#version"); + if (vp) { + char* nl = strchr(vp, '\n'); + if (nl) + memmove(vp, nl + 1, strlen(nl + 1) + 1); + else + *vp = '\0'; + } + } + + // Texture built-ins + src = gdraw_strreplace(src, "texture2DRect", "texture"); + src = gdraw_strreplace(src, "texture2D", "texture"); + + // Attribute -> in + src = gdraw_strreplace(src, "attribute ", "in "); + src = gdraw_strreplace(src, "attribute\t", "in\t"); + src = gdraw_strreplace(src, "attribute\n", "in\n"); + + // Varying -> out (vert) / in (frag) + if (is_vert) { + src = gdraw_strreplace(src, "varying ", "out "); + src = gdraw_strreplace(src, "varying\t", "out\t"); + src = gdraw_strreplace(src, "varying\n", "out\n"); + } else { + src = gdraw_strreplace(src, "varying ", "in "); + src = gdraw_strreplace(src, "varying\t", "in\t"); + src = gdraw_strreplace(src, "varying\n", "in\n"); + } + if (!is_vert) { + src = gdraw_strreplace(src, "gl_FragData[0]", "_gdraw_frag_out"); + src = gdraw_strreplace(src, "gl_FragColor", "_gdraw_frag_out"); + } + + // finally turn it 330 + { + const char* vert_header = "#version 330 core\n"; + const char* frag_header = + "#version 330 core\nout vec4 _gdraw_frag_out;\n"; + const char* header = is_vert ? vert_header : frag_header; + patched = (char*)malloc(strlen(header) + strlen(src) + 2); + if (!patched) { + free(src); + gdraw_real_shadersource(shader, count, strings, lengths); + return; + } + strcpy(patched, header); + strcat(patched, src); + free(src); + } + + patched_ptr = (const GLchar*)patched; + gdraw_real_shadersource(shader, 1, &patched_ptr, NULL); + free(patched); +} + +#undef glShaderSource +#define glShaderSource gdraw_ShaderSourceUpgraded + + +// Remap all the deprecated internal formats to their modern equivalents +// (idk why but just the word "swizzle" is cracking me up) +static void gdraw_apply_swizzle(GLenum internal_fmt) { + if (internal_fmt == 0x1906 /* GL_ALPHA */ || internal_fmt == GL_RED) { + GLint sw[4] = {GL_ZERO, GL_ZERO, GL_ZERO, GL_RED}; + glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, sw); + } else if (internal_fmt == 0x1909 /* GL_LUMINANCE */) { + GLint sw[4] = {GL_RED, GL_RED, GL_RED, GL_ONE}; + glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, sw); + } else if (internal_fmt == 0x190A /* GL_LUMINANCE_ALPHA */) { + GLint sw[4] = {GL_RED, GL_RED, GL_RED, GL_GREEN}; + glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, sw); + } +} + +static GLenum gdraw_remap_fmt(GLenum fmt) { + switch (fmt) { + case 0x1906: + return GL_RED; // GL_ALPHA + case 0x1909: + return GL_RED; // GL_LUMINANCE + case 0x190A: + return GL_RG; // GL_LUMINANCE_ALPHA + case 0x8033: + return GL_RG; // GL_LUMINANCE4_ALPHA4 + case 0x8045: + return GL_R8; // GL_LUMINANCE8 + case 0x8048: + return GL_RG8; // GL_LUMINANCE8_ALPHA8 + case 0x804F: + return GL_R8; // GL_INTENSITY4 + case 0x8050: + return GL_R8; // GL_INTENSITY8 + default: + return fmt; + } +} + +static void gdraw_TexImage2D(GLenum target, GLint level, GLint ifmt, GLsizei w, + GLsizei h, GLint border, GLenum fmt, GLenum type, + const void* data) { + GLenum new_ifmt = gdraw_remap_fmt((GLenum)ifmt); + GLenum new_fmt = gdraw_remap_fmt(fmt); + gdraw_real_teximage2d(target, level, (GLint)new_ifmt, w, h, border, new_fmt, + type, data); + if (new_ifmt != (GLenum)ifmt) gdraw_apply_swizzle((GLenum)ifmt); +} + +static void gdraw_TexSubImage2D(GLenum target, GLint level, GLint xoff, + GLint yoff, GLsizei w, GLsizei h, GLenum fmt, + GLenum type, const void* data) { + GLenum new_fmt = gdraw_remap_fmt(fmt); + gdraw_real_texsubimage2d(target, level, xoff, yoff, w, h, new_fmt, type, + data); +} + +#undef glTexImage2D +#define glTexImage2D gdraw_TexImage2D +#undef glTexSubImage2D +#define glTexSubImage2D gdraw_TexSubImage2D + +// vbo emu +static void gdraw_ClientVertexAttribPointer(GLuint index, GLint size, + GLenum type, GLboolean normalized, + GLsizei stride, + const void* pointer) { + if (gdraw_glBindVertexArray && gdraw_vao) { + GLint current_vao = 0; + glGetIntegerv(GL_VERTEX_ARRAY_BINDING, ¤t_vao); + if ((GLuint)current_vao != gdraw_vao) + gdraw_glBindVertexArray(gdraw_vao); + } + + { + GLint current_vbo = 0; + glGetIntegerv(GL_ARRAY_BUFFER_BINDING, ¤t_vbo); + + if (current_vbo != 0 && current_vbo != (GLint)gdraw_screenvbo) { + gdraw_real_vtxattrib(index, size, type, normalized, stride, + pointer); + return; + } + } + + if (pointer == NULL) { + gdraw_real_vtxattrib(index, size, type, normalized, stride, pointer); + return; + } + + if (gdraw_screenvbo_base == NULL) { + if (!gdraw_screenvbo) glGenBuffers(1, &gdraw_screenvbo); + glBindBuffer(GL_ARRAY_BUFFER, gdraw_screenvbo); + + size_t upload_size = + gdraw_expected_vbo_size > 0 ? gdraw_expected_vbo_size : 256; + glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)upload_size, pointer, + GL_STREAM_DRAW); + + gdraw_screenvbo_base = pointer; + gdraw_real_vtxattrib(index, size, type, normalized, stride, + (const void*)0); + } else { + glBindBuffer(GL_ARRAY_BUFFER, gdraw_screenvbo); + ptrdiff_t offset = + (const char*)pointer - (const char*)gdraw_screenvbo_base; + gdraw_real_vtxattrib(index, size, type, normalized, stride, + (const void*)offset); + } +} + +#undef glVertexAttribPointer +#define glVertexAttribPointer gdraw_ClientVertexAttribPointer + +// fake ibo +static void hooked_glDrawElements(GLenum mode, GLsizei count, GLenum type, + const void* indices) { + GLint current_ibo = 0; + glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, ¤t_ibo); + + if (current_ibo == 0 && indices != NULL) { + if (!gdraw_screenibo) glGenBuffers(1, &gdraw_screenibo); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, gdraw_screenibo); + + size_t index_size = (type == GL_UNSIGNED_SHORT) ? 2 + : (type == GL_UNSIGNED_BYTE) ? 1 + : 4; + glBufferData(GL_ELEMENT_ARRAY_BUFFER, (GLsizeiptr)(count * index_size), + indices, GL_STREAM_DRAW); + + gdraw_real_drawelements(mode, count, type, (const void*)0); + } else { + gdraw_real_drawelements(mode, count, type, indices); + } +} + +#define glDrawElements hooked_glDrawElements + +// dummy shader for glUseProgram(0) safety +static void gdraw_UseProgramSafe(GLuint program) { + if (!program) { + if (!gdraw_null_program && gdraw_real_useprogram) { + const char* vs = + "#version 330 core\nvoid main(){gl_Position=vec4(0);}"; + const char* fs = + "#version 330 core\nout vec4 c;\nvoid main(){c=vec4(0);}"; + GLuint v = gdraw_real_createshader(GL_VERTEX_SHADER); + GLuint f = gdraw_real_createshader(GL_FRAGMENT_SHADER); + gdraw_real_shadersource(v, 1, &vs, NULL); + gdraw_real_shadersource(f, 1, &fs, NULL); + gdraw_real_compileshader(v); + gdraw_real_compileshader(f); + gdraw_null_program = glCreateProgram(); + glAttachShader(gdraw_null_program, v); + glAttachShader(gdraw_null_program, f); + gdraw_real_linkprogram(gdraw_null_program); + glDeleteShader(v); + glDeleteShader(f); + } + gdraw_real_useprogram(0); + return; + } + gdraw_real_useprogram(program); +} + +#undef glUseProgram +#define glUseProgram gdraw_UseProgramSafe + +#undef glCompileShader +#define glCompileShader gdraw_CompileShaderAndLog + +#undef glLinkProgram +#define glLinkProgram gdraw_LinkProgramAndLog + +// v ugh fuck you windows +#include "../../../Windows64/Iggy/gdraw/gdraw_gl_shared.inl" +#undef glVertexAttribPointer +#define glVertexAttribPointer gdraw_real_vtxattrib + +// 3.3 c extension +static int hasext_core(const char* name) { + GLint n = 0; + GLint i; + if (!gdraw_glGetStringi) return 0; + glGetIntegerv(GL_NUM_EXTENSIONS, &n); + for (i = 0; i < n; i++) { + const char* e = + (const char*)gdraw_glGetStringi(GL_EXTENSIONS, (GLuint)i); + if (e && strcmp(e, name) == 0) return 1; + } + return 0; +} + +static gdraw_draw_indexed_triangles* real_DrawIndexedTriangles = NULL; + +static void RADLINK hooked_DrawIndexedTriangles(GDrawRenderState* r, + GDrawPrimitive* prim, + GDrawVertexBuffer* buf, + GDrawStats* stats) { + if (buf == NULL && prim != NULL && prim->vertices != NULL) { + size_t stride = 8; + if (prim->vertex_format == GDRAW_vformat_v2aa) + stride = 16; + else if (prim->vertex_format == GDRAW_vformat_v2tc2) + stride = 16; + else if (prim->vertex_format == GDRAW_vformat_ihud1) + stride = 20; + gdraw_expected_vbo_size = prim->num_vertices * stride; + } else { + gdraw_expected_vbo_size = 0; + } + gdraw_screenvbo_base = NULL; // Force VBO re-upload for each primitive + real_DrawIndexedTriangles(r, prim, buf, stats); +} + +static gdraw_filter_quad* real_FilterQuad = NULL; + +static void RADLINK hooked_FilterQuad(GDrawRenderState* r, S32 x0, S32 y0, + S32 x1, S32 y1, GDrawStats* stats) { + gdraw_expected_vbo_size = 4 * 20; // 4 vertices, max stride + gdraw_screenvbo_base = NULL; + real_FilterQuad(r, x0, y0, x1, y1, stats); +} + +static gdraw_rendering_begin* real_RenderingBegin = NULL; + +// stupid hack +static void RADLINK hooked_RenderingBegin(void) { + if (real_RenderingBegin) real_RenderingBegin(); + glDisable(GL_DEPTH_TEST); + glDisable(GL_CULL_FACE); +} + +// Creating the context +GDrawFunctions* gdraw_GL_CreateContext(S32 w, S32 h, S32 msaa_samples) { + static const TextureFormatDesc tex_formats[] = { + {IFT_FORMAT_rgba_8888, 1, 1, 4, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE}, + {IFT_FORMAT_rgba_4444_LE, 1, 1, 2, GL_RGBA4, GL_RGBA, + GL_UNSIGNED_SHORT_4_4_4_4}, + {IFT_FORMAT_rgba_5551_LE, 1, 1, 2, GL_RGB5_A1, GL_RGBA, + GL_UNSIGNED_SHORT_5_5_5_1}, + {IFT_FORMAT_la_88, 1, 1, 2, GL_LUMINANCE8_ALPHA8, GL_LUMINANCE_ALPHA, + GL_UNSIGNED_BYTE}, + {IFT_FORMAT_la_44, 1, 1, 1, GL_LUMINANCE4_ALPHA4, GL_LUMINANCE_ALPHA, + GL_UNSIGNED_BYTE}, + {IFT_FORMAT_i_8, 1, 1, 1, GL_INTENSITY8, GL_ALPHA, GL_UNSIGNED_BYTE}, + {IFT_FORMAT_i_4, 1, 1, 1, GL_INTENSITY4, GL_ALPHA, GL_UNSIGNED_BYTE}, + {IFT_FORMAT_l_8, 1, 1, 1, GL_LUMINANCE8, GL_LUMINANCE, + GL_UNSIGNED_BYTE}, + {IFT_FORMAT_l_4, 1, 1, 1, GL_LUMINANCE4, GL_LUMINANCE, + GL_UNSIGNED_BYTE}, + {IFT_FORMAT_DXT1, 4, 4, 8, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, 0, + GL_UNSIGNED_BYTE}, + {IFT_FORMAT_DXT3, 4, 4, 16, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, 0, + GL_UNSIGNED_BYTE}, + {IFT_FORMAT_DXT5, 4, 4, 16, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, 0, + GL_UNSIGNED_BYTE}, + {0, 0, 0, 0, 0, 0, 0}, + }; + + GDrawFunctions* funcs; + GLint n; + GLint major = 0, minor = 0; + + // incase everything goes wrong and it goes like 1.1 or smh + glGetIntegerv(GL_MAJOR_VERSION, &major); + glGetIntegerv(GL_MINOR_VERSION, &minor); + if (major < 3 || (major == 3 && minor < 3)) { + fprintf(stderr, "[GDraw] GL 3.3 or higher required (got %d.%d)\n", + major, minor); + return NULL; + } + + // FBO is core since 3.0 + if (!hasext_core("GL_EXT_framebuffer_object")) { + fprintf(stderr, + "[GDraw] GL_EXT_framebuffer_object not listed, " + "fuck it, let's continue.\n"); + } + + if (!hasext_core("GL_EXT_framebuffer_multisample") && msaa_samples > 1) + return NULL; + + load_extensions(); + + if (gdraw_glBindVertexArray && gdraw_vao) + gdraw_glBindVertexArray(gdraw_vao); + + funcs = create_context(w, h); + if (!funcs) return NULL; + + // hook the vtable entries for VBO reset and render state + real_DrawIndexedTriangles = funcs->DrawIndexedTriangles; + funcs->DrawIndexedTriangles = hooked_DrawIndexedTriangles; + + real_FilterQuad = funcs->FilterQuad; + funcs->FilterQuad = hooked_FilterQuad; + + real_RenderingBegin = funcs->RenderingBegin; + funcs->RenderingBegin = hooked_RenderingBegin; + + gdraw->tex_formats = tex_formats; + gdraw->has_mapbuffer = true; + gdraw->has_depth24 = true; + gdraw->has_texture_max_level = true; + + if (hasext_core("GL_EXT_packed_depth_stencil")) + gdraw->has_packed_depth_stencil = true; + + glGetIntegerv(GL_MAX_TEXTURE_SIZE, &n); + gdraw->has_conditional_non_power_of_two = (n < 8192); + + if (msaa_samples > 1) { + glGetIntegerv(GL_MAX_SAMPLES, &n); + gdraw->multisampling = RR_MIN(msaa_samples, n); + } + + opengl_check(); + + fprintf(stderr, + "[GDraw] Context created successfully (%dx%d, msaa=%d)\n", w, h, + msaa_samples); + return funcs; +} + +// Custom draw callbacks +void gdraw_GL_BeginCustomDraw_4J(IggyCustomDrawCallbackRegion* region, + F32* matrix) { + // rebind vbo + if (gdraw_glBindVertexArray && gdraw_vao) + gdraw_glBindVertexArray(gdraw_vao); + clear_renderstate(); + gdraw_GetObjectSpaceMatrix(matrix, region->o2w, gdraw->projection, + depth_from_id(0), 0); +} + +void gdraw_GL_CalculateCustomDraw_4J(IggyCustomDrawCallbackRegion* region, + F32* matrix) { + gdraw_GetObjectSpaceMatrix(matrix, region->o2w, gdraw->projection, 0.0f, 0); +} \ No newline at end of file diff --git a/Minecraft.Client/Platform/Linux/Iggy/gdraw/gdraw_sdl.h b/Minecraft.Client/Platform/Linux/Iggy/gdraw/gdraw.h similarity index 94% rename from Minecraft.Client/Platform/Linux/Iggy/gdraw/gdraw_sdl.h rename to Minecraft.Client/Platform/Linux/Iggy/gdraw/gdraw.h index 063660297..326d5c5a5 100644 --- a/Minecraft.Client/Platform/Linux/Iggy/gdraw/gdraw_sdl.h +++ b/Minecraft.Client/Platform/Linux/Iggy/gdraw/gdraw.h @@ -1,7 +1,9 @@ -#ifndef __RAD_INCLUDE_GDRAW_SDL_H__ -#define __RAD_INCLUDE_GDRAW_SDL_H__ +#ifndef __LINUX_IGGY_GDRAW_H__ +#define __LINUX_IGGY_GDRAW_H__ + #include "../../../Windows64/Iggy/include/gdraw.h" #include "../../../Windows64/Iggy/include/iggy.h" + #ifdef __cplusplus extern "C" { #endif @@ -34,4 +36,5 @@ extern void gdraw_GL_DestroyTextureFromResource(GDrawTexture *tex); #ifdef __cplusplus } #endif -#endif // __RAD_INCLUDE_GDRAW_SDL_H__ \ No newline at end of file + +#endif // __LINUX_IGGY_GDRAW_H__ \ No newline at end of file diff --git a/Minecraft.Client/Platform/Linux/Iggy/gdraw/gdraw_sdl.c b/Minecraft.Client/Platform/Linux/Iggy/gdraw/gdraw_sdl.c deleted file mode 100644 index 7e3506367..000000000 --- a/Minecraft.Client/Platform/Linux/Iggy/gdraw/gdraw_sdl.c +++ /dev/null @@ -1,240 +0,0 @@ -// Rewrite of gdraw_GLFW to gdraw_SDL -// I hope iggy gets fully implemented rrlllly quickly <3 -#define GDRAW_ASSERTS - -#include "../../../Windows64/Iggy/include/iggy.h" -#include "../../../Windows64/Iggy/include/gdraw.h" -#include "gdraw_sdl.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define true 1 -#define false 0 - -// Say hi to sdl - -#ifndef _ENABLEIGGY -void *IggyGDrawMallocAnnotated(SINTa size, const char *file, int line) -{ - (void)file; (void)line; - return malloc((size_t)size); -} - -void IggyGDrawFree(void *ptr) -{ - free(ptr); -} - -void IggyGDrawSendWarning(Iggy *f, char const *message, ...) -{ - (void)f; - va_list args; - va_start(args, message); - fprintf(stderr, "[Iggy GDraw Warning] "); - vfprintf(stderr, message, args); - fprintf(stderr, "\n"); - va_end(args); -} - -void IggyDiscardVertexBufferCallback(void *owner, void *buf) -{ - (void)owner; (void)buf; -} -#endif - -// glActiveTexture and glCompressedTexImage2D are core GL 1.3+ on Linux and -// are declared directly in , so they are omitted from this list. -#define GDRAW_GL_EXTENSION_LIST \ -/* identifier import procname */ \ -/* GL_ARB_vertex_buffer_object */ \ -GLE(GenBuffers, "GenBuffersARB", GENBUFFERSARB) \ -GLE(DeleteBuffers, "DeleteBuffersARB", DELETEBUFFERSARB) \ -GLE(BindBuffer, "BindBufferARB", BINDBUFFERARB) \ -GLE(BufferData, "BufferDataARB", BUFFERDATAARB) \ -GLE(MapBuffer, "MapBufferARB", MAPBUFFERARB) \ -GLE(UnmapBuffer, "UnmapBufferARB", UNMAPBUFFERARB) \ -GLE(VertexAttribPointer, "VertexAttribPointerARB", VERTEXATTRIBPOINTERARB) \ -GLE(EnableVertexAttribArray, "EnableVertexAttribArrayARB", ENABLEVERTEXATTRIBARRAYARB) \ -GLE(DisableVertexAttribArray, "DisableVertexAttribArrayARB", DISABLEVERTEXATTRIBARRAYARB) \ -/* GL_ARB_shader_objects */ \ -GLE(CreateShader, "CreateShaderObjectARB", CREATESHADEROBJECTARB) \ -GLE(DeleteShader, "DeleteObjectARB", DELETEOBJECTARB) \ -GLE(ShaderSource, "ShaderSourceARB", SHADERSOURCEARB) \ -GLE(CompileShader, "CompileShaderARB", COMPILESHADERARB) \ -GLE(GetShaderiv, "GetObjectParameterivARB", GETOBJECTPARAMETERIVARB) \ -GLE(GetShaderInfoLog, "GetInfoLogARB", GETINFOLOGARB) \ -GLE(CreateProgram, "CreateProgramObjectARB", CREATEPROGRAMOBJECTARB) \ -GLE(DeleteProgram, "DeleteObjectARB", DELETEOBJECTARB) \ -GLE(AttachShader, "AttachObjectARB", ATTACHOBJECTARB) \ -GLE(LinkProgram, "LinkProgramARB", LINKPROGRAMARB) \ -GLE(GetUniformLocation, "GetUniformLocationARB", GETUNIFORMLOCATIONARB) \ -GLE(UseProgram, "UseProgramObjectARB", USEPROGRAMOBJECTARB) \ -GLE(GetProgramiv, "GetObjectParameterivARB", GETOBJECTPARAMETERIVARB) \ -GLE(GetProgramInfoLog, "GetInfoLogARB", GETINFOLOGARB) \ -GLE(Uniform1i, "Uniform1iARB", UNIFORM1IARB) \ -GLE(Uniform4f, "Uniform4fARB", UNIFORM4FARB) \ -GLE(Uniform4fv, "Uniform4fvARB", UNIFORM4FVARB) \ -/* GL_ARB_vertex_shader */ \ -GLE(BindAttribLocation, "BindAttribLocationARB", BINDATTRIBLOCATIONARB) \ -/* Missing from WGL but needed by shared code */ \ -GLE(Uniform1f, "Uniform1fARB", UNIFORM1FARB) \ -/* GL_EXT_framebuffer_object */ \ -GLE(GenRenderbuffers, "GenRenderbuffersEXT", GENRENDERBUFFERSEXT) \ -GLE(DeleteRenderbuffers, "DeleteRenderbuffersEXT", DELETERENDERBUFFERSEXT) \ -GLE(BindRenderbuffer, "BindRenderbufferEXT", BINDRENDERBUFFEREXT) \ -GLE(RenderbufferStorage, "RenderbufferStorageEXT", RENDERBUFFERSTORAGEEXT) \ -GLE(GenFramebuffers, "GenFramebuffersEXT", GENFRAMEBUFFERSEXT) \ -GLE(DeleteFramebuffers, "DeleteFramebuffersEXT", DELETEFRAMEBUFFERSEXT) \ -GLE(BindFramebuffer, "BindFramebufferEXT", BINDFRAMEBUFFEREXT) \ -GLE(CheckFramebufferStatus, "CheckFramebufferStatusEXT", CHECKFRAMEBUFFERSTATUSEXT) \ -GLE(FramebufferRenderbuffer, "FramebufferRenderbufferEXT", FRAMEBUFFERRENDERBUFFEREXT) \ -GLE(FramebufferTexture2D, "FramebufferTexture2DEXT", FRAMEBUFFERTEXTURE2DEXT) \ -GLE(GenerateMipmap, "GenerateMipmapEXT", GENERATEMIPMAPEXT) \ -/* GL_EXT_framebuffer_blit */ \ -GLE(BlitFramebuffer, "BlitFramebufferEXT", BLITFRAMEBUFFEREXT) \ -/* GL_EXT_framebuffer_multisample */ \ -GLE(RenderbufferStorageMultisample, "RenderbufferStorageMultisampleEXT",RENDERBUFFERSTORAGEMULTISAMPLEEXT) \ -/* */ - -#define gdraw_GLx_(id) gdraw_GL_##id -#define GDRAW_GLx_(id) GDRAW_GL_##id -#define GDRAW_SHADERS "gdraw_gl_shaders.inl" - -// On Linux, GLhandleARB is void* but shader functions use GLuint values. -// Use GLuint as our handle type, matching the Mac pattern from gdraw_gl_shared.inl. -#define GDrawGLProgram GLuint -typedef GLuint GLhandle; -typedef gdraw_gl_resourcetype gdraw_resourcetype; - -// Declare extension function pointers -#define GLE(id, import, procname) static PFNGL##procname##PROC gl##id; -GDRAW_GL_EXTENSION_LIST -#undef GLE - -static void load_extensions(void) -{ - #define GLE(id, import, procname) \ - gl##id = (PFNGL##procname##PROC) SDL_GL_GetProcAddress("gl" import); - GDRAW_GL_EXTENSION_LIST - #undef GLE -} - -static void clear_renderstate_platform_specific(void) -{ - glDisable(GL_ALPHA_TEST); -} - -static void error_msg_platform_specific(const char *msg) -{ - fprintf(stderr, "[GDraw SDL] %s\n", msg); -} - -#define GDRAW_MULTISAMPLING - -// Suppress SIGTRAP from GL debug assertions on Linux -#ifdef RR_BREAK -#undef RR_BREAK -#endif -#define RR_BREAK() \ - do { fprintf(stderr, "[GDraw] RR_BREAK suppressed (GL error)\n"); } while(0) - -#include "../../../Windows64/Iggy/gdraw/gdraw_gl_shared.inl" - -// Context creation and management - -GDrawFunctions *gdraw_GL_CreateContext(S32 w, S32 h, S32 msaa_samples) -{ - static const TextureFormatDesc tex_formats[] = { - { IFT_FORMAT_rgba_8888, 1, 1, 4, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE }, - { IFT_FORMAT_rgba_4444_LE, 1, 1, 2, GL_RGBA4, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4 }, - { IFT_FORMAT_rgba_5551_LE, 1, 1, 2, GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1 }, - { IFT_FORMAT_la_88, 1, 1, 2, GL_LUMINANCE8_ALPHA8, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE }, - { IFT_FORMAT_la_44, 1, 1, 1, GL_LUMINANCE4_ALPHA4, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE }, - { IFT_FORMAT_i_8, 1, 1, 1, GL_INTENSITY8, GL_ALPHA, GL_UNSIGNED_BYTE }, - { IFT_FORMAT_i_4, 1, 1, 1, GL_INTENSITY4, GL_ALPHA, GL_UNSIGNED_BYTE }, - { IFT_FORMAT_l_8, 1, 1, 1, GL_LUMINANCE8, GL_LUMINANCE, GL_UNSIGNED_BYTE }, - { IFT_FORMAT_l_4, 1, 1, 1, GL_LUMINANCE4, GL_LUMINANCE, GL_UNSIGNED_BYTE }, - { IFT_FORMAT_DXT1, 4, 4, 8, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, 0, GL_UNSIGNED_BYTE }, - { IFT_FORMAT_DXT3, 4, 4, 16, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, 0, GL_UNSIGNED_BYTE }, - { IFT_FORMAT_DXT5, 4, 4, 16, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, 0, GL_UNSIGNED_BYTE }, - { 0, 0, 0, 0, 0, 0, 0 }, - }; - - GDrawFunctions *funcs; - const char *s; - GLint n; - - // A current SDL2 GL context must be active before calling this, if it doesn't exist, just throw an warning- - s = (const char *) glGetString(GL_EXTENSIONS); - if (!s) { - fprintf(stderr, "[GDraw SDL] glGetString(GL_EXTENSIONS) returned NULL - " - "SDL GL context not current?\n"); - assert(s != NULL); - return NULL; - } - - // Verify required extensions - if (!hasext(s, "GL_ARB_multitexture") || - !hasext(s, "GL_ARB_texture_compression") || - !hasext(s, "GL_ARB_texture_mirrored_repeat") || - !hasext(s, "GL_ARB_texture_non_power_of_two") || - !hasext(s, "GL_ARB_vertex_buffer_object") || - !hasext(s, "GL_EXT_framebuffer_object") || - !hasext(s, "GL_ARB_shader_objects") || - !hasext(s, "GL_ARB_vertex_shader") || - !hasext(s, "GL_ARB_fragment_shader")) - { - fprintf(stderr, "[GDraw SDL] Required GL extensions not available\n"); - return NULL; - } - - if (!hasext(s, "GL_EXT_framebuffer_multisample") && msaa_samples > 1) - return NULL; - - load_extensions(); - funcs = create_context(w, h); - if (!funcs) - return NULL; - - gdraw->tex_formats = tex_formats; - - gdraw->has_mapbuffer = true; // core in ARB_vertex_buffer_object - gdraw->has_depth24 = true; - gdraw->has_texture_max_level = true; // core GL - - if (hasext(s, "GL_EXT_packed_depth_stencil")) - gdraw->has_packed_depth_stencil = true; - - glGetIntegerv(GL_MAX_TEXTURE_SIZE, &n); - gdraw->has_conditional_non_power_of_two = (n < 8192); - - if (msaa_samples > 1) { - glGetIntegerv(GL_MAX_SAMPLES, &n); - gdraw->multisampling = RR_MIN(msaa_samples, n); - } - - opengl_check(); - - fprintf(stderr, "[GDraw SDL] Context created successfully (%dx%d, msaa=%d)\n", - w, h, msaa_samples); - return funcs; -} - -void gdraw_GL_BeginCustomDraw_4J(IggyCustomDrawCallbackRegion *region, F32 *matrix) -{ - clear_renderstate(); - gdraw_GetObjectSpaceMatrix(matrix, region->o2w, gdraw->projection, depth_from_id(0), 0); -} - -void gdraw_GL_CalculateCustomDraw_4J(IggyCustomDrawCallbackRegion *region, F32 *matrix) -{ - gdraw_GetObjectSpaceMatrix(matrix, region->o2w, gdraw->projection, 0.0f, 0); -} diff --git a/Minecraft.Client/Platform/Linux/LinuxGL.cpp b/Minecraft.Client/Platform/Linux/LinuxGL.cpp index 351bb5d24..1333b5114 100644 --- a/Minecraft.Client/Platform/Linux/LinuxGL.cpp +++ b/Minecraft.Client/Platform/Linux/LinuxGL.cpp @@ -1,7 +1,6 @@ #ifdef __linux__ #include "../stdafx.h" - #include #include #include @@ -11,125 +10,138 @@ #include "../../Minecraft.World/IO/Streams/FloatBuffer.h" #include "../../Minecraft.World/IO/Streams/ByteBuffer.h" -void LinuxGLLogLightmapState(const char* stage, int textureId, bool scaleLight) { - static int logCount = 0; - if (logCount >= 16) return; +#undef glGenTextures +#undef glDeleteTextures +#undef glLight +#undef glLightModel +#undef glGetFloat +#undef glTexGen +#undef glFog +#undef glTexCoordPointer +#undef glNormalPointer +#undef glColorPointer +#undef glVertexPointer +#undef glEndList +#undef glTexImage2D +#undef glCallLists +#undef glReadPixels +#undef glActiveTexture - ++logCount; - - static bool loggedSymbols = false; - if (!loggedSymbols) { - loggedSymbols = true; - app.DebugPrintf( - "[linux-lightmap] linuxgl symbols glActiveTexture=%p " - "glClientActiveTexture=%p glMultiTexCoord2f=%p\n", - reinterpret_cast(::glActiveTexture), - reinterpret_cast(::glClientActiveTexture), - reinterpret_cast(::glMultiTexCoord2f)); - } - - GLint activeTexture = 0; - GLint matrixMode = 0; - ::glGetIntegerv(GL_ACTIVE_TEXTURE, &activeTexture); - ::glGetIntegerv(GL_MATRIX_MODE, &matrixMode); - - const GLint restoreTexture = activeTexture; - ::glActiveTexture(GL_TEXTURE1); - - GLint unit1Binding = 0; - ::glGetIntegerv(GL_TEXTURE_BINDING_2D, &unit1Binding); - const bool unit1Enabled = (::glIsEnabled(GL_TEXTURE_2D) == GL_TRUE); - - GLfloat textureMatrix[16]; - ::glGetFloatv(GL_TEXTURE_MATRIX, textureMatrix); - - ::glActiveTexture(restoreTexture); - - app.DebugPrintf( - "[linux-lightmap] %s tex=%d scale=%d active=%#x matrixMode=%#x " - "unit1Bound=%d unit1Enabled=%d texMatrix=[%.4f %.4f %.4f %.4f]\n", - stage, textureId, scaleLight ? 1 : 0, activeTexture, matrixMode, - unit1Binding, unit1Enabled ? 1 : 0, textureMatrix[0], textureMatrix[5], - textureMatrix[12], textureMatrix[13]); -} - -int glGenTextures() { - GLuint id = 0; - ::glGenTextures(1, &id); - return (int)id; -} - -void glGenTextures(IntBuffer* buf) { +// _4j suffix shit (todo: make ts better) +void glGenTextures_4J(IntBuffer* buf) { GLuint id = 0; ::glGenTextures(1, &id); buf->put((int)id); buf->flip(); } -void glDeleteTextures(int id) { - GLuint uid = (GLuint)id; - ::glDeleteTextures(1, &uid); +void glDeleteTextures_4J(IntBuffer* buf) { + if (buf && buf->limit() > 0) { + int id = buf->get(0); + GLuint uid = (GLuint)id; + ::glDeleteTextures(1, &uid); + } } -void glDeleteTextures(IntBuffer* buf) { - int id = buf->get(0); - GLuint uid = (GLuint)id; - ::glDeleteTextures(1, &uid); -} - -void glLight(int light, int pname, FloatBuffer* params) { +void glLight_4J(int light, int pname, FloatBuffer* params) { ::glLightfv((GLenum)light, (GLenum)pname, params->_getDataPointer()); } -void glLightModel(int pname, FloatBuffer* params) { +void glLightModel_4J(int pname, FloatBuffer* params) { ::glLightModelfv((GLenum)pname, params->_getDataPointer()); } -void glGetFloat(int pname, FloatBuffer* params) { +void glGetFloat_4J(int pname, FloatBuffer* params) { ::glGetFloatv((GLenum)pname, params->_getDataPointer()); } -void glTexGen(int coord, int pname, FloatBuffer* params) { +void glTexGen_4J(int coord, int pname, FloatBuffer* params) { ::glTexGenfv((GLenum)coord, (GLenum)pname, params->_getDataPointer()); } -void glFog(int pname, FloatBuffer* params) { +void glFog_4J(int pname, FloatBuffer* params) { ::glFogfv((GLenum)pname, params->_getDataPointer()); } -void glTexCoordPointer(int size, int type, FloatBuffer* pointer) { +void glTexCoordPointer_4J(int size, int type, FloatBuffer* pointer) { ::glTexCoordPointer(size, (GLenum)type, 0, pointer->_getDataPointer()); } -void glNormalPointer(int type, ByteBuffer* pointer) { +void glNormalPointer_4J(int type, ByteBuffer* pointer) { ::glNormalPointer((GLenum)type, 0, pointer->getBuffer()); } -void glColorPointer(int size, bool normalized, int stride, - ByteBuffer* pointer) { +void glColorPointer_4J(int size, bool normalized, int stride, + ByteBuffer* pointer) { (void)normalized; ::glColorPointer(size, GL_UNSIGNED_BYTE, stride, pointer->getBuffer()); } -void glVertexPointer(int size, int type, FloatBuffer* pointer) { +void glVertexPointer_4J(int size, int type, FloatBuffer* pointer) { ::glVertexPointer(size, (GLenum)type, 0, pointer->_getDataPointer()); } -void glEndList(int) { ::glEndList(); } +void glEndList_4J(int dummy) { + (void)dummy; + ::glEndList(); +} -void glTexImage2D(int target, int level, int internalformat, int width, - int height, int border, int format, int type, - ByteBuffer* pixels) { +void glTexImage2D_4J(int target, int level, int internalformat, int width, + int height, int border, int format, int type, + ByteBuffer* pixels) { void* data = pixels ? pixels->getBuffer() : nullptr; ::glTexImage2D((GLenum)target, level, internalformat, width, height, border, (GLenum)format, (GLenum)type, data); } -void glCallLists(IntBuffer* lists) { +void glCallLists_4J(IntBuffer* lists) { int count = lists->limit() - lists->position(); ::glCallLists(count, GL_INT, lists->getBuffer()); } +void glReadPixels_4J(int x, int y, int width, int height, int format, int type, + ByteBuffer* pixels) { + ::glReadPixels(x, y, width, height, (GLenum)format, (GLenum)type, + pixels->getBuffer()); +} + +void glGetFloat(int pname, FloatBuffer* params) { + glGetFloat_4J(pname, params); +} +void glGenTextures(IntBuffer* buf) { glGenTextures_4J(buf); } +void glDeleteTextures(IntBuffer* buf) { glDeleteTextures_4J(buf); } +void glLight(int light, int pname, FloatBuffer* params) { + glLight_4J(light, pname, params); +} +void glLightModel(int pname, FloatBuffer* params) { + glLightModel_4J(pname, params); +} +void glTexGen(int coord, int pname, FloatBuffer* params) { + glTexGen_4J(coord, pname, params); +} +void glFog(int pname, FloatBuffer* params) { glFog_4J(pname, params); } +void glTexCoordPointer(int size, int type, FloatBuffer* pointer) { + glTexCoordPointer_4J(size, type, pointer); +} +void glNormalPointer(int type, ByteBuffer* pointer) { + glNormalPointer_4J(type, pointer); +} +void glColorPointer(int size, bool normalized, int stride, + ByteBuffer* pointer) { + glColorPointer_4J(size, normalized, stride, pointer); +} +void glVertexPointer(int size, int type, FloatBuffer* pointer) { + glVertexPointer_4J(size, type, pointer); +} +void glTexImage2D(int t, int l, int i, int w, int h, int b, int f, int ty, + ByteBuffer* p) { + glTexImage2D_4J(t, l, i, w, h, b, f, ty, p); +} +void glCallLists(IntBuffer* lists) { glCallLists_4J(lists); } +void glReadPixels(int x, int y, int w, int h, int f, int t, ByteBuffer* p) { + glReadPixels_4J(x, y, w, h, f, t, p); +} + static PFNGLGENQUERIESARBPROC _glGenQueriesARB = nullptr; static PFNGLBEGINQUERYARBPROC _glBeginQueryARB = nullptr; static PFNGLENDQUERYARBPROC _glEndQueryARB = nullptr; @@ -148,7 +160,7 @@ static void initQueryFuncs() { RTLD_DEFAULT, "glGetQueryObjectuivARB"); } -void glGenQueriesARB(IntBuffer* buf) { +void glGenQueriesARB_4J(IntBuffer* buf) { initQueryFuncs(); if (_glGenQueriesARB) { GLuint id = 0; @@ -157,18 +169,21 @@ void glGenQueriesARB(IntBuffer* buf) { buf->flip(); } } +void glGenQueriesARB(IntBuffer* buf) { glGenQueriesARB_4J(buf); } -void glBeginQueryARB(int target, int id) { +void glBeginQueryARB_4J(int target, int id) { initQueryFuncs(); if (_glBeginQueryARB) _glBeginQueryARB((GLenum)target, (GLuint)id); } +void glBeginQueryARB(int target, int id) { glBeginQueryARB_4J(target, id); } -void glEndQueryARB(int target) { +void glEndQueryARB_4J(int target) { initQueryFuncs(); if (_glEndQueryARB) _glEndQueryARB((GLenum)target); } +void glEndQueryARB(int target) { glEndQueryARB_4J(target); } -void glGetQueryObjectuARB(int id, int pname, IntBuffer* params) { +void glGetQueryObjectuARB_4J(int id, int pname, IntBuffer* params) { initQueryFuncs(); if (_glGetQueryObjectuivARB) { GLuint val = 0; @@ -177,11 +192,30 @@ void glGetQueryObjectuARB(int id, int pname, IntBuffer* params) { params->flip(); } } - -void glReadPixels(int x, int y, int width, int height, int format, int type, - ByteBuffer* pixels) { - ::glReadPixels(x, y, width, height, (GLenum)format, (GLenum)type, - pixels->getBuffer()); +void glGetQueryObjectuARB(int id, int pname, IntBuffer* params) { + glGetQueryObjectuARB_4J(id, pname, params); } -#endif +void LinuxGLLogLightmapState(const char* stage, int textureId, + bool scaleLight) { + static int logCount = 0; + if (logCount >= 16) return; + ++logCount; + + GLint activeTexture = 0; + ::glGetIntegerv(GL_ACTIVE_TEXTURE, &activeTexture); + const GLint restoreTexture = activeTexture; + ::glActiveTexture(GL_TEXTURE1); + GLint unit1Binding = 0; + ::glGetIntegerv(GL_TEXTURE_BINDING_2D, &unit1Binding); + const bool unit1Enabled = (::glIsEnabled(GL_TEXTURE_2D) == GL_TRUE); + ::glActiveTexture(restoreTexture); + + app.DebugPrintf( + "[linux-lightmap] %s tex=%d scale=%d active=%#x unit1Bound=%d " + "unit1Enabled=%d\n", + stage, textureId, scaleLight ? 1 : 0, activeTexture, unit1Binding, + unit1Enabled ? 1 : 0); +} + +#endif \ No newline at end of file diff --git a/Minecraft.Client/Platform/Linux/Linux_UIController.cpp b/Minecraft.Client/Platform/Linux/Linux_UIController.cpp index 4a39e85ef..445fd5d9d 100644 --- a/Minecraft.Client/Platform/Linux/Linux_UIController.cpp +++ b/Minecraft.Client/Platform/Linux/Linux_UIController.cpp @@ -1,3 +1,4 @@ +// Linux_UIController.cpp #include "../../../Minecraft.World/Platform/stdafx.h" #include "Linux_UIController.h" @@ -6,34 +7,34 @@ #include "../../Textures/Textures.h" // GDraw GL backend for Linux -#include "Iggy/gdraw/gdraw_sdl.h" +#include "Iggy/gdraw/gdraw.h" +#include "4J_Render.h" ConsoleUIController ui; static void restoreFixedFunctionStateAfterIggy() { - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glEnable(GL_ALPHA_TEST); - glAlphaFunc(GL_GREATER, 0.1f); - glEnable(GL_DEPTH_TEST); - glDepthFunc(GL_LEQUAL); - glEnable(GL_CULL_FACE); - glCullFace(GL_BACK); + RenderManager.StateSetColour(1.0f, 1.0f, 1.0f, 1.0f); + RenderManager.StateSetAlphaTestEnable(true); + RenderManager.StateSetAlphaFunc(GL_GREATER, 0.1f); - glClientActiveTexture(GL_TEXTURE1); - glActiveTexture(GL_TEXTURE1); - glDisable(GL_TEXTURE_2D); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glMatrixMode(GL_TEXTURE); - glLoadIdentity(); + RenderManager.StateSetDepthTestEnable(true); + RenderManager.StateSetDepthFunc(GL_LEQUAL); + RenderManager.StateSetDepthMask(true); - glClientActiveTexture(GL_TEXTURE0); - glActiveTexture(GL_TEXTURE0); - glEnable(GL_TEXTURE_2D); - glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - glMatrixMode(GL_TEXTURE); - glLoadIdentity(); + RenderManager.StateSetFaceCull(true); + RenderManager.StateSetActiveTexture(GL_TEXTURE1); + RenderManager.StateSetTextureEnable(false); + RenderManager.MatrixMode(GL_TEXTURE); + RenderManager.MatrixSetIdentity(); - glMatrixMode(GL_MODELVIEW); + RenderManager.StateSetActiveTexture(GL_TEXTURE0); + RenderManager.StateSetTextureEnable(true); + RenderManager.MatrixMode(GL_TEXTURE); + + RenderManager.MatrixSetIdentity(); + RenderManager.MatrixMode(GL_MODELVIEW); + + RenderManager.Set_matrixDirty(); } void ConsoleUIController::init(S32 w, S32 h) { @@ -66,8 +67,11 @@ void ConsoleUIController::render() { if (!gdraw_funcs) return; gdraw_GL_SetTileOrigin(0, 0, 0); - if (!app.GetGameStarted() && gdraw_funcs->ClearID) { - gdraw_funcs->ClearID(); + if (!app.GetGameStarted()) { + glDisable(GL_SCISSOR_TEST); + glClearDepth(1.0); + glDepthMask(GL_TRUE); + glClear(GL_DEPTH_BUFFER_BIT); } // render @@ -138,4 +142,4 @@ void ConsoleUIController::shutdown() { gdraw_funcs = nullptr; } #endif -} +} \ No newline at end of file diff --git a/Minecraft.Client/Platform/stdafx.h b/Minecraft.Client/Platform/stdafx.h index aa113c2c0..e305669a7 100644 --- a/Minecraft.Client/Platform/stdafx.h +++ b/Minecraft.Client/Platform/stdafx.h @@ -5,8 +5,8 @@ #pragma once -//#include -//#include +// #include +// #include #define __STR2__(x) #x #define __STR1__(x) __STR2__(x) @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include #include @@ -49,7 +49,7 @@ #include #include #include -#include +#include #include #include "../Platform/PSVita/PSVitaExtras/PSVitaTypes.h" #include "../Platform/PSVita/PSVitaExtras/PSVitaStubs.h" @@ -71,8 +71,8 @@ typedef unsigned __int64 __uint64; #endif -#ifdef _WINDOWS64 -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#ifdef _WINDOWS64 +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers // Windows Header Files: #include #include @@ -80,14 +80,12 @@ typedef unsigned __int64 __uint64; // TODO: reference additional headers your program requires here #include #include -using namespace DirectX; +using namespace DirectX; #define HRESULT_SUCCEEDED(hr) (((HRESULT)(hr)) >= 0) #endif - - #ifdef _DURANGO #include #include @@ -95,14 +93,12 @@ using namespace DirectX; #include #include #include -using namespace DirectX; +using namespace DirectX; #include #include "../Platform/Durango/DurangoExtras/DurangoStubs.h" #define HRESULT_SUCCEEDED(hr) (((HRESULT)(hr)) >= 0) #endif - - #ifdef _XBOX #include #include @@ -166,42 +162,42 @@ typedef XUID GameSessionUID; #include "../../Minecraft.World/Util/PerformanceTimer.h" #ifdef _XBOX - #include "xbox/4JLibs/inc/4J_Input.h" - #include "xbox/4JLibs/inc/4J_Profile.h" - #include "xbox/4JLibs/inc/4J_Render.h" - #include "xbox/4JLibs/inc/4J_XTMS.h" - #include "xbox/4JLibs/inc/4J_Storage.h" -#elif defined (__PS3__) +#include "xbox/4JLibs/inc/4J_Input.h" +#include "xbox/4JLibs/inc/4J_Profile.h" +#include "xbox/4JLibs/inc/4J_Render.h" +#include "xbox/4JLibs/inc/4J_XTMS.h" +#include "xbox/4JLibs/inc/4J_Storage.h" +#elif defined(__PS3__) - #include "../Platform/PS3/4JLibs/inc/4J_Input.h" - #include "../Platform/PS3/4JLibs/inc/4J_Profile.h" - #include "../Platform/PS3/4JLibs/inc/4J_Render.h" - #include "../Platform/PS3/4JLibs/inc/4J_Storage.h" +#include "../Platform/PS3/4JLibs/inc/4J_Input.h" +#include "../Platform/PS3/4JLibs/inc/4J_Profile.h" +#include "../Platform/PS3/4JLibs/inc/4J_Render.h" +#include "../Platform/PS3/4JLibs/inc/4J_Storage.h" #elif defined _DURANGO - #include "../Platform/Durango/4JLibs/inc/4J_Input.h" - #include "../Platform/Durango/4JLibs/inc/4J_Profile.h" - #include "../Platform/Durango/4JLibs/inc/4J_Render.h" - #include "../Platform/Durango/4JLibs/inc/4J_Storage.h" +#include "../Platform/Durango/4JLibs/inc/4J_Input.h" +#include "../Platform/Durango/4JLibs/inc/4J_Profile.h" +#include "../Platform/Durango/4JLibs/inc/4J_Render.h" +#include "../Platform/Durango/4JLibs/inc/4J_Storage.h" #elif defined _WINDOWS64 - #include "../Platform/Windows64/4JLibs/inc/4J_Input.h" - #include "../Platform/Windows64/4JLibs/inc/4J_Profile.h" - #include "../Platform/Windows64/4JLibs/inc/4J_Render.h" - #include "../Platform/Windows64/4JLibs/inc/4J_Storage.h" +#include "../Platform/Windows64/4JLibs/inc/4J_Input.h" +#include "../Platform/Windows64/4JLibs/inc/4J_Profile.h" +#include "../Platform/Windows64/4JLibs/inc/4J_Render.h" +#include "../Platform/Windows64/4JLibs/inc/4J_Storage.h" #elif defined __linux__ - #include "4J_Input.h" - #include "4J_Profile.h" - #include "4J_Render.h" - #include "4J_Storage.h" +#include "4J_Input.h" +#include "4J_Profile.h" +#include "4J_Render.h" +#include "4J_Storage.h" #elif defined __PSVITA__ - #include "../Platform/PSVita/4JLibs/inc/4J_Input.h" - #include "../Platform/PSVita/4JLibs/inc/4J_Profile.h" - #include "../Platform/PSVita/4JLibs/inc/4J_Render.h" - #include "../Platform/PSVita/4JLibs/inc/4J_Storage.h" +#include "../Platform/PSVita/4JLibs/inc/4J_Input.h" +#include "../Platform/PSVita/4JLibs/inc/4J_Profile.h" +#include "../Platform/PSVita/4JLibs/inc/4J_Render.h" +#include "../Platform/PSVita/4JLibs/inc/4J_Storage.h" #else - #include "../Platform/Orbis/4JLibs/inc/4J_Input.h" - #include "../Platform/Orbis/4JLibs/inc/4J_Profile.h" - #include "../Platform/Orbis/4JLibs/inc/4J_Render.h" - #include "../Platform/Orbis/4JLibs/inc/4J_Storage.h" +#include "../Platform/Orbis/4JLibs/inc/4J_Input.h" +#include "../Platform/Orbis/4JLibs/inc/4J_Profile.h" +#include "../Platform/Orbis/4JLibs/inc/4J_Render.h" +#include "../Platform/Orbis/4JLibs/inc/4J_Storage.h" #endif #include "../Textures/Textures.h" @@ -229,7 +225,7 @@ typedef XUID GameSessionUID; #include "../Platform/Common/App_enums.h" #include "../Platform/Common/Tutorial/TutorialEnum.h" #include "../Platform/Common/App_structs.h" -//#endif +// #endif #include "../Platform/Common/Consoles_App.h" #include "../Platform/Common/Minecraft_Macros.h" @@ -242,95 +238,94 @@ typedef XUID GameSessionUID; #include "strings.h" #ifdef _XBOX - #include "../Platform/Xbox/Xbox_App.h" - #include "../Platform/Xbox/Sentient/MinecraftTelemetry.h" - #include "../Platform/Xbox/Sentient/DynamicConfigurations.h" - #include "../Platform/Xbox/Sentient/SentientTelemetryCommon.h" - #include "../Platform/Xbox/Sentient/Include/SenClientStats.h" - #include "../Platform/Xbox/GameConfig/Minecraft.spa.h" - #include "../../Minecraft.Assets/XboxMedia/4J_strings.h" - #include "../Platform/Xbox/XML/ATGXmlParser.h" - #include "../Platform/Xbox/Leaderboards/XboxLeaderboardManager.h" - #include "../Platform/Xbox/Social/SocialManager.h" - #include "../Platform/Xbox/Audio/SoundEngine.h" - #include "../Platform/Xbox/Xbox_UIController.h" +#include "../Platform/Xbox/Xbox_App.h" +#include "../Platform/Xbox/Sentient/MinecraftTelemetry.h" +#include "../Platform/Xbox/Sentient/DynamicConfigurations.h" +#include "../Platform/Xbox/Sentient/SentientTelemetryCommon.h" +#include "../Platform/Xbox/Sentient/Include/SenClientStats.h" +#include "../Platform/Xbox/GameConfig/Minecraft.spa.h" +#include "../../Minecraft.Assets/XboxMedia/4J_strings.h" +#include "../Platform/Xbox/XML/ATGXmlParser.h" +#include "../Platform/Xbox/Leaderboards/XboxLeaderboardManager.h" +#include "../Platform/Xbox/Social/SocialManager.h" +#include "../Platform/Xbox/Audio/SoundEngine.h" +#include "../Platform/Xbox/Xbox_UIController.h" -#elif defined (__PS3__) - #include "extraX64client.h" - #include "../Platform/PS3/Sentient/MinecraftTelemetry.h" - #include "../Platform/PS3/Sentient/DynamicConfigurations.h" - #include "../Platform/PS3/Sentient/SentientTelemetryCommon.h" - #include "../Platform/PS3/PS3_App.h" - #include "../Platform/PS3/GameConfig/Minecraft.spa.h" - #include "../../Minecraft.Assets/PS3Media/4J_strings.h" - #include "../Platform/PS3/XML/ATGXmlParser.h" - #include "../Platform/PS3/Social/SocialManager.h" - #include "../Platform/Common/Audio/SoundEngine.h" - #include "../Platform/PS3/Iggy/include/iggy.h" - #include "../Platform/PS3/Iggy/gdraw/gdraw_ps3gcm.h" - #include "../Platform/PS3/PS3_UIController.h" +#elif defined(__PS3__) +#include "extraX64client.h" +#include "../Platform/PS3/Sentient/MinecraftTelemetry.h" +#include "../Platform/PS3/Sentient/DynamicConfigurations.h" +#include "../Platform/PS3/Sentient/SentientTelemetryCommon.h" +#include "../Platform/PS3/PS3_App.h" +#include "../Platform/PS3/GameConfig/Minecraft.spa.h" +#include "../../Minecraft.Assets/PS3Media/4J_strings.h" +#include "../Platform/PS3/XML/ATGXmlParser.h" +#include "../Platform/PS3/Social/SocialManager.h" +#include "../Platform/Common/Audio/SoundEngine.h" +#include "../Platform/PS3/Iggy/include/iggy.h" +#include "../Platform/PS3/Iggy/gdraw/gdraw_ps3gcm.h" +#include "../Platform/PS3/PS3_UIController.h" #elif defined _DURANGO - #include "../Platform/Durango/Sentient/MinecraftTelemetry.h" - #include "../Platform/Durango/Durango_App.h" - #include "../Platform/Durango/Sentient/DynamicConfigurations.h" - #include "../Platform/Durango/Sentient/TelemetryEnum.h" - #include "../Platform/Durango/Sentient/SentientTelemetryCommon.h" - #include "../Platform/Durango/PresenceIds.h" - #include "../../Minecraft.Assets/DurangoMedia/4J_strings.h" - #include "../Platform/Durango/XML/ATGXmlParser.h" - #include "../Platform/Durango/Social/SocialManager.h" - #include "../Platform/Common/Audio/SoundEngine.h" - #include "../Platform/Durango/Iggy/include/iggy.h" - #include "../Platform/Durango/Iggy/gdraw/gdraw_d3d11.h" - #include "../Platform/Durango/Durango_UIController.h" +#include "../Platform/Durango/Sentient/MinecraftTelemetry.h" +#include "../Platform/Durango/Durango_App.h" +#include "../Platform/Durango/Sentient/DynamicConfigurations.h" +#include "../Platform/Durango/Sentient/TelemetryEnum.h" +#include "../Platform/Durango/Sentient/SentientTelemetryCommon.h" +#include "../Platform/Durango/PresenceIds.h" +#include "../../Minecraft.Assets/DurangoMedia/4J_strings.h" +#include "../Platform/Durango/XML/ATGXmlParser.h" +#include "../Platform/Durango/Social/SocialManager.h" +#include "../Platform/Common/Audio/SoundEngine.h" +#include "../Platform/Durango/Iggy/include/iggy.h" +#include "../Platform/Durango/Iggy/gdraw/gdraw_d3d11.h" +#include "../Platform/Durango/Durango_UIController.h" #elif defined _WINDOWS64 - #include "../Platform/Windows64/Sentient/MinecraftTelemetry.h" - #include "../Platform/Windows64/Windows64_App.h" - #include "../Platform/Windows64/Sentient/DynamicConfigurations.h" - #include "../Platform/Windows64/Sentient/SentientTelemetryCommon.h" - #include "../Platform/Windows64/GameConfig/Minecraft.spa.h" - #include "../Platform/Windows64/XML/ATGXmlParser.h" - #include "../Platform/Windows64/Social/SocialManager.h" - #include "../Platform/Common/Audio/SoundEngine.h" - #include "../Platform/Windows64/Iggy/include/iggy.h" - #include "../Platform/Windows64/Iggy/gdraw/gdraw_d3d11.h" - #include "../Platform/Windows64/Windows64_UIController.h" +#include "../Platform/Windows64/Sentient/MinecraftTelemetry.h" +#include "../Platform/Windows64/Windows64_App.h" +#include "../Platform/Windows64/Sentient/DynamicConfigurations.h" +#include "../Platform/Windows64/Sentient/SentientTelemetryCommon.h" +#include "../Platform/Windows64/GameConfig/Minecraft.spa.h" +#include "../Platform/Windows64/XML/ATGXmlParser.h" +#include "../Platform/Windows64/Social/SocialManager.h" +#include "../Platform/Common/Audio/SoundEngine.h" +#include "../Platform/Windows64/Iggy/include/iggy.h" +#include "../Platform/Windows64/Iggy/gdraw/gdraw_d3d11.h" +#include "../Platform/Windows64/Windows64_UIController.h" #elif defined __linux__ - // Linux build: avoid pulling in Windows64 platform headers (they cause - // symbol/class redefinitions). Use Orbis-compatible stubs and Linux controller. - #include "../Platform/Linux/Linux_App.h" - #include "../Platform/Linux/Iggy/include/iggy.h" - #include "../Platform/Linux/Sentient/SentientTelemetryCommon.h" - #include "../Platform/Linux/Sentient/DynamicConfigurations.h" - #include "../Platform/Orbis/GameConfig/Minecraft.spa.h" - #include "../Platform/Common/Audio/SoundEngine.h" - #include "../Platform/Linux/Linux_UIController.h" - #include "../Platform/Linux/Social/SocialManager.h" +// todo: cleanup ts +#include "../Platform/Linux/Linux_App.h" +#include "../Platform/Linux/Iggy/include/iggy.h" +#include "../Platform/Linux/Sentient/SentientTelemetryCommon.h" +#include "../Platform/Linux/Sentient/DynamicConfigurations.h" +#include "../Platform/Orbis/GameConfig/Minecraft.spa.h" +#include "../Platform/Common/Audio/SoundEngine.h" +#include "../Platform/Linux/Linux_UIController.h" +#include "../Platform/Linux/Social/SocialManager.h" #elif defined __PSVITA__ - #include "../Platform/PSVita/PSVita_App.h" - #include "../Platform/PSVita/Sentient/SentientManager.h" - #include "../Platform/PSVita/Sentient/MinecraftTelemetry.h" - #include "../Platform/PSVita/Sentient/DynamicConfigurations.h" - #include "../Platform/PSVita/GameConfig/Minecraft.spa.h" - #include "../Platform/PSVita/XML/ATGXmlParser.h" - #include "../Platform/PSVita/Social/SocialManager.h" - #include "../Platform/Common/Audio/SoundEngine.h" - #include "../Platform/PSVita/Iggy/include/iggy.h" - #include "../Platform/PSVita/Iggy/gdraw/gdraw_psp2.h" - #include "../Platform/PSVita/PSVita_UIController.h" +#include "../Platform/PSVita/PSVita_App.h" +#include "../Platform/PSVita/Sentient/SentientManager.h" +#include "../Platform/PSVita/Sentient/MinecraftTelemetry.h" +#include "../Platform/PSVita/Sentient/DynamicConfigurations.h" +#include "../Platform/PSVita/GameConfig/Minecraft.spa.h" +#include "../Platform/PSVita/XML/ATGXmlParser.h" +#include "../Platform/PSVita/Social/SocialManager.h" +#include "../Platform/Common/Audio/SoundEngine.h" +#include "../Platform/PSVita/Iggy/include/iggy.h" +#include "../Platform/PSVita/Iggy/gdraw/gdraw_psp2.h" +#include "../Platform/PSVita/PSVita_UIController.h" #else - #include "../Platform/Orbis/Sentient/MinecraftTelemetry.h" - #include "../Platform/Orbis/Orbis_App.h" - #include "../Platform/Orbis/Sentient/SentientTelemetryCommon.h" - #include "../Platform/Orbis/Sentient/DynamicConfigurations.h" - #include "../Platform/Orbis/GameConfig/Minecraft.spa.h" - #include "../../Minecraft.Assets/OrbisMedia/4J_strings.h" - #include "../Platform/Orbis/XML/ATGXmlParser.h" - #include "../Platform/Windows64/Social/SocialManager.h" - #include "../Platform/Common/Audio/SoundEngine.h" - #include "../Platform/Orbis/Iggy/include/iggy.h" - #include "../Platform/Orbis/Iggy/gdraw/gdraw_orbis.h" - #include "../Platform/Orbis/Orbis_UIController.h" +#include "../Platform/Orbis/Sentient/MinecraftTelemetry.h" +#include "../Platform/Orbis/Orbis_App.h" +#include "../Platform/Orbis/Sentient/SentientTelemetryCommon.h" +#include "../Platform/Orbis/Sentient/DynamicConfigurations.h" +#include "../Platform/Orbis/GameConfig/Minecraft.spa.h" +#include "../../Minecraft.Assets/OrbisMedia/4J_strings.h" +#include "../Platform/Orbis/XML/ATGXmlParser.h" +#include "../Platform/Windows64/Social/SocialManager.h" +#include "../Platform/Common/Audio/SoundEngine.h" +#include "../Platform/Orbis/Iggy/include/iggy.h" +#include "../Platform/Orbis/Iggy/gdraw/gdraw_orbis.h" +#include "../Platform/Orbis/Orbis_UIController.h" #endif #ifdef _XBOX @@ -358,13 +353,11 @@ typedef XUID GameSessionUID; #include "../Platform/Common/Telemetry/TelemetryManager.h" #ifdef _XBOX -//#include "../Platform/Xbox/Xbox_App.h" +// #include "../Platform/Xbox/Xbox_App.h" #elif !defined(__PS3__) #include "extraX64client.h" #endif - - #ifdef _FINAL_BUILD #define printf BREAKTHECOMPILE #define wprintf BREAKTHECOMPILE diff --git a/Minecraft.Client/Platform/stubs.h b/Minecraft.Client/Platform/stubs.h index 91464c6a8..9841637ca 100644 --- a/Minecraft.Client/Platform/stubs.h +++ b/Minecraft.Client/Platform/stubs.h @@ -13,30 +13,32 @@ class FloatBuffer; class IntBuffer; class ByteBuffer; -void glGenTextures(IntBuffer *); +void glGenTextures(IntBuffer*); int glGenTextures(); -void glDeleteTextures(IntBuffer *); +void glDeleteTextures(IntBuffer*); void glDeleteTextures(int); -void glLight(int, int, FloatBuffer *); -void glLightModel(int, FloatBuffer *); -void glGetFloat(int, FloatBuffer *); -void glTexGen(int, int, FloatBuffer *); -void glFog(int, FloatBuffer *); -void glTexCoordPointer(int, int, FloatBuffer *); -void glNormalPointer(int, ByteBuffer *); -void glColorPointer(int, bool, int, ByteBuffer *); -void glVertexPointer(int, int, FloatBuffer *); -void glEndList(int); -void glTexImage2D(int, int, int, int, int, int, int, int, ByteBuffer *); -void glCallLists(IntBuffer *); -void glGenQueriesARB(IntBuffer *); +void glLight(int, int, FloatBuffer*); +void glLightModel(int, FloatBuffer*); +void glGetFloat(int, FloatBuffer*); +void glTexGen(int, int, FloatBuffer*); +void glFog(int, FloatBuffer*); +void glTexCoordPointer(int, int, FloatBuffer*); +void glNormalPointer(int, ByteBuffer*); +void glColorPointer(int, bool, int, ByteBuffer*); +void glVertexPointer(int, int, FloatBuffer*); + +void glEndList_4J(int vertexCount = 0); + +void glTexImage2D(int, int, int, int, int, int, int, int, ByteBuffer*); +void glCallLists(IntBuffer*); +void glGenQueriesARB(IntBuffer*); void glBeginQueryARB(int, int); void glEndQueryARB(int); -void glGetQueryObjectuARB(int, int, IntBuffer *); -void glReadPixels(int, int, int, int, int, int, ByteBuffer *); +void glGetQueryObjectuARB(int, int, IntBuffer*); +void glReadPixels(int, int, int, int, int, int, ByteBuffer*); + void LinuxGLLogLightmapState(const char* stage, int textureId, bool scaleLight); void LinuxLogStubLightmapProbe(); - #else const int GL_BYTE = 0; @@ -54,13 +56,9 @@ const int GL_NORMALIZE = 0; const int GL_RESCALE_NORMAL = 0; - - const int GL_SMOOTH = 0; const int GL_FLAT = 0; - - const int GL_RGBA = 0; const int GL_BGRA = 1; const int GL_BGR = 0; @@ -83,73 +81,73 @@ const int GL_TEXTURE1 = 0; const int GL_TEXTURE0 = 1; void glFlush(); -void glTexGeni(int,int,int); -void glTexGen(int,int,FloatBuffer *); -void glReadPixels(int,int, int, int, int, int, ByteBuffer *); +void glTexGeni(int, int, int); +void glTexGen(int, int, FloatBuffer*); +void glReadPixels(int, int, int, int, int, int, ByteBuffer*); void glClearDepth(double); void glCullFace(int); -void glDeleteLists(int,int); -void glGenTextures(IntBuffer *); +void glDeleteLists(int, int); +void glGenTextures(IntBuffer*); int glGenTextures(); int glGenLists(int); -void glLight(int, int,FloatBuffer *); -void glLightModel(int, FloatBuffer *); -void glGetFloat(int a, FloatBuffer *b); +void glLight(int, int, FloatBuffer*); +void glLightModel(int, FloatBuffer*); +void glGetFloat(int a, FloatBuffer* b); void glTexCoordPointer(int, int, int, int); -void glTexCoordPointer(int, int, FloatBuffer *); +void glTexCoordPointer(int, int, FloatBuffer*); void glNormalPointer(int, int, int); -void glNormalPointer(int, ByteBuffer *); +void glNormalPointer(int, ByteBuffer*); void glEnableClientState(int); void glDisableClientState(int); -void glColorPointer(int, bool, int, ByteBuffer *); +void glColorPointer(int, bool, int, ByteBuffer*); void glColorPointer(int, int, int, int); void glVertexPointer(int, int, int, int); -void glVertexPointer(int, int, FloatBuffer *); -void glDrawArrays(int,int,int); -void glTranslatef(float,float,float); -void glRotatef(float,float,float,float); -void glNewList(int,int); +void glVertexPointer(int, int, FloatBuffer*); +void glDrawArrays(int, int, int); +void glTranslatef(float, float, float); +void glRotatef(float, float, float, float); +void glNewList(int, int); void glEndList(int vertexCount = 0); void glCallList(int); void glPopMatrix(); void glPushMatrix(); -void glColor3f(float,float,float); -void glScalef(float,float,float); -void glMultMatrixf(float *); -void glColor4f(float,float,float,float); +void glColor3f(float, float, float); +void glScalef(float, float, float); +void glMultMatrixf(float*); +void glColor4f(float, float, float, float); void glDisable(int); void glEnable(int); -void glBlendFunc(int,int); +void glBlendFunc(int, int); void glDepthMask(bool); -void glNormal3f(float,float,float); +void glNormal3f(float, float, float); void glDepthFunc(int); void glMatrixMode(int); void glLoadIdentity(); -void glBindTexture(int,int); -void glTexParameteri(int,int,int); -void glTexImage2D(int,int,int,int,int,int,int,int,ByteBuffer *); -void glDeleteTextures(IntBuffer *); +void glBindTexture(int, int); +void glTexParameteri(int, int, int); +void glTexImage2D(int, int, int, int, int, int, int, int, ByteBuffer*); +void glDeleteTextures(IntBuffer*); void glDeleteTextures(int); -void glCallLists(IntBuffer *); -void glGenQueriesARB(IntBuffer *); -void glColorMask(bool,bool,bool,bool); -void glBeginQueryARB(int,int); +void glCallLists(IntBuffer*); +void glGenQueriesARB(IntBuffer*); +void glColorMask(bool, bool, bool, bool); +void glBeginQueryARB(int, int); void glEndQueryARB(int); -void glGetQueryObjectuARB(int,int,IntBuffer *); +void glGetQueryObjectuARB(int, int, IntBuffer*); void glShadeModel(int); -void glPolygonOffset(float,float); +void glPolygonOffset(float, float); void glLineWidth(float); -void glScaled(double,double,double); -void gluPerspective(float,float,float,float); +void glScaled(double, double, double); +void gluPerspective(float, float, float, float); void glClear(int); -void glViewport(int,int,int,int); -void glAlphaFunc(int,float); -void glOrtho(float,float,float,float,float,float); -void glClearColor(float,float,float,float); -void glFogi(int,int); -void glFogf(int,float); -void glFog(int,FloatBuffer *); -void glColorMaterial(int,int); +void glViewport(int, int, int, int); +void glAlphaFunc(int, float); +void glOrtho(float, float, float, float, float, float); +void glClearColor(float, float, float, float); +void glFogi(int, int); +void glFogf(int, float); +void glFog(int, FloatBuffer*); +void glColorMaterial(int, int); void glMultiTexCoord2f(int, float, float); void glClientActiveTexture(int); @@ -158,164 +156,150 @@ void glActiveTexture(int); #endif #ifdef __linux__ -class GL11 -{ -public: - static const int GL_SMOOTH = 0x1D01; - static const int GL_FLAT = 0x1D00; - static void glShadeModel(int mode) { ::glShadeModel(mode); } -}; +class GL11 { +public: + static const int GL_SMOOTH = 0x1D01; + static const int GL_FLAT = 0x1D00; +#undef glShadeModel +#define GL_SHADEMODEL_IS_FUNCTION + static void glShadeModel(int mode) { ::glShadeModel(mode); } +}; #undef GL_ARRAY_BUFFER_ARB #undef GL_STREAM_DRAW_ARB -class ARBVertexBufferObject -{ +class ARBVertexBufferObject { public: - static const int GL_ARRAY_BUFFER_ARB = 0x8892; - static const int GL_STREAM_DRAW_ARB = 0x88E0; - static void glBindBufferARB(int, int) {} - static void glBufferDataARB(int, ByteBuffer *, int) {} - static void glGenBuffersARB(IntBuffer *) {} + static const int GL_ARRAY_BUFFER_ARB = 0x8892; + static const int GL_STREAM_DRAW_ARB = 0x88E0; + static void glBindBufferARB(int, int) {} + static void glBufferDataARB(int, ByteBuffer*, int) {} + static void glGenBuffersARB(IntBuffer*) {} }; #else -class GL11 -{ +class GL11 { public: - static const int GL_SMOOTH = 0; - static const int GL_FLAT = 0; - static void glShadeModel(int) {}; + static const int GL_SMOOTH = 0; + static const int GL_FLAT = 0; + static void glShadeModel(int) {}; }; -class ARBVertexBufferObject -{ +class ARBVertexBufferObject { public: - static const int GL_ARRAY_BUFFER_ARB = 0; - static const int GL_STREAM_DRAW_ARB = 0; - static void glBindBufferARB(int, int) {} - static void glBufferDataARB(int, ByteBuffer *, int) {} - static void glGenBuffersARB(IntBuffer *) {} + static const int GL_ARRAY_BUFFER_ARB = 0; + static const int GL_STREAM_DRAW_ARB = 0; + static void glBindBufferARB(int, int) {} + static void glBufferDataARB(int, ByteBuffer*, int) {} + static void glGenBuffersARB(IntBuffer*) {} }; #endif - class Level; class Player; class Textures; class Font; class MapItemSavedData; class Mob; -class Particles -{ +class Particles { public: - void render(float) {} - void tick() {} + void render(float) {} + void tick() {} }; class BufferedImage; -class Graphics -{ +class Graphics { public: - void drawImage(BufferedImage *, int, int, void *) {} - void dispose() {} + void drawImage(BufferedImage*, int, int, void*) {} + void dispose() {} }; -class ZipEntry -{ -}; +class ZipEntry {}; class InputStream; class File; -class ZipFile -{ +class ZipFile { public: - ZipFile(File *file) {} - InputStream *getInputStream(ZipEntry *entry) { return NULL; } - ZipEntry *getEntry(const std::wstring& name) {return NULL;} - void close() {} + ZipFile(File* file) {} + InputStream* getInputStream(ZipEntry* entry) { return NULL; } + ZipEntry* getEntry(const std::wstring& name) { return NULL; } + void close() {} }; -class ImageIO -{ +class ImageIO { public: - static BufferedImage *read(InputStream *in) { return NULL; } + static BufferedImage* read(InputStream* in) { return NULL; } }; -class Keyboard -{ +class Keyboard { public: - static void create() {} - static void destroy() {} - static bool isKeyDown(int) {return false;} - static std::wstring getKeyName(int) { return L"KEYNAME"; } - static void enableRepeatEvents(bool) {} - static const int KEY_A = 0; - static const int KEY_B = 1; - static const int KEY_C = 2; - static const int KEY_D = 3; - static const int KEY_E = 4; - static const int KEY_F = 5; - static const int KEY_G = 6; - static const int KEY_H = 7; - static const int KEY_I = 8; - static const int KEY_J = 9; - static const int KEY_K = 10; - static const int KEY_L = 11; - static const int KEY_M = 12; - static const int KEY_N = 13; - static const int KEY_O = 14; - static const int KEY_P = 15; - static const int KEY_Q = 16; - static const int KEY_R = 17; - static const int KEY_S = 18; - static const int KEY_T = 19; - static const int KEY_U = 20; - static const int KEY_V = 21; - static const int KEY_W = 22; - static const int KEY_X = 23; - static const int KEY_Y = 24; - static const int KEY_Z = 25; - static const int KEY_SPACE = 26; - static const int KEY_LSHIFT = 27; - static const int KEY_ESCAPE = 28; - static const int KEY_BACK = 29; - static const int KEY_RETURN = 30; - static const int KEY_RSHIFT = 31; - static const int KEY_UP = 32; - static const int KEY_DOWN = 33; - static const int KEY_TAB = 34; + static void create() {} + static void destroy() {} + static bool isKeyDown(int) { return false; } + static std::wstring getKeyName(int) { return L"KEYNAME"; } + static void enableRepeatEvents(bool) {} + static const int KEY_A = 0; + static const int KEY_B = 1; + static const int KEY_C = 2; + static const int KEY_D = 3; + static const int KEY_E = 4; + static const int KEY_F = 5; + static const int KEY_G = 6; + static const int KEY_H = 7; + static const int KEY_I = 8; + static const int KEY_J = 9; + static const int KEY_K = 10; + static const int KEY_L = 11; + static const int KEY_M = 12; + static const int KEY_N = 13; + static const int KEY_O = 14; + static const int KEY_P = 15; + static const int KEY_Q = 16; + static const int KEY_R = 17; + static const int KEY_S = 18; + static const int KEY_T = 19; + static const int KEY_U = 20; + static const int KEY_V = 21; + static const int KEY_W = 22; + static const int KEY_X = 23; + static const int KEY_Y = 24; + static const int KEY_Z = 25; + static const int KEY_SPACE = 26; + static const int KEY_LSHIFT = 27; + static const int KEY_ESCAPE = 28; + static const int KEY_BACK = 29; + static const int KEY_RETURN = 30; + static const int KEY_RSHIFT = 31; + static const int KEY_UP = 32; + static const int KEY_DOWN = 33; + static const int KEY_TAB = 34; }; -class Mouse -{ +class Mouse { public: - static void create() {} - static void destroy() {} - static int getX() { return 0; } - static int getY() { return 0; } - static bool isButtonDown(int) { return false; } + static void create() {} + static void destroy() {} + static int getX() { return 0; } + static int getY() { return 0; } + static bool isButtonDown(int) { return false; } }; -class Display -{ +class Display { public: - static bool isActive() {return true;} - static void update(); - static void swapBuffers(); - static void destroy() {} + static bool isActive() { return true; } + static void update(); + static void swapBuffers(); + static void destroy() {} }; -class BackgroundDownloader -{ +class BackgroundDownloader { public: - BackgroundDownloader(File workDir, Minecraft* minecraft) {} - void start() {} - void halt() {} - void forceReload() {} + BackgroundDownloader(File workDir, Minecraft* minecraft) {} + void start() {} + void halt() {} + void forceReload() {} }; -class Color -{ +class Color { public: - static int HSBtoRGB(float,float,float) {return 0;} + static int HSBtoRGB(float, float, float) { return 0; } };