Skip to content

Commit b54d1c1

Browse files
gmtaQuaker762
authored andcommitted
Build: Enable LibGL and x86_64 support
This partially reverts commits 470365f and 15795fd to allow the game to run on x86_64 and to run the OpenGL renderer. Instructions are added to the README.
1 parent d62996f commit b54d1c1

File tree

3 files changed

+47
-6
lines changed

3 files changed

+47
-6
lines changed

README.md

+11
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,14 @@ Build like a regular Serenity Port.
3030
In the `quake2` port directory, run `./package.sh`.
3131

3232
You'll then need to source the QuakeII demo pak file yourself. iD's FTP is offline, however you can find the demo in a few places. Once you've downloaded the demo, move the `pak0.pak` file to `/home/anon/.quake2/baseq2/` and run `quake2` from the command line.
33+
34+
Running with OpenGL
35+
-------------------
36+
37+
Dynamically switching between software rendering and LibGL does not yet work; to run Quake2 in OpenGL mode, add the
38+
following statements to `~/.quake2/baseq2/config.cfg`:
39+
40+
```
41+
set vid_ref "sdlgl"
42+
set gl_driver "libgl.so.serenity"
43+
```

src/CMakeLists.txt

+35-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
set (quake_resource_libdir /usr/local/lib/quake2sdl)
2-
set (quake_resource_datadir /usr/local/share/quake2)
1+
set (quake_resource_libdir ${CMAKE_INSTALL_PREFIX}/lib/quake2sdl)
2+
set (quake_resource_datadir ${CMAKE_INSTALL_PREFIX}/share/quake2)
33
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/q_resources.h.in ${CMAKE_CURRENT_BINARY_DIR}/q_resources.h)
44

5-
include_directories (${SDL2_INCLUDE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
5+
include_directories (${SDL2_INCLUDE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${OPENGL_INCLUDE_DIR})
66

77
set (Q2_SOURCES
88
client/cl_cin.c
@@ -84,6 +84,36 @@ add_library (ref-softsdl SHARED
8484
)
8585
set_target_properties (ref-softsdl PROPERTIES OUTPUT_NAME ref_softsdl PREFIX "")
8686

87+
if (WITH_QMAX)
88+
set (GL_DIR ref_candygl)
89+
else (WITH_QMAX)
90+
set (GL_DIR ref_gl)
91+
endif (WITH_QMAX)
92+
93+
add_library (ref-sdlgl SHARED
94+
${GL_DIR}/gl_draw.c
95+
${GL_DIR}/gl_image.c
96+
${GL_DIR}/gl_light.c
97+
${GL_DIR}/gl_mesh.c
98+
${GL_DIR}/gl_model.c
99+
${GL_DIR}/gl_rmain.c
100+
${GL_DIR}/gl_rmisc.c
101+
${GL_DIR}/gl_rsurf.c
102+
${GL_DIR}/gl_warp.c
103+
linux/qgl_linux.c
104+
game/q_shared.c
105+
linux/q_shlinux.c
106+
linux/glob.c
107+
linux/rw_sdl.c
108+
linux/rw_linux.c
109+
linux/joystick.c
110+
)
111+
if (WITH_QMAX)
112+
target_link_libraries (ref-sdlgl ${JPEG_LIBRARY})
113+
endif (WITH_QMAX)
114+
target_compile_definitions (ref-sdlgl PRIVATE -DOPENGL)
115+
set_target_properties (ref-sdlgl PROPERTIES OUTPUT_NAME ref_sdlgl PREFIX "")
116+
87117
add_library (game-base SHARED
88118
game/g_ai.c
89119
game/p_client.c
@@ -133,8 +163,8 @@ add_library (game-base SHARED
133163
game/p_weapon.c
134164
game/q_shared.c
135165
game/m_flash.c)
136-
set_target_properties (game-base PROPERTIES OUTPUT_NAME gamei386 PREFIX "")
166+
set_target_properties (game-base PROPERTIES OUTPUT_NAME game PREFIX "")
137167

138168
install (TARGETS quake2 RUNTIME DESTINATION bin)
139-
install (TARGETS ref-softsdl LIBRARY DESTINATION lib/quake2sdl)
169+
install (TARGETS ref-softsdl ref-sdlgl LIBRARY DESTINATION lib/quake2sdl)
140170
install (TARGETS game-base LIBRARY DESTINATION lib/quake2sdl/baseq2)

src/linux/glw_linux.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1919
*/
2020
#ifndef __linux__
2121
#ifndef __FreeBSD__
22-
#error You shouldnt be including this file on non-unix platforms
22+
// #error You shouldnt be including this file on non-unix platforms
2323
#endif
2424
#endif
2525

0 commit comments

Comments
 (0)