DEADSOFTWARE

render: add stub render
authorDeaDDooMER <deaddoomer@deadsoftware.ru>
Mon, 30 Mar 2020 09:48:55 +0000 (13:48 +0400)
committerDeaDDooMER <deaddoomer@deadsoftware.ru>
Mon, 30 Mar 2020 09:48:55 +0000 (13:48 +0400)
src/CMakeLists.txt
src/stubren/render.c [new file with mode: 0644]

index 67832e8f0ef27ead2e1e601b6c26f872a0f02de4..427acc8679d7940a57254237a3729681c41bc9ce 100644 (file)
@@ -1,10 +1,14 @@
 cmake_minimum_required(VERSION 3.6)
 project(doom2d C)
 
-option(WITH_OPENGL "Build with OpenGL render" ON)
-option(WITH_SOFTWARE "Build with Software render" ON)
+option(RENDER_DRIVER "Build with selected render driver" "OpenGL")
 option(SOUND_DRIVER "Build with selected sound driver" "OpenAL")
 
+string(TOUPPER "${RENDER_DRIVER}" RENDER_DRIVER)
+string(COMPARE EQUAL "${RENDER_DRIVER}" "OPENGL" WITH_OPENGL)
+string(COMPARE EQUAL "${RENDER_DRIVER}" "SOFTWARE" WITH_SOFTWARE)
+string(COMPARE EQUAL "${RENDER_DRIVER}" "STUB" WITH_STUBRENDER)
+
 string(TOUPPER "${SOUND_DRIVER}" SOUND_DRIVER)
 string(COMPARE EQUAL "${SOUND_DRIVER}" "OPENAL" WITH_OPENAL)
 string(COMPARE EQUAL "${SOUND_DRIVER}" "SDLMIXER" WITH_SDLMIXER)
@@ -13,6 +17,7 @@ string(COMPARE EQUAL "${SOUND_DRIVER}" "STUB" WITH_STUBSOUND)
 set(D2D_GAME_ROOT .)
 set(D2D_OPENGL_ROOT ${D2D_GAME_ROOT}/gl)
 set(D2D_SOFTWARE_ROOT ${D2D_GAME_ROOT}/soft)
+set(D2D_STUBRENDER_ROOT ${D2D_GAME_ROOT}/stubren)
 set(D2D_SDL_ROOT ${D2D_GAME_ROOT}/sdl)
 set(D2D_SDLMIXER_ROOT ${D2D_GAME_ROOT}/sdlmixer)
 set(D2D_OPENAL_ROOT ${D2D_GAME_ROOT}/openal)
@@ -21,13 +26,31 @@ set(D2D_STUBSOUND_ROOT ${D2D_GAME_ROOT}/stubsnd)
 aux_source_directory(${D2D_GAME_ROOT} D2D_GAME_SRC)
 aux_source_directory(${D2D_OPENGL_ROOT} D2D_OPENGL_SRC)
 aux_source_directory(${D2D_SOFTWARE_ROOT} D2D_SOFTWARE_SRC)
+aux_source_directory(${D2D_STUBRENDER_ROOT} D2D_STUBRENDER_SRC)
 aux_source_directory(${D2D_SDL_ROOT} D2D_SDL_SRC)
 aux_source_directory(${D2D_SDLMIXER_ROOT} D2D_SDLMIXER_SRC)
 aux_source_directory(${D2D_OPENAL_ROOT} D2D_OPENAL_SRC)
 aux_source_directory(${D2D_STUBSOUND_ROOT} D2D_STUBSOUND_SRC)
 
 find_package(SDL REQUIRED)
-message(STATUS "sound::${SOUND_DRIVER}")
+
+if (WITH_STUBRENDER)
+  set(D2D_RENDER_SRC "${D2D_STUBRENDER_SRC}")
+  set(D2D_RENDER_INCLUDE_DIR "")
+  set(D2D_RENDER_LIBRARY "")
+elseif(WITH_OPENGL)
+  find_package(OpenGL REQUIRED)
+  set(D2D_RENDER_SRC "${D2D_OPENGL_SRC}")
+  set(D2D_RENDER_INCLUDE_DIR "${OPENGL_INCLUDE_DIR}")
+  set(D2D_RENDER_LIBRARY "${OPENGL_LIBRARY}")  
+elseif(WITH_SOFTWARE)
+  set(D2D_RENDER_SRC "${D2D_SOFTWARE_SRC}")
+  set(D2D_RENDER_INCLUDE_DIR "")
+  set(D2D_RENDER_LIBRARY "")
+else(WITH_STUBRENDER)
+  message(FATAL_ERROR "Select RENDER_DRIVER as 'OPENGL' or 'SOFTWARE' or 'STUB'")
+endif(WITH_STUBRENDER)
+
 if(WITH_STUBSOUND)
   set(D2D_SOUND_SRC "${D2D_STUBSOUND_SRC}")
   set(D2D_SOUND_INCLUDE_DIR "")
@@ -46,10 +69,6 @@ else(WITH_STUBSOUND)
   message(FATAL_ERROR "Select SOUND_DRIVER as 'OPENAL' or 'SDLMIXER' or 'STUB'")
 endif(WITH_STUBSOUND)
 
-if (WITH_OPENGL)
-  find_package(OpenGL REQUIRED)
-endif (WITH_OPENGL)
-
 if (NOT CMAKE_BUILD_TYPE)
   set(CMAKE_BUILD_TYPE Release)
 endif (NOT CMAKE_BUILD_TYPE)
@@ -63,20 +82,9 @@ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
 message(STATUS "=== BUILD OPTIONS ===")
 message(STATUS "BUILD:  " "${CMAKE_BUILD_TYPE}")
 message(STATUS "CFLAGS: " "${CMAKE_C_FLAGS}")
+message(STATUS "RENDER: " "${RENDER_DRIVER}")
 message(STATUS "SOUND:  " "${SOUND_DRIVER}")
 
-message(STATUS "=== RENDERS ===")
-message(STATUS "SOFTWARE: " ${WITH_SOFTWARE})
-message(STATUS "OPENGL:   " ${WITH_OPENGL})
-
-if (WITH_OPENGL)
-  add_executable(doom2d-gl ${D2D_GAME_SRC} ${D2D_SOUND_SRC} ${D2D_SDL_SRC} ${D2D_OPENGL_SRC})
-  target_include_directories(doom2d-gl PRIVATE "${D2D_GAME_ROOT}" "${D2D_SOUND_INCLUDE_DIR}" "${SDL_INCLUDE_DIR}" "${OPENGL_INCLUDE_DIR}")
-  target_link_libraries(doom2d-gl "${D2D_SOUND_LIBRARY}" "${SDL_LIBRARY}" "${OPENGL_LIBRARY}")
-endif (WITH_OPENGL)
-
-if (WITH_SOFTWARE)
-  add_executable(doom2d-soft ${D2D_GAME_SRC} ${D2D_SOUND_SRC} ${D2D_SDL_SRC} ${D2D_SOFTWARE_SRC})
-  target_include_directories(doom2d-soft PRIVATE "${D2D_GAME_ROOT}" "${D2D_SOUND_INCLUDE_DIR}" "${SDL_INCLUDE_DIR}")
-  target_link_libraries(doom2d-soft "${D2D_SOUND_LIBRARY}" "${SDL_LIBRARY}")
-endif (WITH_SOFTWARE)
+add_executable(doom2d ${D2D_GAME_SRC} ${D2D_RENDER_SRC} ${D2D_SOUND_SRC} ${D2D_SDL_SRC})
+target_include_directories(doom2d PRIVATE "${D2D_GAME_ROOT}" "${D2D_RENDER_INCLUDE_DIR}" "${D2D_SOUND_INCLUDE_DIR}" "${SDL_INCLUDE_DIR}")
+target_link_libraries(doom2d "${D2D_RENDER_LIBRARY}" "${D2D_SOUND_LIBRARY}" "${SDL_LIBRARY}")
diff --git a/src/stubren/render.c b/src/stubren/render.c
new file mode 100644 (file)
index 0000000..2ea2714
--- /dev/null
@@ -0,0 +1,56 @@
+#include "render.h"
+
+int SCRW, SCRH; // public
+static int gamma;
+
+void R_draw (void) {
+
+}
+
+void R_alloc (void) {
+
+}
+
+void R_init (void) {
+
+}
+
+void R_done (void) {
+
+}
+
+void R_setgamma (int g) {
+  gamma = g;
+}
+
+int R_getgamma (void) {
+  return gamma;
+}
+
+void R_toggle_fullscreen (void) {
+
+}
+
+void R_get_name (int n, char s[8]) {
+
+}
+
+int R_get_special_id (int n) {
+  return -1;
+}
+
+void R_begin_load (void) {
+
+}
+
+void R_load (char s[8], int f) {
+
+}
+
+void R_end_load (void) {
+
+}
+
+void R_loadsky (int sky) {
+
+}
\ No newline at end of file