Skip to content

Commit 46d0e7a

Browse files
committed
SDL3 port
1 parent 6cd9c16 commit 46d0e7a

17 files changed

Lines changed: 2474 additions & 2 deletions

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Build instructions are in the README file for each platform:
3232
- [Plan9](plan9/README.md) for use on Plan9 (APE)
3333
- [SDL 1.x](sdl1/README.md) for use as separate SDL version 1 window
3434
- [SDL 2.x](sdl2/README.md) for use as separate SDL version 2 window
35+
- [SDL 3.x](sdl3/README.md) for use as separate SDL version 3 window
3536
- [wincon](wincon/README.md) (formerly win32) for use on Windows Console
3637
- [WinGUI](wingui/README.md) for use on Windows Graphics Mode
3738
- [X11](x11/README.md) (also called XCurses) for use as separate X11 window (but see below)

cmake/project_common.cmake

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,22 @@ if(WIN32 AND NOT WATCOM)
3131
set(EXTRA_LIBS gdi32.lib winspool.lib shell32.lib ole32.lib comdlg32.lib advapi32.lib)
3232
set(WINCON_WINGUI_DEP_LIBS winmm.lib)
3333
set(SDL2_DEP_LIBRARIES version.lib winmm.lib imm32.lib)
34+
set(SDL3_DEP_LIBRARIES version.lib winmm.lib imm32.lib)
3435
elseif(WATCOM_WIN32)
3536
set(EXTRA_LIBS "")
3637
set(WINCON_WINGUI_DEP_LIBS winmm.lib)
3738
set(SDL2_DEP_LIBRARIES "dl")
39+
set(SDL3_DEP_LIBRARIES "dl")
3840
elseif(APPLE)
3941
set(EXTRA_LIBS "")
4042
set(WINCON_WINGUI_DEP_LIBS "")
4143
set(SDL2_DEP_LIBRARIES "dl")
44+
set(SDL3_DEP_LIBRARIES "dl")
4245
else()
4346
set(EXTRA_LIBS "")
4447
set(WINCON_WINGUI_DEP_LIBS "")
4548
set(SDL2_DEP_LIBRARIES "dl")
49+
set(SDL3_DEP_LIBRARIES "dl")
4650
endif()
4751

4852
if (APPLE)
@@ -91,6 +95,13 @@ if(PDC_BUILD_SHARED)
9195
else()
9296
target_link_libraries(${PDCURSE_PROJ} PRIVATE ${SDL2_LIBRARIES} ${SDL2_DEP_LIBRARIES})
9397
endif()
98+
elseif(${PROJECT_NAME} STREQUAL "sdl3")
99+
if(PDC_WIDE OR PDC_UTF8)
100+
target_link_libraries(${PDCURSE_PROJ} PRIVATE ${SDL3_LIBRARIES} ${SDL3_TTF_LIBRARY}
101+
${FT2_LIBRARY} ${ZLIB_LIBRARY} ${SDL3_DEP_LIBRARIES})
102+
else()
103+
target_link_libraries(${PDCURSE_PROJ} PRIVATE ${SDL3_LIBRARIES} ${SDL3_DEP_LIBRARIES})
104+
endif()
94105
elseif((${PROJECT_NAME} STREQUAL "wincon") OR (${PROJECT_NAME} STREQUAL "wingui") OR (${PROJECT_NAME} STREQUAL "vt"))
95106
target_link_libraries(${PDCURSE_PROJ} PRIVATE ${WINCON_WINGUI_DEP_LIBS})
96107
endif()

curses.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ enum PDC_port
178178
PDC_PORT_PLAN9 = 9,
179179
PDC_PORT_LINUX_FB = 10,
180180
PDC_PORT_OPENGL = 11,
181-
PDC_PORT_OS2GUI = 12
181+
PDC_PORT_OS2GUI = 12,
182+
PDC_PORT_SDL3 = 13
182183
};
183184

184185
/* Use this structure with PDC_get_version() for run-time info about the

demos/ozdemo.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ int main(int argc, char **argv)
223223
const char *versions_1 =
224224
" DOS, DOSVGA, GL, Linux framebuffer/DRM, OS/2, OS/2 GUI,";
225225
const char *versions_2 =
226-
" Plan 9, SDL 1/2, VT, Windows console & GUI, X11";
226+
" Plan 9, SDL 1/2/3, VT, Windows console & GUI, X11";
227227
const char *hit_any_key =
228228
" Type a key to continue or ESC to quit ";
229229
SCREEN *screen_pointer = newterm(NULL, stdout, stdin);

sdl3/CMakeLists.txt

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
cmake_minimum_required(VERSION 3.11)
2+
3+
if(NOT CMAKE_BUILD_TYPE)
4+
set(CMAKE_BUILD_TYPE "MinSizeRel" CACHE STRING "Choose the type of build, options are: Debug, Release, or MinSizeRel." FORCE)
5+
message(STATUS "No build type specified, defaulting to MinSizeRel.")
6+
endif()
7+
8+
project(sdl3 VERSION "${PROJECT_VERSION}" LANGUAGES C)
9+
message(STATUS "${PROJECT_NAME} version: ${PROJECT_VERSION}")
10+
11+
message(STATUS "SDL3_LIBRARIES = ${SDL3_LIBRARIES}")
12+
message(STATUS "SDL3_INCLUDE_DIR = ${SDL3_INCLUDE_DIR}")
13+
message(STATUS "SDL3_LIBRARY_DIR = ${SDL3_LIBRARY_DIR}")
14+
if(PDC_WIDE OR PDC_UTF8)
15+
message(STATUS "SDL3_TTF_LIBRARY = ${SDL3_TTF_LIBRARY}")
16+
message(STATUS "SDL3_TTF_INCLUDE_DIR = ${SDL3_TTF_INCLUDE_DIR}")
17+
message(STATUS "SDL3_TTF_LIBRARY_DIR = ${SDL3_TTF_LIBRARY_DIR}")
18+
endif()
19+
20+
include_directories(${SDL3_INCLUDE_DIR} ${SDL3_TTF_INCLUDE_DIR})
21+
link_directories(${SDL3_LIBRARY_DIR} ${SDL3_TTF_LIBRARY_DIR})
22+
23+
if(NOT pdcurses_src_files)
24+
file(GLOB pdcurses_src_files ${CMAKE_CURRENT_SOURCE_DIR}/../pdcurses/*.c)
25+
endif()
26+
27+
include(project_common)
28+
29+
macro (sdl3_app dir targ)
30+
31+
set(bin_name "${PROJECT_NAME}_${targ}")
32+
33+
if(${targ} STREQUAL "tuidemo")
34+
set(src_files ${CMAKE_CURRENT_SOURCE_DIR}/${dir}/tuidemo.c ${CMAKE_CURRENT_SOURCE_DIR}/${dir}/tui.c)
35+
else()
36+
set(src_files ${CMAKE_CURRENT_SOURCE_DIR}/${dir}/${targ}.c)
37+
endif()
38+
39+
if(${ARGV2})
40+
add_executable(${bin_name} WIN32 ${src_files})
41+
else()
42+
add_executable(${bin_name} ${src_files})
43+
endif()
44+
45+
if(PDC_WIDE OR PDC_UTF8)
46+
target_link_libraries(${bin_name} PUBLIC ${PDCURSE_PROJ} ${EXTRA_LIBS}
47+
"${SDL3_LIBRARIES};${SDL3_TTF_LIBRARY};${FT2_LIBRARY};${ZLIB_LIBRARY};${SDL3_DEP_LIBRARIES}")
48+
else()
49+
target_link_libraries(${bin_name} PUBLIC ${PDCURSE_PROJ} ${EXTRA_LIBS}
50+
"${SDL3_LIBRARIES};${SDL3_TTF_DEP_LIBRARIES};${SDL3_DEP_LIBRARIES}")
51+
endif()
52+
53+
add_dependencies(${bin_name} ${PDCURSE_PROJ})
54+
set_target_properties(${bin_name} PROPERTIES OUTPUT_NAME ${targ})
55+
56+
install(TARGETS ${bin_name} RUNTIME DESTINATION ${PDCURSES_DIST}/bin/${PROJECT_NAME} COMPONENT applications)
57+
58+
endmacro ()
59+
60+
sdl3_app(../demos version)
61+
sdl3_app(../demos calendar)
62+
sdl3_app(../demos firework)
63+
sdl3_app(../demos init_col)
64+
sdl3_app(../demos mbrot)
65+
sdl3_app(../demos ozdemo)
66+
sdl3_app(../demos newtest WIN32)
67+
sdl3_app(../demos picsview)
68+
sdl3_app(../demos ptest)
69+
sdl3_app(../demos rain)
70+
sdl3_app(../demos speed)
71+
sdl3_app(../demos testcurs)
72+
sdl3_app(../demos test_pan)
73+
sdl3_app(../demos tuidemo)
74+
sdl3_app(../demos widetest)
75+
sdl3_app(../demos worm)
76+
sdl3_app(../demos xmas)
77+
sdl3_app(./ sdltest)
78+
79+
if(PDC_SDL3_DEPS_BUILD)
80+
if(PDC_WIDE OR PDC_UTF8)
81+
add_dependencies(${PDCURSE_PROJ} sdl3_ext sdl3_ttf_ext)
82+
else()
83+
add_dependencies(${PDCURSE_PROJ} sdl3_ext)
84+
endif()
85+
endif()
86+
87+
set(CPACK_COMPONENTS_ALL applications)

sdl3/Makefile.vc

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# Visual C++ Makefile for PDCurses - SDL3
2+
#
3+
# Usage: nmake -f [path\]Makefile.vc [DEBUG=Y] [DLL=Y] [WIDE=Y] [UTF8=Y]
4+
# [target]
5+
#
6+
# where target can be any of:
7+
# [all|demos|pdcurses.lib|testcurs.exe...]
8+
9+
O = obj
10+
E = .exe
11+
RM = del
12+
13+
!ifndef PDCURSES_SRCDIR
14+
PDCURSES_SRCDIR = ..
15+
!endif
16+
17+
osdir = $(PDCURSES_SRCDIR)\sdl3
18+
common = $(PDCURSES_SRCDIR)\common
19+
20+
!include $(common)\libobjs.mif
21+
!include $(osdir)\versions.mif
22+
23+
SDL3_INCLUDE = -I$(SDLBASE)\include
24+
SDL3_LIB = $(SDLBASE)\lib\$(PLATFORM)\SDL3.lib
25+
SDL3_LIBMAIN = $(SDLBASE)\lib\$(PLATFORM)\SDL3main.lib
26+
27+
PDCURSES_WIN_H = $(osdir)\pdcsdl.h
28+
29+
CC = cl.exe -nologo
30+
31+
!ifndef PLATFORM
32+
PLATFORM = $(VSCMD_ARG_TGT_ARCH)
33+
!endif
34+
35+
!ifdef DEBUG
36+
CFLAGS = -Z7 -W4 -DPDCDEBUG -D_CRT_SECURE_NO_DEPRECATE
37+
LDFLAGS = -debug -pdb:none
38+
!else
39+
CFLAGS = -Ox -W4 -D_CRT_SECURE_NO_DEPRECATE
40+
LDFLAGS =
41+
!endif
42+
43+
!ifdef WIDE
44+
WIDEOPT = -DPDC_WIDE
45+
!endif
46+
47+
!ifdef UTF8
48+
WIDEOPT = -DPDC_FORCE_UTF8
49+
!endif
50+
51+
!ifdef WIDEOPT
52+
TTF_INCLUDE = -I$(TTFBASE)\include
53+
TTF_LIB = $(TTFBASE)\lib\$(PLATFORM)\SDL3_ttf.lib
54+
!endif
55+
56+
SHL_LD = link $(LDFLAGS) -nologo -dll -machine:$(PLATFORM) -out:pdcurses.dll
57+
58+
LINK = link.exe -nologo -subsystem:windows
59+
60+
LIBEXE = lib -nologo
61+
62+
LIBCURSES = pdcurses.lib
63+
CURSESDLL = pdcurses.dll
64+
65+
!ifdef DLL
66+
DLLOPT = -DPDC_DLL_BUILD
67+
PDCLIBS = $(CURSESDLL)
68+
LIBLIBS = $(SDL3_LIB) $(TTF_LIB)
69+
CCLIBS = $(SDL3_LIBMAIN) $(SDL3_LIB) shell32.lib
70+
!else
71+
PDCLIBS = $(LIBCURSES)
72+
CCLIBS = $(SDL3_LIBMAIN) $(SDL3_LIB) $(TTF_LIB) shell32.lib
73+
!endif
74+
75+
BUILD = $(CC) -I$(PDCURSES_SRCDIR) \
76+
-c $(CFLAGS) $(DLLOPT) $(WIDEOPT) $(INFOPT)
77+
78+
all: $(PDCLIBS)
79+
80+
clean:
81+
-$(RM) *.obj
82+
-$(RM) $(LIBCURSES)
83+
-$(RM) *.exe
84+
-$(RM) $(CURSESDLL)
85+
-$(RM) *.exp
86+
-$(RM) pdcurses.res
87+
88+
demos: $(PDCLIBS) $(DEMOS) sdltest.exe
89+
90+
DEMOOBJS = $(DEMOS:.exe=.obj) tui.obj sdltest.obj
91+
92+
$(LIBOBJS) $(PDCOBJS) : $(PDCURSES_HEADERS)
93+
$(PDCOBJS) : $(PDCURSES_WIN_H)
94+
$(DEMOOBJS) : $(PDCURSES_CURSES_H)
95+
$(DEMOS) : $(LIBCURSES)
96+
panel.obj : $(PANEL_HEADER)
97+
98+
!ifndef DLL
99+
$(LIBCURSES) : $(LIBOBJS) $(PDCOBJS)
100+
$(LIBEXE) -out:$@ $(LIBOBJS) $(PDCOBJS)
101+
!endif
102+
103+
$(CURSESDLL) : $(LIBOBJS) $(PDCOBJS) pdcurses.obj
104+
$(SHL_LD) $(LIBOBJS) $(PDCOBJS) pdcurses.obj $(LIBLIBS)
105+
106+
pdcurses.res pdcurses.obj: $(common)\pdcurses.rc
107+
rc -r -fopdcurses.res $(common)\pdcurses.rc
108+
cvtres -machine:$(PLATFORM) -nologo -out:pdcurses.obj pdcurses.res
109+
110+
{$(srcdir)\}.c{}.obj::
111+
$(BUILD) $<
112+
113+
{$(osdir)\}.c{}.obj::
114+
$(BUILD) -Dmain=SDL_main $(SDL3_INCLUDE) $(TTF_INCLUDE) $<
115+
116+
{$(demodir)\}.c{}.obj::
117+
$(BUILD) -Dmain=SDL_main $<
118+
119+
.obj.exe:
120+
$(LINK) $(LDFLAGS) $< $(LIBCURSES) $(CCLIBS)
121+
122+
tuidemo.exe: tuidemo.obj tui.obj pdcurses.lib
123+
$(LINK) $(LDFLAGS) $*.obj tui.obj $(LIBCURSES) $(CCLIBS)
124+
125+
tui.obj: $(demodir)\tui.c $(demodir)\tui.h
126+
$(BUILD) -I$(demodir) $(demodir)\tui.c
127+
128+
tuidemo.obj: $(demodir)\tuidemo.c
129+
$(BUILD) -Dmain=SDL_main -I$(demodir) $(demodir)\tuidemo.c
130+
131+
sdltest.exe: sdltest.obj pdcurses.obj pdcurses.lib
132+
$(LINK) $(LDFLAGS) $*.obj $(LIBCURSES) $(LIBLIBS) $(CCLIBS)

0 commit comments

Comments
 (0)