Skip to content

Commit

Permalink
Merge branch 'tools'
Browse files Browse the repository at this point in the history
Bringing back support for the (MFC-based Windows-only) editing tools.
Only tested 32bit (not sure if the code is 64bit-clean), needs a
"proper" (non-Express) version of Visual Studio *including* MFC support,
tested the free "Community" Editions of VS 2013 and 2017.
(For VS2013 I needed to install the "Visual C++ MFC MBCS Library for
Visual Studio 2013" because it either didn't include MFC support at all
or only the wrong version, don't remember, you'll need that one anyway)
  • Loading branch information
DanielGibson committed Mar 11, 2019
2 parents 17c10d4 + 5c1e1d7 commit 3a763fc
Show file tree
Hide file tree
Showing 191 changed files with 1,105 additions and 433 deletions.
116 changes: 103 additions & 13 deletions neo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ include(GNUInstallDirs OPTIONAL RESULT_VARIABLE GNUINSTALLDIRS)
option(CORE "Build the core" ON)
option(BASE "Build the base game code" ON)
option(D3XP "Build the d3xp game code" ON)
if(MSVC)
option(TOOLS "Build the tools game code (Windows+Visual Studio+SDL2 only)" OFF)
endif()
option(DEDICATED "Build the dedicated server" OFF)
option(ONATIVE "Optimize for the host CPU" OFF)
option(SDL2 "Use SDL2 instead of SDL1.2" ON)
Expand Down Expand Up @@ -149,6 +152,16 @@ else()
set(CURL_LIBRARY "")
endif()

if(MSVC)
# This is required for tools on windows.
find_package(MFC)

if(TOOLS AND NOT MFC_FOUND)
message(SEND_ERROR "MFC ('Microsoft Foundation Classes for C++') couldn't be found, but is needed for TOOLS!")
message(FATAL_ERROR "If you're using VS2013, you'll also need the 'Multibyte MFC Library for Visual Studio 2013': https://www.microsoft.com/en-us/download/details.aspx?id=40770 (VS2015 and 2017 include that in the default MFC package)")
endif()
endif()

# compiler specific flags
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
add_compile_options(-pipe)
Expand Down Expand Up @@ -231,7 +244,10 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
set(sys_libs ${sys_libs} ${EXECINFO_LIBRARIES})
endif()
elseif(MSVC)
add_definitions(/MP) # parallel build (use all cores, or as many as configured in VS)

add_compile_options(/W4)
add_compile_options(/we4840) # treat as error when passing a class to a vararg-function (probably printf-like)
add_compile_options(/wd4100) # unreferenced formal parameter
add_compile_options(/wd4127) # conditional expression is constant
add_compile_options(/wd4244) # possible loss of data
Expand Down Expand Up @@ -509,12 +525,6 @@ set(src_ui

add_globbed_headers(src_ui "ui")

set(src_tools
tools/guied/GEWindowWrapper_stub.cpp
)

# TODO: add_globbed_headers(src_tools "tools/guied")

set(src_idlib
idlib/bv/Bounds.cpp
idlib/bv/Frustum.cpp
Expand Down Expand Up @@ -734,6 +744,80 @@ set(src_core
set(src_stub_openal sys/stub/openal_stub.cpp)
set(src_stub_gl sys/stub/stub_gl.cpp)


set(src_tools
tools/guied/GEWindowWrapper_stub.cpp
)

# TODO: add_globbed_headers(src_tools "tools/guied")

# Begin normal tools code
if (TOOLS AND MFC_FOUND AND MSVC)
set(ALLOWRESOURCES ON)
# Common files.
file(GLOB src_comafx "tools/comafx/*.cpp")
add_globbed_headers(src_comafx "tools/comafx")
file(GLOB_RECURSE src_tools_common "tools/common/*.cpp")
add_globbed_headers(src_tools_common "tools/common")

#Compilers.
# DG: this is always added, why add it again? file(GLOB src_compiler_renderbump "neo/tools/compilers/renderbump/*.cpp")
file(GLOB src_compiler_roqvq "tools/compilers/roqvq/*.cpp") # FIXME: some of those were added before
add_globbed_headers(src_compiler_roqvq "tools/compilers/roqvq")
#tools
# Articulated Frame editor.
file(GLOB src_afeditor "tools/af/*.cpp")
add_globbed_headers(src_afeditor "tools/af")
# Declaration editor
file(GLOB src_decleditor "tools/decl/*.cpp")
add_globbed_headers(src_decleditor "tools/decl")
# GUI Editor.
file(GLOB src_gui_editor "tools/guied/*.cpp")
add_globbed_headers(src_gui_editor "tools/guied")
# Material editor
file(GLOB src_materialeditor "tools/materialeditor/*.cpp")
add_globbed_headers(src_materialeditor "tools/materialeditor")
# Particle Editor
file(GLOB src_particleeditor "tools/particle/*.cpp")
add_globbed_headers(src_particleeditor "tools/particle")
# PDA editor
file(GLOB src_pdaeditor "tools/pda/*.cpp")
add_globbed_headers(src_pdaeditor "tools/pda")
# Radiant ( Map editor )
file(GLOB src_map_editor "tools/radiant/*.cpp")
add_globbed_headers(src_map_editor "tools/radiant")
# Script editor
file(GLOB src_script_editor "tools/script/*.cpp")
add_globbed_headers(src_script_editor "tools/script")
# sound editor?
file(GLOB src_sound_editor "tools/sound/*.cpp")
add_globbed_headers(src_sound_editor "tools/sound")


# The numerous tools in a nice list.
list(APPEND src_editor_tools
${src_comafx}
${src_tools_common}
${src_compiler_renderbump}
${src_afeditor}
${src_decleditor}
${src_gui_editor}
${src_materialeditor}
${src_particleeditor}
${src_pdaeditor}
${src_map_editor}
${src_script_editor}
${src_sound_editor}
"tools/edit_public.h"
"tools/edit_gui_common.h"
)
SET(CMAKE_MFC_FLAG 2)
set(TOOLS_DEFINES "ID_ALLOW_TOOLS;__AFXDLL")
else()
set(src_editor_tools "tools/edit_stub.cpp" "tools/edit_public.h")
endif()


if(AROS)
set(DHEWM3BINARY "ADoom3")
set(sys_libs ${sys_libs} dll)
Expand Down Expand Up @@ -783,9 +867,6 @@ elseif(APPLE)
${OSX_RESOURCE_FILES}
)
elseif(WIN32)
set(WIN32_RESOURCE_FILES
"${CMAKE_SOURCE_DIR}/sys/win32/rc/dhewm3.rc"
)

set(src_sys_base
sys/cpu.cpp
Expand All @@ -799,7 +880,7 @@ elseif(WIN32)
sys/win32/win_syscon.cpp
sys/win32/SDL_win32_main.c
)

# adding the few relevant headers in sys/ manually..
set(src_sys_base ${src_sys_base}
sys/platform.h
Expand All @@ -810,8 +891,16 @@ elseif(WIN32)

set(src_sys_core
sys/glimp.cpp
${WIN32_RESOURCE_FILES}
)

if(TOOLS)
set(src_sys_core ${src_sys_core} "sys/win32/rc/doom.rc")
else()
# adding both .rc files breaks the build, but I think it only contains the icon
# and doom.rc also contains that (+icons for editor etc, AFAIK), so this is fine
set(src_sys_core ${src_sys_core} "${CMAKE_SOURCE_DIR}/sys/win32/rc/dhewm3.rc" )
endif()

else()
set(src_sys_base
sys/cpu.cpp
Expand Down Expand Up @@ -852,11 +941,12 @@ if(CORE)
${src_core}
${src_sys_base}
${src_sys_core}
${src_editor_tools}
)

source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} PREFIX neo FILES ${src_core} ${src_sys_base} ${src_sys_core})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} PREFIX neo FILES ${src_core} ${src_sys_base} ${src_sys_core} ${src_editor_tools})

set_target_properties(${DHEWM3BINARY} PROPERTIES COMPILE_DEFINITIONS "__DOOM_DLL__")
set_target_properties(${DHEWM3BINARY} PROPERTIES COMPILE_DEFINITIONS "__DOOM_DLL__;${TOOLS_DEFINES}")
set_target_properties(${DHEWM3BINARY} PROPERTIES LINK_FLAGS "${ldflags}")
set_target_properties(${DHEWM3BINARY} PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${PROJECT_SOURCE_DIR}/sys/osx/Info.plist)

Expand Down
4 changes: 2 additions & 2 deletions neo/framework/BuildDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ If you have questions concerning this license or the applicable additional terms
// compiled out.
//#define ID_DEDICATED

// don't define ID_ALLOW_TOOLS when we don't want tool code in the executable.
#if defined( _WIN32 ) && defined(_MFC_VER) && !defined( ID_DEDICATED )
// don't define ID_ALLOW_TOOLS when we don't want tool code in the executable. - DG: defined in cmake now
#if 0 // defined( _WIN32 ) && defined(_MFC_VER) && !defined( ID_DEDICATED )
#define ID_ALLOW_TOOLS
#endif

Expand Down
1 change: 1 addition & 0 deletions neo/framework/Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ If you have questions concerning this license or the applicable additional terms
#include "renderer/RenderSystem.h"
#include "tools/compilers/compiler_public.h"
#include "tools/compilers/aas/AASFileManager.h"
#include "tools/edit_public.h"

#include "framework/Common.h"

Expand Down
2 changes: 2 additions & 0 deletions neo/framework/Console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ If you have questions concerning this license or the applicable additional terms

#include "framework/Console.h"

#include "tools/edit_public.h"

void SCR_DrawTextLeftAlign( float &y, const char *text, ... ) id_attribute((format(printf,2,3)));
void SCR_DrawTextRightAlign( float &y, const char *text, ... ) id_attribute((format(printf,2,3)));

Expand Down
2 changes: 2 additions & 0 deletions neo/framework/FileSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ If you have questions concerning this license or the applicable additional terms
===============================================================================
*/

// FIXME: DG: this assumes 32bit time_t, but it's 64bit now, at least on some platforms incl. Win32 in modern VS
// => change it (to -1?) or does that break anything?
static const ID_TIME_T FILE_NOT_FOUND_TIMESTAMP = 0xFFFFFFFF;
static const int MAX_PURE_PAKS = 128;
static const int MAX_OSPATH = FILENAME_MAX;
Expand Down
9 changes: 9 additions & 0 deletions neo/idlib/math/Matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ If you have questions concerning this license or the applicable additional terms
#include <malloc.h>
#endif

#ifdef _MSC_VER // DG: I don't care if matrix code has some unused r variable only used for assertions, shut up VS
#pragma warning( push )
#pragma warning( disable : 4189 )
#endif

/*
===============================================================================
Expand Down Expand Up @@ -2946,4 +2951,8 @@ ID_INLINE float *idMatX::ToFloatPtr( void ) {
return mat;
}

#ifdef _MSC_VER // DG: re-enable warning 4189
#pragma warning( pop )
#endif

#endif /* !__MATH_MATRIX_H__ */
4 changes: 2 additions & 2 deletions neo/renderer/Image_files.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -957,7 +957,7 @@ void R_LoadImage( const char *cname, byte **pic, int *width, int *height, ID_TIM
*pic = NULL;
}
if ( timestamp ) {
*timestamp = 0xFFFFFFFF;
*timestamp = FILE_NOT_FOUND_TIMESTAMP;
}
if ( width ) {
*width = 0;
Expand All @@ -978,7 +978,7 @@ void R_LoadImage( const char *cname, byte **pic, int *width, int *height, ID_TIM

if ( ext == "tga" ) {
LoadTGA( name.c_str(), pic, width, height, timestamp ); // try tga first
if ( ( pic && *pic == 0 ) || ( timestamp && *timestamp == -1 ) ) {
if ( ( pic && *pic == 0 ) || ( timestamp && *timestamp == FILE_NOT_FOUND_TIMESTAMP ) ) {
name.StripFileExtension();
name.DefaultFileExtension( ".jpg" );
LoadJPG( name.c_str(), pic, width, height, timestamp );
Expand Down
6 changes: 3 additions & 3 deletions neo/renderer/Image_program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ static bool R_ParseImageProgram_r( idLexer &src, byte **pic, int *width, int *he
}

if ( !token.Icmp( "addnormals" ) ) {
byte *pic2;
byte *pic2 = NULL;
int width2, height2;

MatchAndAppendToken( src, "(" );
Expand Down Expand Up @@ -454,7 +454,7 @@ static bool R_ParseImageProgram_r( idLexer &src, byte **pic, int *width, int *he
}

if ( !token.Icmp( "add" ) ) {
byte *pic2;
byte *pic2 = NULL;
int width2, height2;

MatchAndAppendToken( src, "(" );
Expand Down Expand Up @@ -589,7 +589,7 @@ static bool R_ParseImageProgram_r( idLexer &src, byte **pic, int *width, int *he
// load it as an image
R_LoadImage( token.c_str(), pic, width, height, &timestamp, true );

if ( timestamp == -1 ) {
if ( timestamp == FILE_NOT_FOUND_TIMESTAMP ) {
return false;
}

Expand Down
7 changes: 7 additions & 0 deletions neo/renderer/RenderSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,13 @@ void idRenderSystemLocal::BeginFrame( int windowWidth, int windowHeight ) {
windowHeight = tiledViewport[1];
}

// DG: FIXME: WTF?! this is *not* reset in EndFrame() and next time
// idSessionLocal::UpdateScreen() calls this function to render a proper frame,
// passing renderSystem->GetScreenWidth()/Height() WHICH JUST RETURN glConfig.vidWidth/Height
// will render the whole frame in that resolution (in a corner of the window), unless someone
// resets glConfig.vid* manually... this is quite fragile, I wonder how many (more) bugs
// (esp. in Editor code) will turn up because of this, but right now I don't dare to change
// the behavior either, in case "fixing" it breaks other things
glConfig.vidWidth = windowWidth;
glConfig.vidHeight = windowHeight;

Expand Down
33 changes: 33 additions & 0 deletions neo/renderer/qgl.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,37 @@ extern PFNGLPROGRAMLOCALPARAMETER4FVARBPROC qglProgramLocalParameter4fvARB;
// GL_EXT_depth_bounds_test
extern PFNGLDEPTHBOUNDSEXTPROC qglDepthBoundsEXT;

#if defined( _WIN32 ) && defined(ID_ALLOW_TOOLS)

extern int (WINAPI * qwglChoosePixelFormat)(HDC, CONST PIXELFORMATDESCRIPTOR *);
extern int (WINAPI * qwglDescribePixelFormat) (HDC, int, UINT, LPPIXELFORMATDESCRIPTOR);
extern int (WINAPI * qwglGetPixelFormat)(HDC);
extern BOOL(WINAPI * qwglSetPixelFormat)(HDC, int, CONST PIXELFORMATDESCRIPTOR *);
extern BOOL(WINAPI * qwglSwapBuffers)(HDC);

extern BOOL(WINAPI * qwglCopyContext)(HGLRC, HGLRC, UINT);
extern HGLRC(WINAPI * qwglCreateContext)(HDC);
extern HGLRC(WINAPI * qwglCreateLayerContext)(HDC, int);
extern BOOL(WINAPI * qwglDeleteContext)(HGLRC);
extern HGLRC(WINAPI * qwglGetCurrentContext)(VOID);
extern HDC(WINAPI * qwglGetCurrentDC)(VOID);
extern PROC(WINAPI * qwglGetProcAddress)(LPCSTR);
extern BOOL(WINAPI * qwglMakeCurrent)(HDC, HGLRC);
extern BOOL(WINAPI * qwglShareLists)(HGLRC, HGLRC);
extern BOOL(WINAPI * qwglUseFontBitmaps)(HDC, DWORD, DWORD, DWORD);

extern BOOL(WINAPI * qwglUseFontOutlines)(HDC, DWORD, DWORD, DWORD, FLOAT,
FLOAT, int, LPGLYPHMETRICSFLOAT);

extern BOOL(WINAPI * qwglDescribeLayerPlane)(HDC, int, int, UINT,
LPLAYERPLANEDESCRIPTOR);
extern int (WINAPI * qwglSetLayerPaletteEntries)(HDC, int, int, int,
CONST COLORREF *);
extern int (WINAPI * qwglGetLayerPaletteEntries)(HDC, int, int, int,
COLORREF *);
extern BOOL(WINAPI * qwglRealizeLayerPalette)(HDC, int, BOOL);
extern BOOL(WINAPI * qwglSwapLayerBuffers)(HDC, UINT);

#endif // _WIN32 && ID_ALLOW_TOOLS

#endif
Loading

0 comments on commit 3a763fc

Please sign in to comment.