From ce125de895074ceaf238f95ca1202754ec4657a5 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sun, 10 Dec 2023 10:49:11 +1100 Subject: [PATCH] Compiles with less warnings --- src/Graphics_GL1.c | 68 ++++++++++++++++++++++------------------------ src/Http.h | 2 +- src/Window_X11.c | 22 ++++++++------- src/_HttpBase.h | 2 +- 4 files changed, 47 insertions(+), 47 deletions(-) diff --git a/src/Graphics_GL1.c b/src/Graphics_GL1.c index 03597f898..306a3baec 100644 --- a/src/Graphics_GL1.c +++ b/src/Graphics_GL1.c @@ -8,18 +8,8 @@ * - 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 -#define GLAPI WINGDIAPI -#else #define GLAPI extern #define APIENTRY -#endif /* === BEGIN OPENGL HEADERS === */ typedef unsigned int GLenum; typedef unsigned char GLboolean; @@ -31,6 +21,14 @@ typedef unsigned int GLuint; typedef float GLfloat; 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_GREATER 0x0204 @@ -103,7 +101,7 @@ GLAPI void APIENTRY glCallList(GLuint list); GLAPI void APIENTRY glClear(GLuint mask); 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 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 glDeleteTextures(GLsizei n, const GLuint* textures); 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 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 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 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 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); /* === 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] --> 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 *_glTexCoordPointer)(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer); -static void (APIENTRY *_glVertexPointer)(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, GLpointer pointer); static const struct DynamicLibSym coreFuncs[] = { DynamicLib_Sym2("glColorPointer", glColorPointer), @@ -390,27 +388,27 @@ void Gfx_SetDynamicVbData(GfxResourceID vb, void* vertices, int vCount) { #endif static void GL_SetupVbColoured(void) { - _glVertexPointer(3, GL_FLOAT, SIZEOF_VERTEX_COLOURED, (void*)(VB_PTR + 0)); - _glColorPointer(4, GL_UNSIGNED_BYTE, SIZEOF_VERTEX_COLOURED, (void*)(VB_PTR + 12)); + _glVertexPointer(3, GL_FLOAT, SIZEOF_VERTEX_COLOURED, VB_PTR + 0); + _glColorPointer(4, GL_UNSIGNED_BYTE, SIZEOF_VERTEX_COLOURED, VB_PTR + 12); } static void GL_SetupVbTextured(void) { - _glVertexPointer(3, GL_FLOAT, SIZEOF_VERTEX_TEXTURED, (void*)(VB_PTR + 0)); - _glColorPointer(4, GL_UNSIGNED_BYTE, SIZEOF_VERTEX_TEXTURED, (void*)(VB_PTR + 12)); - _glTexCoordPointer(2, GL_FLOAT, SIZEOF_VERTEX_TEXTURED, (void*)(VB_PTR + 16)); + _glVertexPointer(3, GL_FLOAT, SIZEOF_VERTEX_TEXTURED, VB_PTR + 0); + _glColorPointer(4, GL_UNSIGNED_BYTE, SIZEOF_VERTEX_TEXTURED, VB_PTR + 12); + _glTexCoordPointer(2, GL_FLOAT, SIZEOF_VERTEX_TEXTURED, VB_PTR + 16); } static void GL_SetupVbColoured_Range(int startVertex) { cc_uint32 offset = startVertex * SIZEOF_VERTEX_COLOURED; - _glVertexPointer(3, GL_FLOAT, SIZEOF_VERTEX_COLOURED, (void*)(VB_PTR + offset)); - _glColorPointer(4, GL_UNSIGNED_BYTE, SIZEOF_VERTEX_COLOURED, (void*)(VB_PTR + offset + 12)); + _glVertexPointer(3, GL_FLOAT, SIZEOF_VERTEX_COLOURED, VB_PTR + offset + 0); + _glColorPointer(4, GL_UNSIGNED_BYTE, SIZEOF_VERTEX_COLOURED, VB_PTR + offset + 12); } static void GL_SetupVbTextured_Range(int startVertex) { cc_uint32 offset = startVertex * SIZEOF_VERTEX_TEXTURED; - _glVertexPointer(3, GL_FLOAT, SIZEOF_VERTEX_TEXTURED, (void*)(VB_PTR + offset)); - _glColorPointer(4, GL_UNSIGNED_BYTE, SIZEOF_VERTEX_TEXTURED, (void*)(VB_PTR + offset + 12)); - _glTexCoordPointer(2, GL_FLOAT, SIZEOF_VERTEX_TEXTURED, (void*)(VB_PTR + offset + 16)); + _glVertexPointer(3, GL_FLOAT, SIZEOF_VERTEX_TEXTURED, VB_PTR + offset + 0); + _glColorPointer(4, GL_UNSIGNED_BYTE, SIZEOF_VERTEX_TEXTURED, VB_PTR + offset + 12); + _glTexCoordPointer(2, GL_FLOAT, SIZEOF_VERTEX_TEXTURED, VB_PTR + offset + 16); } void Gfx_SetVertexFormat(VertexFormat fmt) { @@ -459,9 +457,9 @@ void Gfx_DrawIndexedTris_T2fC4b(int verticesCount, int startVertex) { glCallList #else void Gfx_DrawIndexedTris_T2fC4b(int verticesCount, int startVertex) { cc_uint32 offset = startVertex * SIZEOF_VERTEX_TEXTURED; - _glVertexPointer(3, GL_FLOAT, SIZEOF_VERTEX_TEXTURED, (void*)(VB_PTR + offset)); - _glColorPointer(4, GL_UNSIGNED_BYTE, SIZEOF_VERTEX_TEXTURED, (void*)(VB_PTR + offset + 12)); - _glTexCoordPointer(2, GL_FLOAT, SIZEOF_VERTEX_TEXTURED, (void*)(VB_PTR + offset + 16)); + _glVertexPointer(3, GL_FLOAT, SIZEOF_VERTEX_TEXTURED, VB_PTR + offset + 0); + _glColorPointer(4, GL_UNSIGNED_BYTE, SIZEOF_VERTEX_TEXTURED, VB_PTR + offset + 12); + _glTexCoordPointer(2, GL_FLOAT, SIZEOF_VERTEX_TEXTURED, VB_PTR + offset + 16); _glDrawElements(GL_TRIANGLES, ICOUNT(verticesCount), GL_UNSIGNED_SHORT, IB_PTR); } #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) { glDrawElements(mode, count, type, (cc_uintptr)indices + cur_ib->data); } -static void APIENTRY fake_colorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) { - glColorPointer(size, type, stride, (cc_uintptr)pointer + cur_vb->data); +static void APIENTRY fake_colorPointer(GLint size, GLenum type, GLsizei stride, GLpointer offset) { + glColorPointer(size, type, stride, (cc_uintptr)cur_vb->data + offset); } -static void APIENTRY fake_texCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) { - glTexCoordPointer(size, type, stride, (cc_uintptr)pointer + cur_vb->data); +static void APIENTRY fake_texCoordPointer(GLint size, GLenum type, GLsizei stride, GLpointer offset) { + glTexCoordPointer(size, type, stride, (cc_uintptr)cur_vb->data + offset); } -static void APIENTRY fake_vertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid* pointer) { - glVertexPointer(size, type, stride, (cc_uintptr)pointer + cur_vb->data); +static void APIENTRY fake_vertexPointer(GLint size, GLenum type, GLsizei stride, GLpointer offset) { + glVertexPointer(size, type, stride, (cc_uintptr)cur_vb->data + offset); } static void OpenGL11Fallback(void) { diff --git a/src/Http.h b/src/Http.h index 9e3f3ffcf..2a97c6dfa 100644 --- a/src/Http.h +++ b/src/Http.h @@ -37,7 +37,7 @@ struct HttpRequest { cc_uint32 size; /* Size of the contents. */ cc_uint32 _capacity; /* (private) Maximum size of data buffer */ 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 etag[STRING_SIZE]; /* ETag of cached item (if any) */ diff --git a/src/Window_X11.c b/src/Window_X11.c index 76bf3d8dc..27d597579 100644 --- a/src/Window_X11.c +++ b/src/Window_X11.c @@ -390,25 +390,27 @@ int Window_GetWindowState(void) { cc_bool fullscreen = false, minimised = false; Atom prop_type; unsigned long items, after; + unsigned char* data = NULL; int i, prop_format; - Atom* data = NULL; + Atom* list; XGetWindowProperty(win_display, win_handle, net_wm_state, 0, 256, false, xa_atom, &prop_type, &prop_format, &items, &after, &data); - if (data) { - for (i = 0; i < items; i++) { - Atom atom = data[i]; + if (!data) return WINDOW_STATE_NORMAL; + list = (Atom*)data; + + for (i = 0; i < items; i++) { + Atom atom = list[i]; - if (atom == net_wm_state_minimized) { - minimised = true; - } 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 (minimised) return WINDOW_STATE_MINIMISED; diff --git a/src/_HttpBase.h b/src/_HttpBase.h index 05bcda060..55a11a15e 100644 --- a/src/_HttpBase.h +++ b/src/_HttpBase.h @@ -184,7 +184,7 @@ static void Http_FinishRequest(struct HttpRequest* req) { req->success = !req->result && req->statusCode == 200 && req->data && req->size; if (!req->success) { - const char* error = req->error; req->error = NULL; + char* error = req->error; req->error = NULL; HttpRequest_Free(req); req->error = error; /* TODO don't HttpRequest_Free here? */