Add some windows support.
This commit is contained in:
parent
c651dcd038
commit
63565fc7f1
11 changed files with 87 additions and 33 deletions
22
i686-w64-mingw32.txt
Normal file
22
i686-w64-mingw32.txt
Normal file
|
@ -0,0 +1,22 @@
|
|||
[binaries]
|
||||
c = 'i686-w64-mingw32-gcc'
|
||||
cpp = 'i686-w64-mingw32-g++'
|
||||
ar = 'i686-w64-mingw32-ar'
|
||||
strip = 'i686-w64-mingw32-strip'
|
||||
pkg-config = 'i686-w64-mingw32-pkg-config'
|
||||
windres = 'i686-w64-mingw32-windres'
|
||||
#exe_wrapper = 'wine'
|
||||
ld = 'i686-w64-mingw32-ld'
|
||||
|
||||
[properties]
|
||||
# Directory that contains 'bin', 'lib', etc
|
||||
root = '/usr/i686-w64-mingw32'
|
||||
# Directory that contains 'bin', 'lib', etc for the toolchain and system libraries
|
||||
sys_root = '/usr/i686-w64-mingw32/sys-root/mingw'
|
||||
|
||||
[host_machine]
|
||||
system = 'windows'
|
||||
cpu_family = 'x86'
|
||||
cpu = 'i686'
|
||||
endian = 'little'
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
#include "linuxController.hh"
|
||||
#include "desktopController.hh"
|
||||
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
bool LinuxController::InitializeController() {
|
||||
bool DesktopController::InitializeController() {
|
||||
std::ifstream gameControllerDB;
|
||||
gameControllerDB.open("./gamecontrollerdb.txt");
|
||||
if (gameControllerDB.is_open()) {
|
||||
|
@ -20,23 +20,23 @@ bool LinuxController::InitializeController() {
|
|||
return false;
|
||||
}
|
||||
|
||||
void LinuxController::PollController() {
|
||||
void DesktopController::PollController() {
|
||||
glfwGetGamepadState(GLFW_JOYSTICK_1, &controllerState);
|
||||
}
|
||||
|
||||
bool LinuxController::IsButtonPressed(Button button) {
|
||||
bool DesktopController::IsButtonPressed(Button button) {
|
||||
return controllerState.buttons[GetButtonMask(button)];
|
||||
}
|
||||
|
||||
float LinuxController::GetLeftJoystickXAxis() {
|
||||
float DesktopController::GetLeftJoystickXAxis() {
|
||||
return controllerState.axes[GLFW_GAMEPAD_AXIS_LEFT_X];
|
||||
}
|
||||
|
||||
float LinuxController::GetLeftJoystickYAxis() {
|
||||
float DesktopController::GetLeftJoystickYAxis() {
|
||||
return controllerState.axes[GLFW_GAMEPAD_AXIS_LEFT_Y];
|
||||
}
|
||||
|
||||
int LinuxController::GetButtonMask(Button button) {
|
||||
int DesktopController::GetButtonMask(Button button) {
|
||||
switch (button) {
|
||||
case Button::A:
|
||||
return GLFW_GAMEPAD_BUTTON_A;
|
|
@ -3,7 +3,7 @@
|
|||
#include "controller.hh"
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
class LinuxController : public Controller {
|
||||
class DesktopController : public Controller {
|
||||
public:
|
||||
bool InitializeController() override;
|
||||
void PollController() override;
|
|
@ -4,8 +4,8 @@ if host_machine.system() == 'dreamcast'
|
|||
sources += 'dreamcastController.cc'
|
||||
endif
|
||||
|
||||
if host_machine.system() == 'linux'
|
||||
sources += 'linuxController.cc'
|
||||
if host_machine.system() != 'dreamcast'
|
||||
sources += 'desktopController.cc'
|
||||
endif
|
||||
|
||||
controller = static_library('controller', sources)
|
||||
controller = static_library('controller', sources, dependencies: engine_deps)
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
#ifdef __linux__
|
||||
#ifndef _arch_dreamcast
|
||||
|
||||
#include "linuxEngine.hh"
|
||||
#include "desktopEngine.hh"
|
||||
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
|
||||
#include "controller/linuxController.hh"
|
||||
#include "controller/desktopController.hh"
|
||||
|
||||
void LinuxEngine::initializeEngine() {
|
||||
void DesktopEngine::initializeEngine() {
|
||||
glfwInit();
|
||||
// Set OpenGL version to 1.2.
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 1);
|
||||
|
@ -28,8 +28,8 @@ void LinuxEngine::initializeEngine() {
|
|||
// printSystemInformation();
|
||||
}
|
||||
|
||||
void LinuxEngine::initializeController() {
|
||||
LinuxController* linuxCont = new LinuxController;
|
||||
void DesktopEngine::initializeController() {
|
||||
DesktopController* linuxCont = new DesktopController;
|
||||
if (linuxCont->InitializeController()) {
|
||||
controller = linuxCont;
|
||||
} else {
|
||||
|
@ -37,16 +37,16 @@ void LinuxEngine::initializeController() {
|
|||
}
|
||||
}
|
||||
|
||||
void LinuxEngine::SwapBuffers() {
|
||||
void DesktopEngine::SwapBuffers() {
|
||||
glfwSwapBuffers(window);
|
||||
glfwPollEvents();
|
||||
}
|
||||
|
||||
bool LinuxEngine::ShouldWindowClose() {
|
||||
bool DesktopEngine::ShouldWindowClose() {
|
||||
return glfwWindowShouldClose(this->window);
|
||||
}
|
||||
|
||||
LinuxEngine::~LinuxEngine() {
|
||||
DesktopEngine::~DesktopEngine() {
|
||||
delete controller;
|
||||
glfwDestroyWindow(window);
|
||||
glfwTerminate();
|
|
@ -3,12 +3,12 @@
|
|||
#include "nativeEngine.hh"
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
class LinuxEngine : public NativeEngine {
|
||||
class DesktopEngine : public NativeEngine {
|
||||
void initializeController() override;
|
||||
void initializeEngine() override;
|
||||
void SwapBuffers() override;
|
||||
bool ShouldWindowClose() override;
|
||||
~LinuxEngine() override;
|
||||
~DesktopEngine() override;
|
||||
GLFWwindow* window = nullptr;
|
||||
};
|
||||
#endif
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include "dreamcastEngine.hh"
|
||||
#else
|
||||
#include "linuxEngine.hh"
|
||||
#include "desktopEngine.hh"
|
||||
#endif
|
||||
|
||||
#include <cstdio>
|
||||
|
@ -18,7 +18,7 @@ void Engine::initializeEngine() {
|
|||
#ifdef _arch_dreamcast
|
||||
engine = new DreamcastEngine;
|
||||
#else
|
||||
engine = new LinuxEngine;
|
||||
engine = new DesktopEngine;
|
||||
#endif
|
||||
engine->initializeEngine();
|
||||
initScreen();
|
||||
|
|
|
@ -3,12 +3,12 @@ engine_deps = [
|
|||
math,
|
||||
]
|
||||
|
||||
if host_machine.system() == 'linux'
|
||||
engine_deps += dependency('glfw3')
|
||||
engine_deps += dependency('epoxy')
|
||||
if host_machine.system() != 'dreamcast'
|
||||
engine_deps += dependency('glfw3', fallback: ['glfw', 'glfw_dep'], required: true)
|
||||
engine_deps += dependency('epoxy', fallback: ['epoxy', 'libepoxy_dep'], required: true)
|
||||
endif
|
||||
|
||||
subdir('controller')
|
||||
|
||||
engine = static_library('engine', ['dreamcastEngine.cc', 'linuxEngine.cc', 'entity.cc', 'engine.cc'], dependencies: engine_deps, include_directories: incdirs)
|
||||
engine = static_library('engine', ['dreamcastEngine.cc', 'desktopEngine.cc', 'entity.cc', 'engine.cc'], dependencies: engine_deps, include_directories: incdirs)
|
||||
engine_dep = declare_dependency(link_with: [engine, controller], include_directories: incdirs)
|
||||
|
|
|
@ -5,7 +5,11 @@ koskernelinc = include_directories('/opt/toolchains/dc/kos/kernel/arch/dreamcast
|
|||
kosaddonsinc = include_directories('/opt/toolchains/dc/kos/addons/include')
|
||||
kosportsinc = include_directories('/opt/toolchains/dc/kos-ports/include')
|
||||
|
||||
if host_machine.system() == 'windows'
|
||||
GL = cc.find_library('opengl32', required: true)
|
||||
else
|
||||
GL = cc.find_library('GL', required: true)
|
||||
endif
|
||||
math = cc.find_library('m', required: true)
|
||||
# pcx = cc.find_library('pcx', required: true)
|
||||
# kosutils = cc.find_library('kosutils', required: true)
|
||||
|
@ -32,9 +36,13 @@ if host_machine.system() == 'dreamcast'
|
|||
]
|
||||
endif
|
||||
|
||||
if host_machine.system() == 'linux'
|
||||
deps += dependency('glfw3')
|
||||
deps += dependency('glu')
|
||||
if host_machine.system() != 'dreamcast'
|
||||
deps += dependency('glfw3', fallback: ['glfw', 'glfw_dep'], required: true)
|
||||
if host_machine.system() == 'windows'
|
||||
deps += cc.find_library('glu32', required: true)
|
||||
elif
|
||||
deps += dependency('glu', required: true)
|
||||
endif
|
||||
endif
|
||||
|
||||
subdir('engine')
|
||||
|
@ -58,5 +66,7 @@ subdir('flappyBird')
|
|||
|
||||
executable('hello.elf', ['hello.cc'], dependencies: [deps] + [hello_dep], include_directories: incdirs)
|
||||
executable('gl.elf', ['gl.cc'], dependencies: [deps] + [glcc_dep], include_directories: incdirs)
|
||||
if host_machine.system() != 'windows'
|
||||
executable('cube.elf', cube_sources, dependencies: deps, include_directories: incdirs)
|
||||
endif
|
||||
executable('flappyBird.elf', ['flappyBird.cc'], dependencies: [deps] + [flappy_dep], include_directories: incdirs)
|
||||
|
|
9
subprojects/epoxy.wrap
Normal file
9
subprojects/epoxy.wrap
Normal file
|
@ -0,0 +1,9 @@
|
|||
[wrap-file]
|
||||
directory = libepoxy-1.5.10
|
||||
source_url = https://github.com/anholt/libepoxy/archive/refs/tags/1.5.10.tar.gz
|
||||
source_filename = libepoxy-1.5.10.tar.gz
|
||||
source_hash = a7ced37f4102b745ac86d6a70a9da399cc139ff168ba6b8002b4d8d43c900c15
|
||||
wrapdb_version = 1.5.10-2
|
||||
|
||||
[provide]
|
||||
epoxy = libepoxy_dep
|
13
subprojects/glfw.wrap
Normal file
13
subprojects/glfw.wrap
Normal file
|
@ -0,0 +1,13 @@
|
|||
[wrap-file]
|
||||
directory = glfw-3.3.9
|
||||
source_url = https://github.com/glfw/glfw/archive/refs/tags/3.3.9.tar.gz
|
||||
source_filename = glfw-3.3.9.tar.gz
|
||||
source_hash = a7e7faef424fcb5f83d8faecf9d697a338da7f7a906fc1afbc0e1879ef31bd53
|
||||
patch_filename = glfw_3.3.9-1_patch.zip
|
||||
patch_url = https://wrapdb.mesonbuild.com/v2/glfw_3.3.9-1/get_patch
|
||||
patch_hash = b4261ed4de479ea0496617feace62eec5b73f62bf3c88dd1537afcf5eebd5cab
|
||||
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/glfw_3.3.9-1/glfw-3.3.9.tar.gz
|
||||
wrapdb_version = 3.3.9-1
|
||||
|
||||
[provide]
|
||||
glfw3 = glfw_dep
|
Loading…
Reference in a new issue