From d6e7c9b41dbe1a1eb80b0526a1d63fdb1734617d Mon Sep 17 00:00:00 2001 From: Antoni Sawicki Date: Sun, 7 Sep 2025 03:36:43 -0700 Subject: [PATCH 1/8] hpux 11iv3 fixes, use mesa --- Makefile | 5 +++-- readme.md | 1 + src/Logger.c | 11 +++++++++++ src/Platform_Posix.c | 7 +++++++ 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 289f58b4d..3b8f1e243 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ BUILD_DIRS = $(BUILD_DIR) $(BUILD_DIR)/src # Configurable flags and names ############################## # Flags passed to the C compiler -CFLAGS = -pipe -fno-math-errno -Werror -Wno-error=missing-braces -Wno-error=strict-aliasing +CFLAGS = -pipe -fno-math-errno # Flags passed to the linker LDFLAGS = -g -rdynamic # Name of the main executable @@ -88,8 +88,9 @@ endif ifeq ($(PLAT),hp-ux) CC = gcc + CFLAGS += -std=c99 -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_DEFAULT_SOURCE -D_BSD_SOURCE LDFLAGS = - LIBS = -lm -lX11 -lXi -lXext -L/opt/graphics/OpenGL/lib -lGL -lpthread + LIBS = -lm -lX11 -lXi -lXext -L/usr/local/lib/hpux32 -lGL -lpthread BUILD_DIR = build/hpux endif diff --git a/readme.md b/readme.md index f90a13443..6a0980317 100644 --- a/readme.md +++ b/readme.md @@ -74,6 +74,7 @@ And also runs on: * Haiku - needs openal package (if you have a GitHub account, can [download from here](https://github.com/ClassiCube/ClassiCube/actions/workflows/build_haiku.yml)) * BeOS - untested on actual hardware * IRIX - needs openal packages +* HP-UX - needs Mesa package, tried building with HP OpenGL and `-DCC_BUILD_GL11` still not working * SerenityOS - needs SDL2 * Classic Mac OS (System 7 and later) * Dreamcast - unfinished, but usable (can [download from here](https://www.classicube.net/download/dreamcast)) diff --git a/src/Logger.c b/src/Logger.c index c1ffd251a..b614179b5 100644 --- a/src/Logger.c +++ b/src/Logger.c @@ -280,6 +280,12 @@ static void DumpFrame(cc_string* trace, void* addr) { cc_uintptr addr_ = (cc_uintptr)addr; String_Format1(trace, "%x", &addr_); } +#elif defined CC_BUILD_HPUX +/* HP-UX doesn't expose a nice interface for dladdr */ +static void DumpFrame(cc_string* trace, void* addr) { + cc_uintptr addr_ = (cc_uintptr)addr; + String_Format1(trace, "%x", &addr_); +} #elif defined CC_BUILD_POSIX && !defined CC_BUILD_OS2 /* need to define __USE_GNU for dladdr */ #ifndef __USE_GNU @@ -455,6 +461,11 @@ void Logger_Backtrace(cc_string* trace, void* ctx) { String_AppendConst(trace, "-- backtrace unimplemented --"); /* There is no dladdr on Symbian */ } +#elif defined CC_BUILD_HPUX +/* HP-UX doesn't have unwind support */ +void Logger_Backtrace(cc_string* trace, void* ctx) { + String_AppendConst(trace, "-- backtrace unimplemented --"); +} #elif defined CC_BUILD_POSIX /* musl etc - rely on unwind from GCC instead */ #define CC_BACKTRACE_UNWIND diff --git a/src/Platform_Posix.c b/src/Platform_Posix.c index 1f5c0dfa9..b07d14b8e 100644 --- a/src/Platform_Posix.c +++ b/src/Platform_Posix.c @@ -800,9 +800,16 @@ cc_result Socket_Create(cc_socket* s, cc_sockaddr* addr, cc_bool nonblocking) { if (*s == -1) return errno; if (nonblocking) { +#ifdef CC_BUILD_HPUX + int flags = fcntl(*s, F_GETFL, 0); + if (flags == -1) return errno; + int err = fcntl(*s, F_SETFL, flags | O_NONBLOCK); + if (err == -1) return errno; +#else int blocking_raw = -1; /* non-blocking mode */ int err = ioctl(*s, FIONBIO, &blocking_raw); if (err == -1) return errno; +#endif } return 0; } From 60c7da3cfb7c589d4c82fed938a4af01eaed3afb Mon Sep 17 00:00:00 2001 From: Antoni Sawicki Date: Mon, 8 Sep 2025 02:18:17 -0700 Subject: [PATCH 2/8] add CC_BUILD_GL11_FALLBACK for hpux --- src/Core.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Core.h b/src/Core.h index 4e5226f3f..3848f3954 100644 --- a/src/Core.h +++ b/src/Core.h @@ -362,6 +362,7 @@ typedef cc_uint8 cc_bool; #define CC_BIG_ENDIAN #define CC_BUILD_NOMUSIC #define CC_BUILD_NOSOUNDS + #define CC_BUILD_GL11_FALLBACK #define DEFAULT_NET_BACKEND CC_NET_BACKEND_BUILTIN #define DEFAULT_AUD_BACKEND CC_AUD_BACKEND_NULL #define DEFAULT_GFX_BACKEND CC_GFX_BACKEND_GL1 From 5918ad85e625bb0e96df16f5bc7af2534c42d183 Mon Sep 17 00:00:00 2001 From: Antoni Sawicki Date: Tue, 9 Sep 2025 02:15:56 -0700 Subject: [PATCH 3/8] restore compiler warnings --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 3b8f1e243..e86b9f4f0 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ BUILD_DIRS = $(BUILD_DIR) $(BUILD_DIR)/src # Configurable flags and names ############################## # Flags passed to the C compiler -CFLAGS = -pipe -fno-math-errno +CFLAGS = -pipe -fno-math-errno -Werror -Wno-error=missing-braces -Wno-error=strict-aliasing # Flags passed to the linker LDFLAGS = -g -rdynamic # Name of the main executable From 873cc1ca6720625ea7182c6e05cb4a130dd8b4ba Mon Sep 17 00:00:00 2001 From: Antoni Sawicki Date: Tue, 9 Sep 2025 02:17:31 -0700 Subject: [PATCH 4/8] update readme for hpux --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 6a0980317..3cf7637b0 100644 --- a/readme.md +++ b/readme.md @@ -74,7 +74,7 @@ And also runs on: * Haiku - needs openal package (if you have a GitHub account, can [download from here](https://github.com/ClassiCube/ClassiCube/actions/workflows/build_haiku.yml)) * BeOS - untested on actual hardware * IRIX - needs openal packages -* HP-UX - needs Mesa package, tried building with HP OpenGL and `-DCC_BUILD_GL11` still not working +* HPUX - tested on 11v3 IA64 * SerenityOS - needs SDL2 * Classic Mac OS (System 7 and later) * Dreamcast - unfinished, but usable (can [download from here](https://www.classicube.net/download/dreamcast)) From d84ad841f1d3e8cbc49393a8242bb89f5797f99f Mon Sep 17 00:00:00 2001 From: Antoni Sawicki Date: Tue, 9 Sep 2025 02:38:03 -0700 Subject: [PATCH 5/8] use hp opengl --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e86b9f4f0..833eb0314 100644 --- a/Makefile +++ b/Makefile @@ -90,7 +90,7 @@ ifeq ($(PLAT),hp-ux) CC = gcc CFLAGS += -std=c99 -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_DEFAULT_SOURCE -D_BSD_SOURCE LDFLAGS = - LIBS = -lm -lX11 -lXi -lXext -L/usr/local/lib/hpux32 -lGL -lpthread + LIBS = -lm -lX11 -lXi -lXext -L/opt/graphics/OpenGL/lib/hpux32 -lGL -lXhp11 -lpthread BUILD_DIR = build/hpux endif From 5774e290c570e137ce157d63ed0213da248d8be3 Mon Sep 17 00:00:00 2001 From: Antoni Sawicki Date: Tue, 9 Sep 2025 02:39:54 -0700 Subject: [PATCH 6/8] add casts to Graphics_GL1.c to make -Werror happy --- src/Graphics_GL1.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Graphics_GL1.c b/src/Graphics_GL1.c index 01b3e6e7e..a8d5fc9bf 100644 --- a/src/Graphics_GL1.c +++ b/src/Graphics_GL1.c @@ -207,27 +207,27 @@ void Gfx_SetDynamicVbData(GfxResourceID vb, void* vertices, int vCount) { #define IB_PTR NULL static void GL_SetupVbColoured(void) { - _glVertexPointer(3, GL_FLOAT, SIZEOF_VERTEX_COLOURED, VB_PTR + 0); - _glColorPointer(4, GL_UNSIGNED_BYTE, SIZEOF_VERTEX_COLOURED, VB_PTR + 12); + _glVertexPointer(3, GL_FLOAT, SIZEOF_VERTEX_COLOURED, (GLpointer)(VB_PTR + 0)); + _glColorPointer(4, GL_UNSIGNED_BYTE, SIZEOF_VERTEX_COLOURED, (GLpointer)(VB_PTR + 12)); } static void GL_SetupVbTextured(void) { - _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); + _glVertexPointer(3, GL_FLOAT, SIZEOF_VERTEX_TEXTURED, (GLpointer)(VB_PTR + 0)); + _glColorPointer(4, GL_UNSIGNED_BYTE, SIZEOF_VERTEX_TEXTURED, (GLpointer)(VB_PTR + 12)); + _glTexCoordPointer(2, GL_FLOAT, SIZEOF_VERTEX_TEXTURED, (GLpointer)(VB_PTR + 16)); } static void GL_SetupVbColoured_Range(int startVertex) { cc_uint32 offset = startVertex * SIZEOF_VERTEX_COLOURED; - _glVertexPointer(3, GL_FLOAT, SIZEOF_VERTEX_COLOURED, VB_PTR + offset + 0); - _glColorPointer(4, GL_UNSIGNED_BYTE, SIZEOF_VERTEX_COLOURED, VB_PTR + offset + 12); + _glVertexPointer(3, GL_FLOAT, SIZEOF_VERTEX_COLOURED, (GLpointer)(VB_PTR + offset + 0)); + _glColorPointer(4, GL_UNSIGNED_BYTE, SIZEOF_VERTEX_COLOURED, (GLpointer)(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, 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); + _glVertexPointer(3, GL_FLOAT, SIZEOF_VERTEX_TEXTURED, (GLpointer)(VB_PTR + offset + 0)); + _glColorPointer(4, GL_UNSIGNED_BYTE, SIZEOF_VERTEX_TEXTURED, (GLpointer)(VB_PTR + offset + 12)); + _glTexCoordPointer(2, GL_FLOAT, SIZEOF_VERTEX_TEXTURED, (GLpointer)(VB_PTR + offset + 16)); } void Gfx_SetVertexFormat(VertexFormat fmt) { @@ -267,9 +267,9 @@ void Gfx_DrawVb_IndexedTris(int verticesCount) { void Gfx_DrawIndexedTris_T2fC4b(int verticesCount, int startVertex) { cc_uint32 offset = startVertex * SIZEOF_VERTEX_TEXTURED; - _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); + _glVertexPointer(3, GL_FLOAT, SIZEOF_VERTEX_TEXTURED, (GLpointer)(VB_PTR + offset + 0)); + _glColorPointer(4, GL_UNSIGNED_BYTE, SIZEOF_VERTEX_TEXTURED, (GLpointer)(VB_PTR + offset + 12)); + _glTexCoordPointer(2, GL_FLOAT, SIZEOF_VERTEX_TEXTURED, (GLpointer)(VB_PTR + offset + 16)); _glDrawElements(GL_TRIANGLES, ICOUNT(verticesCount), GL_UNSIGNED_SHORT, IB_PTR); } @@ -585,7 +585,7 @@ static void APIENTRY gl10_colorPointer(GLint size, GLenum type, GLsizei stride, static void APIENTRY gl10_texCoordPointer(GLint size, GLenum type, GLsizei stride, GLpointer offset) { } static void APIENTRY gl10_vertexPointer(GLint size, GLenum type, GLsizei stride, GLpointer offset) { - gl10_vb = cur_vb->data + offset; + gl10_vb = cur_vb->data + (cc_uintptr)offset; } From fc9f9c011b808a0c88221d952db14eee3a30ab29 Mon Sep 17 00:00:00 2001 From: Antoni Sawicki Date: Tue, 9 Sep 2025 02:41:45 -0700 Subject: [PATCH 7/8] fix hpux colormap --- src/_GLShared.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/_GLShared.h b/src/_GLShared.h index 40c2afa65..8eec7ec8d 100644 --- a/src/_GLShared.h +++ b/src/_GLShared.h @@ -80,6 +80,12 @@ static void ConvertRGBA(void* dst, const void* src, int numPixels) { d[1] = s[2]; d[2] = s[3]; d[3] = s[0]; +#elif defined CC_BUILD_HPUX + /* HP-UX specific color channel mapping - try IRIX style G,B,A,R */ + d[0] = s[1]; /* R = G */ + d[1] = s[2]; /* G = B */ + d[2] = s[3]; /* B = A */ + d[3] = s[0]; /* A = R */ #else d[0] = s[2]; d[1] = s[1]; From 3a762a531171e03608a826a717071bf0f6787a37 Mon Sep 17 00:00:00 2001 From: Antoni Sawicki Date: Tue, 9 Sep 2025 02:55:28 -0700 Subject: [PATCH 8/8] -lXhp11 not needed --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 833eb0314..46d934852 100644 --- a/Makefile +++ b/Makefile @@ -90,7 +90,7 @@ ifeq ($(PLAT),hp-ux) CC = gcc CFLAGS += -std=c99 -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -D_DEFAULT_SOURCE -D_BSD_SOURCE LDFLAGS = - LIBS = -lm -lX11 -lXi -lXext -L/opt/graphics/OpenGL/lib/hpux32 -lGL -lXhp11 -lpthread + LIBS = -lm -lX11 -lXi -lXext -L/opt/graphics/OpenGL/lib/hpux32 -lGL -lpthread BUILD_DIR = build/hpux endif