Compiles with less warnings

This commit is contained in:
UnknownShadow200 2023-12-10 10:49:11 +11:00
parent 740c2416d7
commit ce125de895
4 changed files with 47 additions and 47 deletions

View File

@ -8,18 +8,8 @@
* - OpenGL 1.5 or OpenGL 1.2 + GL_ARB_vertex_buffer_object (default desktop backend) * - OpenGL 1.5 or OpenGL 1.2 + GL_ARB_vertex_buffer_object (default desktop backend)
*/ */
#if defined CC_BUILD_WIN
/* Avoid pointless includes */
#define WIN32_LEAN_AND_MEAN
#define NOSERVICE
#define NOMCX
#define NOIME
#include <windows.h>
#define GLAPI WINGDIAPI
#else
#define GLAPI extern #define GLAPI extern
#define APIENTRY #define APIENTRY
#endif
/* === BEGIN OPENGL HEADERS === */ /* === BEGIN OPENGL HEADERS === */
typedef unsigned int GLenum; typedef unsigned int GLenum;
typedef unsigned char GLboolean; typedef unsigned char GLboolean;
@ -31,6 +21,14 @@ typedef unsigned int GLuint;
typedef float GLfloat; typedef float GLfloat;
typedef void GLvoid; typedef void GLvoid;
/* NOTE: With the OpenGL 1.1 backend "pointer" arguments are actual pointers,
/* but with VBOs they are just offsets instead */
#ifdef CC_BUILD_GL11
typedef const void* GLpointer;
#else
typedef cc_uintptr GLpointer;
#endif
#define GL_LEQUAL 0x0203 #define GL_LEQUAL 0x0203
#define GL_GREATER 0x0204 #define GL_GREATER 0x0204
@ -103,7 +101,7 @@ GLAPI void APIENTRY glCallList(GLuint list);
GLAPI void APIENTRY glClear(GLuint mask); GLAPI void APIENTRY glClear(GLuint mask);
GLAPI void APIENTRY glClearColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); GLAPI void APIENTRY glClearColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
GLAPI void APIENTRY glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); GLAPI void APIENTRY glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
GLAPI void APIENTRY glColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer); GLAPI void APIENTRY glColorPointer(GLint size, GLenum type, GLsizei stride, GLpointer pointer);
GLAPI void APIENTRY glDeleteLists(GLuint list, GLsizei range); GLAPI void APIENTRY glDeleteLists(GLuint list, GLsizei range);
GLAPI void APIENTRY glDeleteTextures(GLsizei n, const GLuint* textures); GLAPI void APIENTRY glDeleteTextures(GLsizei n, const GLuint* textures);
GLAPI void APIENTRY glDepthFunc(GLenum func); GLAPI void APIENTRY glDepthFunc(GLenum func);
@ -131,11 +129,11 @@ GLAPI void APIENTRY glLoadMatrixf(const GLfloat* m);
GLAPI void APIENTRY glMatrixMode(GLenum mode); GLAPI void APIENTRY glMatrixMode(GLenum mode);
GLAPI void APIENTRY glNewList(GLuint list, GLenum mode); GLAPI void APIENTRY glNewList(GLuint list, GLenum mode);
GLAPI void APIENTRY glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels); GLAPI void APIENTRY glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels);
GLAPI void APIENTRY glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer); GLAPI void APIENTRY glTexCoordPointer(GLint size, GLenum type, GLsizei stride, GLpointer pointer);
GLAPI void APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels); GLAPI void APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels);
GLAPI void APIENTRY glTexParameteri(GLenum target, GLenum pname, GLint param); GLAPI void APIENTRY glTexParameteri(GLenum target, GLenum pname, GLint param);
GLAPI void APIENTRY glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels); GLAPI void APIENTRY glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels);
GLAPI void APIENTRY glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer); GLAPI void APIENTRY glVertexPointer(GLint size, GLenum type, GLsizei stride, GLpointer pointer);
GLAPI void APIENTRY glViewport(GLint x, GLint y, GLsizei width, GLsizei height); GLAPI void APIENTRY glViewport(GLint x, GLint y, GLsizei width, GLsizei height);
/* === END OPENGL HEADERS === */ /* === END OPENGL HEADERS === */
@ -171,10 +169,10 @@ static GL_SetupVBRangeFunc gfx_setupVBRangeFunc;
/* call [glDrawElements] --> opengl32.dll thunk--> GL driver thunk --> GL driver implementation */ /* call [glDrawElements] --> opengl32.dll thunk--> GL driver thunk --> GL driver implementation */
/* call [_glDrawElements] --> GL driver thunk --> GL driver implementation */ /* call [_glDrawElements] --> GL driver thunk --> GL driver implementation */
static void (APIENTRY *_glColorPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer); static void (APIENTRY *_glColorPointer)(GLint size, GLenum type, GLsizei stride, GLpointer pointer);
static void (APIENTRY *_glDrawElements)(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices); static void (APIENTRY *_glDrawElements)(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices);
static void (APIENTRY *_glTexCoordPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer); static void (APIENTRY *_glTexCoordPointer)(GLint size, GLenum type, GLsizei stride, GLpointer pointer);
static void (APIENTRY *_glVertexPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer); static void (APIENTRY *_glVertexPointer)(GLint size, GLenum type, GLsizei stride, GLpointer pointer);
static const struct DynamicLibSym coreFuncs[] = { static const struct DynamicLibSym coreFuncs[] = {
DynamicLib_Sym2("glColorPointer", glColorPointer), DynamicLib_Sym2("glColorPointer", glColorPointer),
@ -390,27 +388,27 @@ void Gfx_SetDynamicVbData(GfxResourceID vb, void* vertices, int vCount) {
#endif #endif
static void GL_SetupVbColoured(void) { static void GL_SetupVbColoured(void) {
_glVertexPointer(3, GL_FLOAT, SIZEOF_VERTEX_COLOURED, (void*)(VB_PTR + 0)); _glVertexPointer(3, GL_FLOAT, SIZEOF_VERTEX_COLOURED, VB_PTR + 0);
_glColorPointer(4, GL_UNSIGNED_BYTE, SIZEOF_VERTEX_COLOURED, (void*)(VB_PTR + 12)); _glColorPointer(4, GL_UNSIGNED_BYTE, SIZEOF_VERTEX_COLOURED, VB_PTR + 12);
} }
static void GL_SetupVbTextured(void) { static void GL_SetupVbTextured(void) {
_glVertexPointer(3, GL_FLOAT, SIZEOF_VERTEX_TEXTURED, (void*)(VB_PTR + 0)); _glVertexPointer(3, GL_FLOAT, SIZEOF_VERTEX_TEXTURED, VB_PTR + 0);
_glColorPointer(4, GL_UNSIGNED_BYTE, SIZEOF_VERTEX_TEXTURED, (void*)(VB_PTR + 12)); _glColorPointer(4, GL_UNSIGNED_BYTE, SIZEOF_VERTEX_TEXTURED, VB_PTR + 12);
_glTexCoordPointer(2, GL_FLOAT, SIZEOF_VERTEX_TEXTURED, (void*)(VB_PTR + 16)); _glTexCoordPointer(2, GL_FLOAT, SIZEOF_VERTEX_TEXTURED, VB_PTR + 16);
} }
static void GL_SetupVbColoured_Range(int startVertex) { static void GL_SetupVbColoured_Range(int startVertex) {
cc_uint32 offset = startVertex * SIZEOF_VERTEX_COLOURED; cc_uint32 offset = startVertex * SIZEOF_VERTEX_COLOURED;
_glVertexPointer(3, GL_FLOAT, SIZEOF_VERTEX_COLOURED, (void*)(VB_PTR + offset)); _glVertexPointer(3, GL_FLOAT, SIZEOF_VERTEX_COLOURED, VB_PTR + offset + 0);
_glColorPointer(4, GL_UNSIGNED_BYTE, SIZEOF_VERTEX_COLOURED, (void*)(VB_PTR + offset + 12)); _glColorPointer(4, GL_UNSIGNED_BYTE, SIZEOF_VERTEX_COLOURED, VB_PTR + offset + 12);
} }
static void GL_SetupVbTextured_Range(int startVertex) { static void GL_SetupVbTextured_Range(int startVertex) {
cc_uint32 offset = startVertex * SIZEOF_VERTEX_TEXTURED; cc_uint32 offset = startVertex * SIZEOF_VERTEX_TEXTURED;
_glVertexPointer(3, GL_FLOAT, SIZEOF_VERTEX_TEXTURED, (void*)(VB_PTR + offset)); _glVertexPointer(3, GL_FLOAT, SIZEOF_VERTEX_TEXTURED, VB_PTR + offset + 0);
_glColorPointer(4, GL_UNSIGNED_BYTE, SIZEOF_VERTEX_TEXTURED, (void*)(VB_PTR + offset + 12)); _glColorPointer(4, GL_UNSIGNED_BYTE, SIZEOF_VERTEX_TEXTURED, VB_PTR + offset + 12);
_glTexCoordPointer(2, GL_FLOAT, SIZEOF_VERTEX_TEXTURED, (void*)(VB_PTR + offset + 16)); _glTexCoordPointer(2, GL_FLOAT, SIZEOF_VERTEX_TEXTURED, VB_PTR + offset + 16);
} }
void Gfx_SetVertexFormat(VertexFormat fmt) { void Gfx_SetVertexFormat(VertexFormat fmt) {
@ -459,9 +457,9 @@ void Gfx_DrawIndexedTris_T2fC4b(int verticesCount, int startVertex) { glCallList
#else #else
void Gfx_DrawIndexedTris_T2fC4b(int verticesCount, int startVertex) { void Gfx_DrawIndexedTris_T2fC4b(int verticesCount, int startVertex) {
cc_uint32 offset = startVertex * SIZEOF_VERTEX_TEXTURED; cc_uint32 offset = startVertex * SIZEOF_VERTEX_TEXTURED;
_glVertexPointer(3, GL_FLOAT, SIZEOF_VERTEX_TEXTURED, (void*)(VB_PTR + offset)); _glVertexPointer(3, GL_FLOAT, SIZEOF_VERTEX_TEXTURED, VB_PTR + offset + 0);
_glColorPointer(4, GL_UNSIGNED_BYTE, SIZEOF_VERTEX_TEXTURED, (void*)(VB_PTR + offset + 12)); _glColorPointer(4, GL_UNSIGNED_BYTE, SIZEOF_VERTEX_TEXTURED, VB_PTR + offset + 12);
_glTexCoordPointer(2, GL_FLOAT, SIZEOF_VERTEX_TEXTURED, (void*)(VB_PTR + offset + 16)); _glTexCoordPointer(2, GL_FLOAT, SIZEOF_VERTEX_TEXTURED, VB_PTR + offset + 16);
_glDrawElements(GL_TRIANGLES, ICOUNT(verticesCount), GL_UNSIGNED_SHORT, IB_PTR); _glDrawElements(GL_TRIANGLES, ICOUNT(verticesCount), GL_UNSIGNED_SHORT, IB_PTR);
} }
#endif /* !CC_BUILD_GL11 */ #endif /* !CC_BUILD_GL11 */
@ -645,14 +643,14 @@ static void APIENTRY fake_bufferSubData(GLenum target, cc_uintptr offset, cc_uin
static void APIENTRY fake_drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices) { static void APIENTRY fake_drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid* indices) {
glDrawElements(mode, count, type, (cc_uintptr)indices + cur_ib->data); glDrawElements(mode, count, type, (cc_uintptr)indices + cur_ib->data);
} }
static void APIENTRY fake_colorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) { static void APIENTRY fake_colorPointer(GLint size, GLenum type, GLsizei stride, GLpointer offset) {
glColorPointer(size, type, stride, (cc_uintptr)pointer + cur_vb->data); glColorPointer(size, type, stride, (cc_uintptr)cur_vb->data + offset);
} }
static void APIENTRY fake_texCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) { static void APIENTRY fake_texCoordPointer(GLint size, GLenum type, GLsizei stride, GLpointer offset) {
glTexCoordPointer(size, type, stride, (cc_uintptr)pointer + cur_vb->data); glTexCoordPointer(size, type, stride, (cc_uintptr)cur_vb->data + offset);
} }
static void APIENTRY fake_vertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) { static void APIENTRY fake_vertexPointer(GLint size, GLenum type, GLsizei stride, GLpointer offset) {
glVertexPointer(size, type, stride, (cc_uintptr)pointer + cur_vb->data); glVertexPointer(size, type, stride, (cc_uintptr)cur_vb->data + offset);
} }
static void OpenGL11Fallback(void) { static void OpenGL11Fallback(void) {

View File

@ -37,7 +37,7 @@ struct HttpRequest {
cc_uint32 size; /* Size of the contents. */ cc_uint32 size; /* Size of the contents. */
cc_uint32 _capacity; /* (private) Maximum size of data buffer */ cc_uint32 _capacity; /* (private) Maximum size of data buffer */
void* meta; /* Pointer to backend specific data */ void* meta; /* Pointer to backend specific data */
const char* error; char* error; /* Pointer to dynamically allocated error message */
char lastModified[STRING_SIZE]; /* Time item cached at (if at all) */ char lastModified[STRING_SIZE]; /* Time item cached at (if at all) */
char etag[STRING_SIZE]; /* ETag of cached item (if any) */ char etag[STRING_SIZE]; /* ETag of cached item (if any) */

View File

@ -390,25 +390,27 @@ int Window_GetWindowState(void) {
cc_bool fullscreen = false, minimised = false; cc_bool fullscreen = false, minimised = false;
Atom prop_type; Atom prop_type;
unsigned long items, after; unsigned long items, after;
unsigned char* data = NULL;
int i, prop_format; int i, prop_format;
Atom* data = NULL; Atom* list;
XGetWindowProperty(win_display, win_handle, XGetWindowProperty(win_display, win_handle,
net_wm_state, 0, 256, false, xa_atom, &prop_type, net_wm_state, 0, 256, false, xa_atom, &prop_type,
&prop_format, &items, &after, &data); &prop_format, &items, &after, &data);
if (data) { if (!data) return WINDOW_STATE_NORMAL;
for (i = 0; i < items; i++) { list = (Atom*)data;
Atom atom = data[i];
if (atom == net_wm_state_minimized) { for (i = 0; i < items; i++) {
minimised = true; Atom atom = list[i];
} else if (atom == net_wm_state_fullscreen) {
fullscreen = true; if (atom == net_wm_state_minimized) {
} minimised = true;
} else if (atom == net_wm_state_fullscreen) {
fullscreen = true;
} }
XFree(data);
} }
XFree(data);
if (fullscreen) return WINDOW_STATE_FULLSCREEN; if (fullscreen) return WINDOW_STATE_FULLSCREEN;
if (minimised) return WINDOW_STATE_MINIMISED; if (minimised) return WINDOW_STATE_MINIMISED;

View File

@ -184,7 +184,7 @@ static void Http_FinishRequest(struct HttpRequest* req) {
req->success = !req->result && req->statusCode == 200 && req->data && req->size; req->success = !req->result && req->statusCode == 200 && req->data && req->size;
if (!req->success) { if (!req->success) {
const char* error = req->error; req->error = NULL; char* error = req->error; req->error = NULL;
HttpRequest_Free(req); HttpRequest_Free(req);
req->error = error; req->error = error;
/* TODO don't HttpRequest_Free here? */ /* TODO don't HttpRequest_Free here? */