Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile on mingw32 #80

Merged
merged 2 commits into from
Oct 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 15 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ set(VERSION_MINOR "0")
string(TIMESTAMP VERSION_PATCH "%Y%m%d")

option(BONZOMATIC_64BIT "Compile for 64 bit target?" ON)
if (MSVC)
if (WIN32)
if (CMAKE_GENERATOR MATCHES "64")
set(BONZOMATIC_64BIT ON CACHE BOOL "Compile for 64 bit target?")
else ()
Expand Down Expand Up @@ -42,7 +42,7 @@ if (UNIX)
add_definitions(-DGTK)
endif ()

if (MSVC)
if (WIN32)
#set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /VERBOSE")
#set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /VERBOSE")
#set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /VERBOSE")
Expand All @@ -61,7 +61,7 @@ if (APPLE)
endif ()

# Dont compile glfw and glew for windows dx targets
if (APPLE OR UNIX OR (MSVC AND (${BONZOMATIC_WINDOWS_FLAVOR} MATCHES "GLFW")))
if (APPLE OR UNIX OR (WIN32 AND (${BONZOMATIC_WINDOWS_FLAVOR} MATCHES "GLFW")))
##############################################################################
# GLFW
# GLFW settings and project inclusion
Expand All @@ -75,7 +75,7 @@ if (APPLE OR UNIX OR (MSVC AND (${BONZOMATIC_WINDOWS_FLAVOR} MATCHES "GLFW")))
set(GLFW_USE_RETINA OFF CACHE BOOL "" FORCE)
set(GLFW_USE_MENUBAR ON CACHE BOOL "" FORCE)
mark_as_advanced(GLFW_USE_CHDIR GLFW_USE_RETINA GLFW_USE_MENUBAR)
elseif (MSVC)
elseif (WIN32)
set(USE_MSVC_RUNTIME_LIBRARY_DLL OFF CACHE BOOL "" FORCE)
mark_as_advanced(USE_MSVC_RUNTIME_LIBRARY_DLL)
endif()
Expand Down Expand Up @@ -118,7 +118,7 @@ elseif (UNIX)
else ()
set(BZC_PROJECT_LIBS ${BZC_PROJECT_LIBS} ${CMAKE_SOURCE_DIR}/external/bass/x86/libbass.so)
endif ()
elseif (MSVC)
elseif (WIN32)
if (BONZOMATIC_64BIT)
set(BZC_PROJECT_LIBS ${BZC_PROJECT_LIBS} ${CMAKE_SOURCE_DIR}/external/bass/x64/bass.lib)
else ()
Expand All @@ -141,7 +141,7 @@ set(BZC_PROJECT_LIBS ${BZC_PROJECT_LIBS} bzc_jsonxx)

##############################################################################
# NDI
if (MSVC AND BONZOMATIC_NDI)
if (WIN32 AND BONZOMATIC_NDI)

if(DEFINED ENV{NDI_SDK_DIR})
set(NDI_SDK_DIR "$ENV{NDI_SDK_DIR}")
Expand Down Expand Up @@ -345,7 +345,7 @@ elseif (UNIX)
${CMAKE_SOURCE_DIR}/src/platform_x11/Clipboard.cpp
)
source_group("Bonzomatic\\Platform" FILES ${BZC_PLATFORM_SRCS})
elseif (MSVC)
elseif (WIN32)
if (${BONZOMATIC_WINDOWS_FLAVOR} MATCHES "DX11")
set(BZC_PLATFORM_SRCS
${CMAKE_SOURCE_DIR}/src/platform_w32_dx11/Renderer.cpp
Expand Down Expand Up @@ -390,7 +390,7 @@ elseif (MSVC)
set(BZC_PROJECT_INCLUDES ${CMAKE_SOURCE_DIR}/data/windows ${BZC_PROJECT_INCLUDES})
endif ()

if (MSVC AND BONZOMATIC_NDI)
if (WIN32 AND BONZOMATIC_NDI)
set(BZC_CAPTURE_SRCS
${CMAKE_SOURCE_DIR}/src/capturing/Capture_NDI.cpp
)
Expand Down Expand Up @@ -435,7 +435,7 @@ if (APPLE)
set(PLATFORM_LIBS ${COCOA_FRAMEWORK} ${OPENGL_FRAMEWORK} ${CARBON_FRAMEWORK})
elseif (UNIX)
set(PLATFORM_LIBS GL)
elseif (MSVC)
elseif (WIN32)
if (${BONZOMATIC_WINDOWS_FLAVOR} MATCHES "DX11")
set(PLATFORM_LIBS d3d11 d3dcompiler dxguid DXGI winmm)
elseif (${BONZOMATIC_WINDOWS_FLAVOR} MATCHES "DX9")
Expand Down Expand Up @@ -467,17 +467,19 @@ elseif (UNIX)
if (NOT BONZOMATIC_64BIT)
# set_target_properties(${BZC_EXE_NAME} PROPERTIES COMPILE_FLAGS "-m32" LINK_FLAGS "-m32")
endif ()
elseif (MSVC)
elseif (WIN32)
if (BONZOMATIC_NDI)
target_compile_definitions(${BZC_EXE_NAME} PUBLIC -DBONZOMATIC_ENABLE_NDI)
endif ()
set_target_properties(${BZC_EXE_NAME} PROPERTIES LINK_FLAGS "/SUBSYSTEM:CONSOLE")
target_compile_options(${BZC_EXE_NAME} PUBLIC "$<$<CONFIG:Release>:/MT>")
if (MSVC)
set_target_properties(${BZC_EXE_NAME} PROPERTIES LINK_FLAGS "/SUBSYSTEM:CONSOLE")
target_compile_options(${BZC_EXE_NAME} PUBLIC "$<$<CONFIG:Release>:/MT>")
endif ()
endif ()
target_include_directories(${BZC_EXE_NAME} PUBLIC ${BZC_PROJECT_INCLUDES})
target_link_libraries(${BZC_EXE_NAME} ${BZC_PROJECT_LIBS})

if (MSVC)
if (WIN32)
if (BONZOMATIC_64BIT)
add_custom_command(TARGET ${BZC_EXE_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_SOURCE_DIR}/external/bass/x64/bass.dll" $<TARGET_FILE_DIR:${BZC_EXE_NAME}>)
else ()
Expand Down
5 changes: 4 additions & 1 deletion src/platform_w32_common/SetupDialog.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#include <windows.h>
#ifdef __MINGW32__
#include <stdio.h>
#endif
#include <tchar.h>
#include "../Renderer.h"
#include "resource.h"
Expand Down Expand Up @@ -140,4 +143,4 @@ bool Renderer::OpenSetupDialog( RENDERER_SETTINGS * settings )
CSetupDialog dlg;
dlg.setup = settings;
return dlg.Open( GetModuleHandle(NULL), NULL );
}
}
16 changes: 15 additions & 1 deletion src/platform_w32_dx9/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@

#define DEVTYPE D3DDEVTYPE_HAL

#if defined(__MINGW32__) && !defined(D3D9b_SDK_VERSION)
#define D3D9b_SDK_VERSION 31
// From https://docs.rs/winapi/0.2.8/i686-pc-windows-gnu/winapi/d3d9/constant.D3D9b_SDK_VERSION.html
#endif

#ifndef WM_MOUSEHWHEEL
#define WM_MOUSEHWHEEL (0x020E)
#endif

const char * shaderKeyword =
" register packoffset static const"
" break continue discard do for if else switch while case default return true false"
Expand Down Expand Up @@ -597,9 +606,14 @@ namespace Renderer
pConstantTable->SetFloat( pDevice, szConstName, x );
}

static D3DXVECTOR4 SetShaderConstant_VEC4;
void SetShaderConstant( const char * szConstName, float x, float y )
{
pConstantTable->SetVector( pDevice, szConstName, &D3DXVECTOR4(x, y, 0, 0) );
SetShaderConstant_VEC4.x = x;
SetShaderConstant_VEC4.y = y;
SetShaderConstant_VEC4.z = 0;
SetShaderConstant_VEC4.w = 0;
pConstantTable->SetVector( pDevice, szConstName, &SetShaderConstant_VEC4 );
}

struct DX9Texture : public Texture
Expand Down