Try to be more compatible with older systems

This commit is contained in:
UnknownShadow200 2024-06-19 12:31:30 +10:00
parent e8f6800096
commit edf81f7a71
13 changed files with 125 additions and 15 deletions

110
misc/linux/min-glx.h Normal file
View file

@ -0,0 +1,110 @@
/*
* Mesa 3-D graphics library
*
* Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef GLX_H
#define GLX_H
#include <X11/Xlib.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* Tokens for glXChooseVisual and glXGetConfig:
*/
#define GLX_USE_GL 1
#define GLX_BUFFER_SIZE 2
#define GLX_LEVEL 3
#define GLX_RGBA 4
#define GLX_DOUBLEBUFFER 5
#define GLX_STEREO 6
#define GLX_AUX_BUFFERS 7
#define GLX_RED_SIZE 8
#define GLX_GREEN_SIZE 9
#define GLX_BLUE_SIZE 10
#define GLX_ALPHA_SIZE 11
#define GLX_DEPTH_SIZE 12
#define GLX_STENCIL_SIZE 13
typedef struct __GLXcontextRec *GLXContext;
typedef XID GLXDrawable;
/* GLX 1.3 and later */
typedef struct __GLXFBConfigRec *GLXFBConfig;
typedef XID GLXFBConfigID;
typedef XID GLXContextID;
typedef XID GLXWindow;
extern XVisualInfo* glXChooseVisual( Display *dpy, int screen,
int *attribList );
extern GLXContext glXCreateContext( Display *dpy, XVisualInfo *vis,
GLXContext shareList, Bool direct );
extern void glXDestroyContext( Display *dpy, GLXContext ctx );
extern Bool glXMakeCurrent( Display *dpy, GLXDrawable drawable,
GLXContext ctx);
extern void glXSwapBuffers( Display *dpy, GLXDrawable drawable );
extern Bool glXQueryVersion( Display *dpy, int *maj, int *min );
extern Bool glXIsDirect( Display *dpy, GLXContext ctx );
/* GLX 1.1 and later */
extern const char *glXQueryExtensionsString( Display *dpy, int screen );
/* GLX 1.3 and later */
extern GLXFBConfig *glXChooseFBConfig( Display *dpy, int screen,
const int *attribList, int *nitems );
extern GLXFBConfig *glXGetFBConfigs( Display *dpy, int screen,
int *nelements );
extern XVisualInfo *glXGetVisualFromFBConfig( Display *dpy,
GLXFBConfig config );
/*
* ARB 2. GLX_ARB_get_proc_address
*/
typedef void (*__GLXextFuncPtr)(void);
extern __GLXextFuncPtr glXGetProcAddressARB (const char *);
/* GLX 1.4 and later */
extern void (*glXGetProcAddress(const char *procname))( void );
/* GLX 1.4 function pointer typedefs */
typedef __GLXextFuncPtr (* PFNGLXGETPROCADDRESSPROC) (const char *procName);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -60,4 +60,4 @@ GL_FUNC(void, glBegin)(GLenum mode);
GL_FUNC(void, glEnd)(void);
GL_FUNC(void, glColor4ub)(GLubyte r, GLubyte g, GLubyte b, GLubyte a);
GL_FUNC(void, glTexCoord2f)(float u, float v);
GL_FUNC(void, glVertex3f)(float x, float y, float z);
GL_FUNC(void, glVertex3f)(float x, float y, float z);

View file

@ -99,4 +99,4 @@ typedef cc_uintptr GLpointer;
#define GL_VERTEX_SHADER 0x8B31
#define GL_COMPILE_STATUS 0x8B81
#define GL_LINK_STATUS 0x8B82
#define GL_INFO_LOG_LENGTH 0x8B84
#define GL_INFO_LOG_LENGTH 0x8B84

View file

@ -198,4 +198,4 @@ void Event_RaiseLightingMode(struct Event_LightingMode* handlers, cc_uint8 oldMo
for (i = 0; i < handlers->Count; i++) {
handlers->Handlers[i](handlers->Objs[i], oldMode, fromServer);
}
}
}

View file

@ -465,4 +465,4 @@ float Math_Atan2f(float x, float y) {
}
double Math_Sin(double x) { return Math_SinF(x); }
double Math_Cos(double x) { return Math_CosF(x); }
double Math_Cos(double x) { return Math_CosF(x); }

View file

@ -13,7 +13,6 @@
#include "Options.h"
#include "Queue.h"
struct LightNode {
IVec3 coords; /* 12 bytes */
cc_uint8 brightness; /* 1 byte */
@ -577,4 +576,4 @@ static void OnEnvVariableChanged(void* obj, int envVar) {
void FancyLighting_OnInit(void) {
Event_Register_(&WorldEvents.EnvVarChanged, NULL, OnEnvVariableChanged);
}
}

View file

@ -611,4 +611,4 @@ static void LBackend_InitHooks(void) {
JavaGetCurrentEnv(env);
JavaRegisterNatives(env, methods);
}
#endif
#endif

View file

@ -472,4 +472,4 @@ struct IGameComponent Lighting_Component = {
OnReset, /* Reset */
OnReset, /* OnNewMap */
OnNewMapLoaded /* OnNewMapLoaded */
};
};

View file

@ -69,4 +69,4 @@ void* Queue_Dequeue(struct Queue* queue) {
queue->head = (queue->head + 1) & queue->mask;
queue->count--;
return result;
}
}

View file

@ -1,7 +1,6 @@
#include "Core.h"
#ifndef CC_QUEUE_H
#define CC_QUEUE_H
#include "Core.h"
struct Queue {
cc_uint8* entries; /* Buffer holding the bytes of the queue */
@ -19,4 +18,4 @@ void Queue_Enqueue(struct Queue* queue, void* item);
void* Queue_Dequeue(struct Queue* queue);
/* Frees the memory of the queue and resets the members to 0. */
void Queue_Clear(struct Queue* queue);
#endif
#endif

View file

@ -1024,4 +1024,4 @@ int WordWrap_GetForwardLength(const cc_string* text, int index) {
while (index < length && text->buffer[index] == ' ') index++;
return index - start;
}
}

View file

@ -249,4 +249,4 @@ void GLContext_SetFpsLimit(cc_bool vsync, float minFrameMs);
void GLContext_GetApiInfo(cc_string* info);
#endif
#endif
#endif

View file

@ -1315,7 +1315,9 @@ void Window_DisableRawMouse(void) {
*-------------------------------------------------------glX OpenGL--------------------------------------------------------*
*#########################################################################################################################*/
#if (CC_GFX_BACKEND & CC_GFX_BACKEND_GL_MASK) && !defined CC_BUILD_EGL
#include <GL/glx.h>
/* #include <GL/glx.h> */
#include "../misc/linux/min-glx.h"
static GLXContext ctx_handle;
typedef int (*FP_SWAPINTERVAL)(int interval);
typedef Bool (*FP_QUERYRENDERER)(int attribute, unsigned int* value);