mirror of
https://github.com/DrBeef/Raze.git
synced 2024-11-15 00:41:55 +00:00
- moved platform backend code to 'common'.
This commit is contained in:
parent
29db3febb8
commit
ebe936f03f
70 changed files with 305 additions and 115 deletions
|
@ -462,84 +462,85 @@ if( ${HAVE_VM_JIT} )
|
|||
set( PROJECT_LIBRARIES ${PROJECT_LIBRARIES} "${ASMJIT_LIBRARIES}")
|
||||
endif()
|
||||
|
||||
# Start defining source files for ZDoom
|
||||
set( PLAT_WIN32_SOURCES
|
||||
platform/win32/i_steam.cpp
|
||||
common/platform/win32/hardware.cpp
|
||||
common/platform/win32/i_crash.cpp
|
||||
common/platform/win32/i_input.cpp
|
||||
common/platform/win32/i_keyboard.cpp
|
||||
common/platform/win32/i_mouse.cpp
|
||||
common/platform/win32/i_dijoy.cpp
|
||||
common/platform/win32/i_rawps2.cpp
|
||||
common/platform/win32/i_xinput.cpp
|
||||
common/platform/win32/i_main.cpp
|
||||
common/platform/win32/i_system.cpp
|
||||
common/platform/win32/i_specialpaths.cpp
|
||||
common/platform/win32/st_start.cpp
|
||||
common/platform/win32/st_start_util.cpp
|
||||
common/platform/win32/gl_sysfb.cpp
|
||||
common/platform/win32/base_sysfb.cpp
|
||||
common/platform/win32/win32basevideo.cpp
|
||||
common/platform/win32/win32glvideo.cpp
|
||||
common/platform/win32/win32polyvideo.cpp)
|
||||
|
||||
if (HAVE_VULKAN)
|
||||
set (PLAT_WIN32_SOURCES ${PLAT_WIN32_SOURCES} common/platform/win32/win32vulkanvideo.cpp )
|
||||
endif()
|
||||
|
||||
set( PLAT_POSIX_SOURCES
|
||||
platform/posix/i_steam.cpp
|
||||
platform/posix/i_system_posix.cpp )
|
||||
common/platform/posix/i_system_posix.cpp )
|
||||
set( PLAT_SDL_SOURCES
|
||||
platform/posix/sdl/crashcatcher.c
|
||||
platform/posix/sdl/hardware.cpp
|
||||
platform/posix/sdl/i_gui.cpp
|
||||
platform/posix/sdl/i_input.cpp
|
||||
platform/posix/sdl/i_joystick.cpp
|
||||
platform/posix/sdl/i_main.cpp
|
||||
platform/posix/sdl/i_system.cpp
|
||||
platform/posix/sdl/sdlglvideo.cpp
|
||||
platform/posix/sdl/st_start.cpp )
|
||||
common/platform/posix/sdl/crashcatcher.c
|
||||
common/platform/posix/sdl/hardware.cpp
|
||||
common/platform/posix/sdl/i_gui.cpp
|
||||
common/platform/posix/sdl/i_input.cpp
|
||||
common/platform/posix/sdl/i_joystick.cpp
|
||||
common/platform/posix/sdl/i_main.cpp
|
||||
common/platform/posix/sdl/i_system.cpp
|
||||
common/platform/posix/sdl/sdlglvideo.cpp
|
||||
common/platform/posix/sdl/st_start.cpp )
|
||||
set( PLAT_UNIX_SOURCES
|
||||
platform/posix/unix/i_specialpaths.cpp
|
||||
platform/posix/unix/gtk_dialogs.cpp )
|
||||
common/platform/posix/unix/i_specialpaths.cpp
|
||||
common/platform/posix/unix/gtk_dialogs.cpp )
|
||||
set( PLAT_OSX_SOURCES
|
||||
platform/posix/osx/iwadpicker_cocoa.mm
|
||||
platform/posix/osx/i_specialpaths.mm
|
||||
common/platform/posix/osx/iwadpicker_cocoa.mm
|
||||
common/platform/posix/osx/i_specialpaths.mm
|
||||
platform/posix/osx/raze.icns )
|
||||
set( PLAT_COCOA_SOURCES
|
||||
platform/posix/cocoa/i_input.mm
|
||||
platform/posix/cocoa/i_joystick.cpp
|
||||
platform/posix/cocoa/i_main.mm
|
||||
platform/posix/cocoa/i_system.mm
|
||||
platform/posix/cocoa/i_video.mm
|
||||
platform/posix/cocoa/st_console.mm
|
||||
platform/posix/cocoa/st_start.mm )
|
||||
|
||||
# Start defining source files
|
||||
set( PLAT_WIN32_SOURCES
|
||||
platform/win32/base_sysfb.cpp
|
||||
platform/win32/gl_sysfb.cpp
|
||||
platform/win32/hardware.cpp
|
||||
platform/win32/i_crash.cpp
|
||||
platform/win32/i_dijoy.cpp
|
||||
platform/win32/i_input.cpp
|
||||
platform/win32/i_keyboard.cpp
|
||||
platform/win32/i_main.cpp
|
||||
platform/win32/i_mouse.cpp
|
||||
platform/win32/i_rawps2.cpp
|
||||
platform/win32/i_specialpaths.cpp
|
||||
platform/win32/i_system.cpp
|
||||
platform/win32/i_xinput.cpp
|
||||
platform/win32/st_start.cpp
|
||||
platform/win32/st_start_util.cpp
|
||||
platform/win32/win32basevideo.cpp
|
||||
platform/win32/win32glvideo.cpp
|
||||
platform/win32/win32vulkanvideo.cpp
|
||||
platform/win32/i_steam.cpp
|
||||
)
|
||||
|
||||
common/platform/posix/cocoa/i_input.mm
|
||||
common/platform/posix/cocoa/i_joystick.cpp
|
||||
common/platform/posix/cocoa/i_main.mm
|
||||
common/platform/posix/cocoa/i_system.mm
|
||||
common/platform/posix/cocoa/i_video.mm
|
||||
common/platform/posix/cocoa/st_console.mm
|
||||
common/platform/posix/cocoa/st_start.mm )
|
||||
|
||||
if( WIN32 )
|
||||
set( SYSTEM_SOURCES_DIR platform/win32 )
|
||||
set( SYSTEM_SOURCES_DIR common/platform/win32 )
|
||||
set( SYSTEM_SOURCES ${PLAT_WIN32_SOURCES} )
|
||||
set( OTHER_SYSTEM_SOURCES ${PLAT_POSIX_SOURCES} ${PLAT_SDL_SOURCES} ${PLAT_OSX_SOURCES} ${PLAT_COCOA_SOURCES} ${PLAT_UNIX_SOURCES} )
|
||||
|
||||
set( SYSTEM_SOURCES ${SYSTEM_SOURCES} platform/win32/gameres.rc )
|
||||
elseif( APPLE )
|
||||
if( OSX_COCOA_BACKEND )
|
||||
set( SYSTEM_SOURCES_DIR platform/posix/cocoa )
|
||||
set( SYSTEM_SOURCES_DIR common/platform/posix common/platform/posix/cocoa )
|
||||
set( SYSTEM_SOURCES ${PLAT_COCOA_SOURCES} )
|
||||
set( OTHER_SYSTEM_SOURCES ${PLAT_WIN32_SOURCES} ${PLAT_SDL_SOURCES} ${PLAT_UNIX_SOURCES} )
|
||||
else()
|
||||
set( SYSTEM_SOURCES_DIR platform/posix/sdl )
|
||||
set( SYSTEM_SOURCES_DIR common/platform/posix common/platform/posix/sdl )
|
||||
set( SYSTEM_SOURCES ${PLAT_SDL_SOURCES} )
|
||||
set( PLAT_OSX_SOURCES ${PLAT_OSX_SOURCES} platform/posix/sdl/i_system.mm )
|
||||
set( PLAT_OSX_SOURCES ${PLAT_OSX_SOURCES} common/platform/posix/sdl/i_system.mm )
|
||||
set( OTHER_SYSTEM_SOURCES ${PLAT_WIN32_SOURCES} ${PLAT_COCOA_SOURCES} ${PLAT_UNIX_SOURCES} )
|
||||
endif()
|
||||
|
||||
set( SYSTEM_SOURCES ${SYSTEM_SOURCES} ${PLAT_POSIX_SOURCES} ${PLAT_OSX_SOURCES} )
|
||||
|
||||
set_source_files_properties( platform/posix/osx/${PROJECT_NAME}.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources )
|
||||
set_source_files_properties( platform/posix/osx/iwadpicker_cocoa.mm PROPERTIES COMPILE_FLAGS -fobjc-exceptions )
|
||||
set_source_files_properties( common/platform/posix/osx/iwadpicker_cocoa.mm PROPERTIES COMPILE_FLAGS -fobjc-exceptions )
|
||||
else()
|
||||
set( SYSTEM_SOURCES_DIR platform/posix/sdl )
|
||||
set( SYSTEM_SOURCES_DIR common/platform/posix common/platform/posix/sdl )
|
||||
set( SYSTEM_SOURCES ${PLAT_POSIX_SOURCES} ${PLAT_SDL_SOURCES} ${PLAT_UNIX_SOURCES} )
|
||||
set( OTHER_SYSTEM_SOURCES ${PLAT_WIN32_SOURCES} ${PLAT_OSX_SOURCES} ${PLAT_COCOA_SOURCES} )
|
||||
endif()
|
||||
|
@ -628,9 +629,13 @@ file( GLOB HEADER_FILES
|
|||
common/console/*.h
|
||||
common/utility/*.h
|
||||
common/engine/*.h
|
||||
common/menu/*.h
|
||||
common/fonts/*.h
|
||||
common/objects/*.h
|
||||
common/filesystem/*.h
|
||||
common/platform/posix/cocoa/*.h
|
||||
common/platform/posix/sdl/*.h
|
||||
common/platform/win32/*.h
|
||||
common/textures/*.h
|
||||
common/textures/hires/hqnx/*.h
|
||||
common/textures/hires/hqnx_asm/*.h
|
||||
|
@ -666,7 +671,7 @@ set( NOT_COMPILED_SOURCE_FILES
|
|||
common/scripting/frontend/zcc-parse.lemon
|
||||
zcc-parse.c
|
||||
zcc-parse.h
|
||||
platform/win32/zutil.natvis
|
||||
common/platform/win32/zutil.natvis
|
||||
)
|
||||
|
||||
set( VM_JIT_SOURCES
|
||||
|
@ -1026,6 +1031,7 @@ include_directories(
|
|||
common/utility
|
||||
common/console
|
||||
common/engine
|
||||
common/menu
|
||||
common/fonts
|
||||
common/objects
|
||||
common/rendering
|
||||
|
@ -1037,7 +1043,6 @@ include_directories(
|
|||
common/scripting/frontend
|
||||
common/scripting/backend
|
||||
${CMAKE_BINARY_DIR}/libraries/gdtoa
|
||||
|
||||
${SYSTEM_SOURCES_DIR}
|
||||
)
|
||||
|
||||
|
@ -1076,7 +1081,7 @@ if( MSVC )
|
|||
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS ${LINKERSTUFF})
|
||||
|
||||
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
|
||||
COMMAND "mt.exe" -manifest \"${CMAKE_CURRENT_SOURCE_DIR}\\platform\\win32\\manifest.game.xml\" -outputresource:\"$<TARGET_FILE:${PROJECT_NAME}>\"\;\#1
|
||||
COMMAND "mt.exe" -manifest \"${CMAKE_CURRENT_SOURCE_DIR}\\common\\platform\\win32\\manifest.xml\" -outputresource:\"$<TARGET_FILE:${PROJECT_NAME}>\"\;\#1
|
||||
COMMENT "Adding manifest..."
|
||||
)
|
||||
|
||||
|
@ -1148,6 +1153,7 @@ source_group("Common\\Utility" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/
|
|||
source_group("Common\\Engine" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/engine/.+")
|
||||
source_group("Common\\2D" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/2d/.+")
|
||||
source_group("Common\\Objects" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/objects/.+")
|
||||
source_group("Common\\Menu" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/menu/.+")
|
||||
source_group("Common\\Fonts" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/fonts/.+")
|
||||
source_group("Common\\File System" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/filesystem/.+")
|
||||
source_group("Common\\Scripting" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/scripting/.+")
|
||||
|
@ -1157,6 +1163,11 @@ source_group("Common\\Scripting\\Backend" REGULAR_EXPRESSION "^${CMAKE_CURRENT_S
|
|||
source_group("Common\\Scripting\\Core" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/scripting/core/.+")
|
||||
source_group("Common\\Scripting\\JIT" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/scripting/jit/.+")
|
||||
source_group("Common\\Scripting\\VM" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/scripting/vm/.+")
|
||||
source_group("Common\\Platforms\\Cocoa Files" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/platform/posix/cocoa/.+")
|
||||
source_group("Common\\Platforms\\OS X Files" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/platform/posix/osx/.+")
|
||||
source_group("Common\\Platforms\\Unix Files" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/platform/posix/unix/.+")
|
||||
source_group("Common\\Platforms\\SDL Files" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/platform/posix/sdl/.+")
|
||||
source_group("Common\\Platforms\\Win32 Files" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/platform/win32/.+")
|
||||
source_group("Common\\Rendering" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/rendering/.+")
|
||||
source_group("Common\\Rendering\\OpenGL Loader" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/rendering/gl_load/.+")
|
||||
source_group("Common\\Textures" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/common/textures/.+")
|
||||
|
@ -1172,9 +1183,6 @@ source_group("Common\\Third Party\\SFMT" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SO
|
|||
source_group("Utility\\Smackerdec" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/smackerdec/.+")
|
||||
source_group("Utility\\Smackerdec\\Headers" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/libsmackerdec/include/.+")
|
||||
source_group("Utility\\Smackerdec\\Sources" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/libsmackerdec/src/.+")
|
||||
source_group("Utility\\XMP-Lite" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/libxmp-lite/.+")
|
||||
source_group("Utility\\XMP-Lite Headers" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/libxmp-lite/include/libxmp-lite/.+")
|
||||
source_group("Utility\\XMP-Lite Sources" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/libxmp-lite/src/.+")
|
||||
source_group("Utility\\Third Party" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/.+")
|
||||
source_group("Utility\\Third Party Headers" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/include/.+")
|
||||
source_group("Utility\\Third Party Sources" REGULAR_EXPRESSION "^${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/src/.+")
|
||||
|
|
9
source/common/engine/g_input.h
Normal file
9
source/common/engine/g_input.h
Normal file
|
@ -0,0 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
// These were in i_input.h, which differed between platforms and on Windows caused problems with its
|
||||
// inclusion of system specific data, so it has been separated into this platform independent file.
|
||||
void I_PutInClipboard (const char *str);
|
||||
FString I_GetFromClipboard (bool use_primary_selection);
|
||||
void I_SetMouseCapture();
|
||||
void I_ReleaseMouseCapture();
|
||||
|
|
@ -10,6 +10,7 @@ struct SystemCallbacks
|
|||
bool (*WantNativeMouse)();
|
||||
bool (*CaptureModeInGame)();
|
||||
void (*CrashInfo)(char* buffer, size_t bufflen, const char* lfstr);
|
||||
void (*PlayStartupSound)(const char* name);
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -24,23 +24,13 @@ void CalculateCPUSpeed(void);
|
|||
|
||||
// Return a seed value for the RNG.
|
||||
unsigned int I_MakeRNGSeed();
|
||||
void I_ShowFatalError(const char* msg);
|
||||
void I_DetectOS (void);
|
||||
|
||||
|
||||
|
||||
void I_StartFrame (void);
|
||||
|
||||
void I_StartTic (void);
|
||||
|
||||
// Asynchronous interrupt functions should maintain private queues
|
||||
// that are read by the synchronous functions
|
||||
// to be converted into events.
|
||||
|
||||
// Either returns a null ticcmd,
|
||||
// or calls a loadable driver to build it.
|
||||
// This ticcmd will then be modified by the gameloop
|
||||
// for normal input.
|
||||
ticcmd_t *I_BaseTiccmd (void);
|
||||
|
||||
// Print a console string
|
||||
void I_PrintStr (const char *str);
|
||||
|
||||
|
@ -77,7 +67,4 @@ inline int I_GetNumaNodeCount() { return 1; }
|
|||
inline int I_GetNumaNodeThreadCount(int numaNode) { return std::max<int>(std::thread::hardware_concurrency(), 1); }
|
||||
inline void I_SetThreadNumaNode(std::thread &thread, int numaNode) { }
|
||||
|
||||
void I_PutInClipboard(const char* str);
|
||||
FString I_GetFromClipboard (bool use_primary_selection);
|
||||
|
||||
#endif
|
|
@ -19,46 +19,11 @@ void CalculateCPUSpeed (void);
|
|||
|
||||
// Return a seed value for the RNG.
|
||||
unsigned int I_MakeRNGSeed();
|
||||
void I_ShowFatalError(const char* msg);
|
||||
|
||||
void I_PutInClipboard(const char* str);
|
||||
FString I_GetFromClipboard(bool use_primary_selection);
|
||||
|
||||
|
||||
//
|
||||
// Called by D_DoomLoop,
|
||||
// called before processing any tics in a frame
|
||||
// (just after displaying a frame).
|
||||
// Time consuming syncronous operations
|
||||
// are performed here (joystick reading).
|
||||
// Can call D_PostEvent.
|
||||
//
|
||||
void I_StartFrame (void);
|
||||
|
||||
|
||||
//
|
||||
// Called by D_DoomLoop,
|
||||
// called before processing each tic in a frame.
|
||||
// Quick syncronous operations are performed here.
|
||||
// Can call D_PostEvent.
|
||||
void I_StartTic (void);
|
||||
|
||||
// Asynchronous interrupt functions should maintain private queues
|
||||
// that are read by the synchronous functions
|
||||
// to be converted into events.
|
||||
|
||||
// Either returns a null ticcmd,
|
||||
// or calls a loadable driver to build it.
|
||||
// This ticcmd will then be modified by the gameloop
|
||||
// for normal input.
|
||||
ticcmd_t *I_BaseTiccmd (void);
|
||||
|
||||
|
||||
// Called by M_Responder when quit is selected.
|
||||
// Clean exit, displays sell blurb.
|
||||
void I_Quit (void);
|
||||
|
||||
|
||||
// Set the mouse cursor. The texture must be 32x32.
|
||||
class FGameTexture;
|
||||
bool I_SetCursor(FGameTexture *cursor);
|
||||
|
@ -113,6 +78,5 @@ FString I_GetLongPathName(const FString &shortpath);
|
|||
int I_GetNumaNodeCount();
|
||||
int I_GetNumaNodeThreadCount(int numaNode);
|
||||
void I_SetThreadNumaNode(std::thread &thread, int numaNode);
|
||||
bool I_QueryPathKey(const wchar_t* keypath, const wchar_t* valname, FString& value);
|
||||
|
||||
#endif
|
|
@ -396,7 +396,8 @@ static const int StrifeStartupPicSizes[4 + 2 + 1] =
|
|||
|
||||
static void ST_Sound(const char* sndname)
|
||||
{
|
||||
//S_Sound(CHAN_BODY, 0, sndname, 1, ATTN_NONE);
|
||||
if (sysCallbacks && sysCallbacks->PlayStartupSound)
|
||||
sysCallbacks->PlayStartupSound(sndname);
|
||||
}
|
||||
|
||||
//==========================================================================
|
199
source/common/platform/win32/win32polyvideo.cpp
Normal file
199
source/common/platform/win32/win32polyvideo.cpp
Normal file
|
@ -0,0 +1,199 @@
|
|||
|
||||
#include <assert.h>
|
||||
#include "hardware.h"
|
||||
#include "engineerrors.h"
|
||||
#include <Windows.h>
|
||||
|
||||
#ifdef HAVE_SOFTPOLY
|
||||
|
||||
EXTERN_CVAR(Bool, vid_vsync)
|
||||
|
||||
bool ViewportLinearScale();
|
||||
|
||||
extern HWND Window;
|
||||
|
||||
#include <d3d9.h>
|
||||
#pragma comment(lib, "d3d9.lib")
|
||||
|
||||
#ifndef D3DPRESENT_FORCEIMMEDIATE
|
||||
#define D3DPRESENT_FORCEIMMEDIATE 0x00000100L // MinGW
|
||||
#endif
|
||||
|
||||
namespace
|
||||
{
|
||||
int SrcWidth = 0;
|
||||
int SrcHeight = 0;
|
||||
int ClientWidth = 0;
|
||||
int ClientHeight = 0;
|
||||
bool CurrentVSync = false;
|
||||
|
||||
IDirect3D9Ex *d3d9 = nullptr;
|
||||
IDirect3DDevice9Ex *device = nullptr;
|
||||
IDirect3DSurface9* surface = nullptr;
|
||||
}
|
||||
|
||||
void I_PolyPresentInit()
|
||||
{
|
||||
Direct3DCreate9Ex(D3D_SDK_VERSION, &d3d9);
|
||||
if (!d3d9)
|
||||
{
|
||||
I_FatalError("Direct3DCreate9 failed");
|
||||
}
|
||||
|
||||
RECT rect = {};
|
||||
GetClientRect(Window, &rect);
|
||||
|
||||
ClientWidth = rect.right;
|
||||
ClientHeight = rect.bottom;
|
||||
|
||||
D3DPRESENT_PARAMETERS pp = {};
|
||||
pp.Windowed = true;
|
||||
pp.SwapEffect = D3DSWAPEFFECT_FLIPEX;
|
||||
pp.BackBufferWidth = ClientWidth;
|
||||
pp.BackBufferHeight = ClientHeight;
|
||||
pp.BackBufferCount = 1;
|
||||
pp.hDeviceWindow = Window;
|
||||
pp.PresentationInterval = CurrentVSync ? D3DPRESENT_INTERVAL_DEFAULT : D3DPRESENT_INTERVAL_IMMEDIATE;
|
||||
|
||||
HRESULT result = d3d9->CreateDeviceEx(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, Window, D3DCREATE_HARDWARE_VERTEXPROCESSING, &pp, nullptr, &device);
|
||||
if (FAILED(result))
|
||||
{
|
||||
I_FatalError("IDirect3D9.CreateDevice failed");
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t *I_PolyPresentLock(int w, int h, bool vsync, int &pitch)
|
||||
{
|
||||
HRESULT result;
|
||||
|
||||
RECT rect = {};
|
||||
GetClientRect(Window, &rect);
|
||||
if (rect.right != ClientWidth || rect.bottom != ClientHeight || CurrentVSync != vsync)
|
||||
{
|
||||
if (surface)
|
||||
{
|
||||
surface->Release();
|
||||
surface = nullptr;
|
||||
}
|
||||
|
||||
CurrentVSync = vsync;
|
||||
ClientWidth = rect.right;
|
||||
ClientHeight = rect.bottom;
|
||||
|
||||
D3DPRESENT_PARAMETERS pp = {};
|
||||
pp.Windowed = true;
|
||||
pp.SwapEffect = D3DSWAPEFFECT_FLIPEX;
|
||||
pp.BackBufferWidth = ClientWidth;
|
||||
pp.BackBufferHeight = ClientHeight;
|
||||
pp.BackBufferCount = 1;
|
||||
pp.hDeviceWindow = Window;
|
||||
pp.PresentationInterval = CurrentVSync ? D3DPRESENT_INTERVAL_DEFAULT : D3DPRESENT_INTERVAL_IMMEDIATE;
|
||||
device->Reset(&pp);
|
||||
}
|
||||
|
||||
if (SrcWidth != w || SrcHeight != h || !surface)
|
||||
{
|
||||
if (surface)
|
||||
{
|
||||
surface->Release();
|
||||
surface = nullptr;
|
||||
}
|
||||
|
||||
SrcWidth = w;
|
||||
SrcHeight = h;
|
||||
result = device->CreateOffscreenPlainSurface(SrcWidth, SrcHeight, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &surface, 0);
|
||||
if (FAILED(result))
|
||||
{
|
||||
I_FatalError("IDirect3DDevice9.CreateOffscreenPlainSurface failed");
|
||||
}
|
||||
}
|
||||
|
||||
D3DLOCKED_RECT lockrect = {};
|
||||
result = surface->LockRect(&lockrect, nullptr, D3DLOCK_DISCARD);
|
||||
if (FAILED(result))
|
||||
{
|
||||
pitch = 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
pitch = lockrect.Pitch;
|
||||
return (uint8_t*)lockrect.pBits;
|
||||
}
|
||||
|
||||
void I_PolyPresentUnlock(int x, int y, int width, int height)
|
||||
{
|
||||
surface->UnlockRect();
|
||||
|
||||
IDirect3DSurface9 *backbuffer = nullptr;
|
||||
HRESULT result = device->GetBackBuffer(0, 0, D3DBACKBUFFER_TYPE_MONO, &backbuffer);
|
||||
if (FAILED(result))
|
||||
return;
|
||||
|
||||
result = device->BeginScene();
|
||||
if (SUCCEEDED(result))
|
||||
{
|
||||
int count = 0;
|
||||
D3DRECT clearrects[4];
|
||||
if (y > 0)
|
||||
{
|
||||
clearrects[count].x1 = 0;
|
||||
clearrects[count].y1 = 0;
|
||||
clearrects[count].x2 = ClientWidth;
|
||||
clearrects[count].y2 = y;
|
||||
count++;
|
||||
}
|
||||
if (y + height < ClientHeight)
|
||||
{
|
||||
clearrects[count].x1 = 0;
|
||||
clearrects[count].y1 = y + height;
|
||||
clearrects[count].x2 = ClientWidth;
|
||||
clearrects[count].y2 = ClientHeight;
|
||||
count++;
|
||||
}
|
||||
if (x > 0)
|
||||
{
|
||||
clearrects[count].x1 = 0;
|
||||
clearrects[count].y1 = y;
|
||||
clearrects[count].x2 = x;
|
||||
clearrects[count].y2 = y + height;
|
||||
count++;
|
||||
}
|
||||
if (x + width < ClientWidth)
|
||||
{
|
||||
clearrects[count].x1 = x + width;
|
||||
clearrects[count].y1 = y;
|
||||
clearrects[count].x2 = ClientWidth;
|
||||
clearrects[count].y2 = y + height;
|
||||
count++;
|
||||
}
|
||||
if (count > 0)
|
||||
device->Clear(count, clearrects, D3DCLEAR_TARGET, 0, 0.0f, 0);
|
||||
|
||||
RECT srcrect = {}, dstrect = {};
|
||||
srcrect.right = SrcWidth;
|
||||
srcrect.bottom = SrcHeight;
|
||||
dstrect.left = x;
|
||||
dstrect.top = y;
|
||||
dstrect.right = x + width;
|
||||
dstrect.bottom = y + height;
|
||||
if (ViewportLinearScale())
|
||||
device->StretchRect(surface, &srcrect, backbuffer, &dstrect, D3DTEXF_LINEAR);
|
||||
else
|
||||
device->StretchRect(surface, &srcrect, backbuffer, &dstrect, D3DTEXF_POINT);
|
||||
|
||||
result = device->EndScene();
|
||||
if (SUCCEEDED(result))
|
||||
device->PresentEx(nullptr, nullptr, 0, nullptr, CurrentVSync ? 0 : D3DPRESENT_FORCEIMMEDIATE);
|
||||
}
|
||||
|
||||
backbuffer->Release();
|
||||
}
|
||||
|
||||
void I_PolyPresentDeinit()
|
||||
{
|
||||
if (surface) surface->Release();
|
||||
if (device) device->Release();
|
||||
if (d3d9) d3d9->Release();
|
||||
}
|
||||
|
||||
#endif
|
21
source/common/platform/win32/win32polyvideo.h
Normal file
21
source/common/platform/win32/win32polyvideo.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
#pragma once
|
||||
|
||||
#include "win32basevideo.h"
|
||||
#include "c_cvars.h"
|
||||
#include "rendering/polyrenderer/backend/poly_framebuffer.h"
|
||||
|
||||
EXTERN_CVAR(Bool, vid_fullscreen)
|
||||
|
||||
class Win32PolyVideo : public Win32BaseVideo
|
||||
{
|
||||
public:
|
||||
void Shutdown() override
|
||||
{
|
||||
}
|
||||
|
||||
DFrameBuffer *CreateFrameBuffer() override
|
||||
{
|
||||
auto fb = new PolyFrameBuffer(m_hMonitor, vid_fullscreen);
|
||||
return fb;
|
||||
}
|
||||
};
|
|
@ -6,10 +6,9 @@
|
|||
#define VK_USE_PLATFORM_WIN32_KHR
|
||||
#endif
|
||||
|
||||
|
||||
#if 0
|
||||
#include "volk/volk.h"
|
||||
|
||||
|
||||
extern HWND Window;
|
||||
|
||||
void I_GetVulkanDrawableSize(int *width, int *height)
|
||||
|
@ -74,4 +73,3 @@ bool I_CreateVulkanSurface(VkInstance instance, VkSurfaceKHR *surface)
|
|||
const VkResult result = vkCreateWin32SurfaceKHR(instance, &windowCreateInfo, nullptr, surface);
|
||||
return result == VK_SUCCESS;
|
||||
}
|
||||
#endif
|
|
@ -5,7 +5,7 @@
|
|||
#include "rendering/vulkan/system/vk_framebuffer.h"
|
||||
|
||||
|
||||
EXTERN_CVAR(Bool, fullscreen)
|
||||
EXTERN_CVAR(Bool, vid_fullscreen)
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
|
@ -35,7 +35,7 @@ public:
|
|||
|
||||
DFrameBuffer *CreateFrameBuffer() override
|
||||
{
|
||||
auto fb = new VulkanFrameBuffer(m_hMonitor, fullscreen, device);
|
||||
auto fb = new VulkanFrameBuffer(m_hMonitor, vid_fullscreen, device);
|
||||
return fb;
|
||||
}
|
||||
|
|
@ -62,6 +62,7 @@
|
|||
#include "gamecontrol.h"
|
||||
#include "v_video.h"
|
||||
#include "v_draw.h"
|
||||
#include "g_input.h"
|
||||
|
||||
#define LEFTMARGIN 8
|
||||
#define RIGHTMARGIN 8
|
||||
|
|
|
@ -139,6 +139,7 @@ static const RegistryPathInfo paths[] = {
|
|||
{ nullptr}
|
||||
};
|
||||
|
||||
bool I_QueryPathKey(const wchar_t* keypath, const wchar_t* valname, FString& value);
|
||||
|
||||
void G_AddExternalSearchPaths(TArray<FString> &searchpaths)
|
||||
{
|
||||
|
|
|
@ -114,4 +114,4 @@ BEGIN
|
|||
END
|
||||
END
|
||||
|
||||
1 24 "manifest.game.xml"
|
||||
1 24 "..\\..\\common\\platform\\win32\\manifest.xml"
|
||||
|
|
Loading…
Reference in a new issue