Skip to content

Commit

Permalink
Separate GL port from SDL2
Browse files Browse the repository at this point in the history
  • Loading branch information
juliusikkala committed May 25, 2023
1 parent 4f3dc96 commit 4678131
Show file tree
Hide file tree
Showing 15 changed files with 5,480 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ else()

endif()

if(PDC_GL_BUILD)

add_subdirectory(gl)

endif()

if(UNIX)
add_subdirectory(vt)
endif()
Expand Down
1 change: 1 addition & 0 deletions cmake/build_options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ option(PDC_DOSVGA_BUILD "Build DOSVGA Project" OFF)
option(PDC_DOSVT_BUILD "Build VT Project" OFF)
option(PDC_SDL2_BUILD "Build SDL2 Project" ON)
option(PDC_SDL2_DEPS_BUILD "Build SDL2 and dependencies" ON)
option(PDC_GL_BUILD "Build OpenGL Project" ON)

message(STATUS "PDC_BUILD_SHARED ....... ${PDC_BUILD_SHARED}")
message(STATUS "PDC_UTF8 ............... ${PDC_UTF8}")
Expand Down
64 changes: 64 additions & 0 deletions gl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
cmake_minimum_required(VERSION 3.11)

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "MinSizeRel" CACHE STRING "Choose the type of build, options are: Debug, Release, or MinSizeRel." FORCE)
message(STATUS "No build type specified, defaulting to MinSizeRel.")
endif()

project(gl VERSION "${PROJECT_VERSION}" LANGUAGES C)
message(STATUS "${PROJECT_NAME} version: ${PROJECT_VERSION}")

message(STATUS "SDL2_LIBRARIES = ${SDL2_LIBRARIES}")
message(STATUS "SDL2_INCLUDE_DIR = ${SDL2_INCLUDE_DIR}")
message(STATUS "SDL2_LIBRARY_DIR = ${SDL2_LIBRARY_DIR}")
message(STATUS "SDL2_TTF_LIBRARY = ${SDL2_TTF_LIBRARY}")
message(STATUS "SDL2_TTF_INCLUDE_DIR = ${SDL2_TTF_INCLUDE_DIR}")
message(STATUS "SDL2_TTF_LIBRARY_DIR = ${SDL2_TTF_LIBRARY_DIR}")

include_directories(${SDL2_INCLUDE_DIR} ${SDL2_TTF_INCLUDE_DIR})
link_directories(${SDL2_LIBRARY_DIR} ${SDL2_TTF_LIBRARY_DIR})

include(project_common)

macro (gl_app dir targ)

set(bin_name "${PROJECT_NAME}_${targ}")

if(${targ} STREQUAL "tuidemo")
set(src_files ${CMAKE_CURRENT_SOURCE_DIR}/${dir}/tuidemo.c ${CMAKE_CURRENT_SOURCE_DIR}/${dir}/tui.c)
else()
set(src_files ${CMAKE_CURRENT_SOURCE_DIR}/${dir}/${targ}.c)
endif()

if(${ARGV2})
add_executable(${bin_name} WIN32 ${src_files})
else()
add_executable(${bin_name} ${src_files})
endif()

target_link_libraries(${bin_name} ${PDCURSE_PROJ} ${EXTRA_LIBS}
"${SDL2_LIBRARIES};${SDL2_TTF_LIBRARY};${FT2_LIBRARY};${ZLIB_LIBRARY};${SDL2_DEP_LIBRARIES}")

add_dependencies(${bin_name} ${PDCURSE_PROJ})
set_target_properties(${bin_name} PROPERTIES OUTPUT_NAME ${targ})

install(TARGETS ${bin_name} RUNTIME DESTINATION ${PDCURSES_DIST}/bin/${PROJECT_NAME} COMPONENT applications)

endmacro ()

gl_app(../demos version)
gl_app(../demos firework)
gl_app(../demos ozdemo)
gl_app(../demos newtest WIN32)
gl_app(../demos ptest)
gl_app(../demos rain)
gl_app(../demos testcurs)
gl_app(../demos tuidemo)
gl_app(../demos worm)
gl_app(../demos xmas)

if(PDC_SDL2_DEPS_BUILD)
add_dependencies(${PDCURSE_PROJ} sdl2_ext sdl2_ttf_ext)
endif()

set(CPACK_COMPONENTS_ALL applications)
74 changes: 74 additions & 0 deletions gl/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
PDCurses for OpenGL 3.3
=======================

This is a port of PDCurses for OpenGL 3.3 on top of SDL2. It's based on the
SDL2 port, but uses OpenGL for character drawing.


Building
--------

- Currently, this port requires using the included CMakeLists.txt for building.
- Depends on SDL2 and SDL2_ttf


Usage
-----

There are no special requirements to use PDCurses for OpenGL -- all
PDCurses-compatible code should work fine.

Unlike the SDL2 PDCurses, this port assumes that the user isn't doing any SDL
or OpenGL stuff behind it's back, as that would break our assumptions of the
OpenGL state machine. However, you can change the SDL window parameters safely
(size, fullscreen).

The default font (if not redefined) is based on the OS:

- Windows: C:/Windows/Fonts/consola.ttf

- Mac: /Library/Fonts/Menlo.ttc

- Other: /usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf

Icons
-----

The icon (used with SDL_SetWindowIcon() -- not used for the executable
file) can be set via the environment variable PDC_ICON, and falls back
to "pdcicon.bmp", and then to the built-in icon from iconbmp.h. The
built-in icon is the PDCurses logo, as seen in ../common/icon32.xpm.

If pdc_screen is preinitialized (see below), PDCurses does not attempt
to set the icon.

Screen size
-----------

The default screen size is 80x25 characters (whatever size they may be),
but you can override this via the environment variables PDC_COLS and/or
PDC_LINES.


Interaction with stdio
----------------------

As with X11, it's a bad idea to mix curses and stdio calls. (In fact,
that's true for PDCurses on any platform; but especially these two,
which don't run under terminals.) Depending on how SDL is built, stdout
and stderr may be redirected to files.


Distribution Status
-------------------

The files in this directory are released to the public domain, EXCEPT for the
'glad'-folder (https://github.com/Dav1dde/glad).


Acknowledgements
----------------

Original SDL port was provided by William McBrine
SDL2 modifications by Laura Michaels and Robin Gustafsson
OpenGL rendering by Julius Ikkala
Loading

0 comments on commit 4678131

Please sign in to comment.