Compare commits
2
Commits
afe30a5dbd
...
3b0b103eb3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3b0b103eb3
|
||
|
|
6beef97cdf
|
+47
-38
@@ -9,44 +9,49 @@ option(PD_ENABLE_CITRO3D "Enable Citro3D Support (3DS)" OFF)
|
||||
option(PD_ENABLE_VULKAN "Not implemented yet" OFF)
|
||||
|
||||
if(NOT WIN32) # cause we are not on windows...
|
||||
set(PD_ENABLE_DIRECTX9 OFF)
|
||||
set(PD_ENABLE_DIRECTX9 OFF)
|
||||
endif()
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Nintendo3DS")
|
||||
set(PD_ENABLE_OPENGL2 OFF)
|
||||
set(PD_ENABLE_OPENGL3 OFF)
|
||||
set(PD_ENABLE_VULKAN OFF)
|
||||
set(PD_ENABLE_CITRO3D ON)
|
||||
set(PD_ENABLE_OPENGL2 OFF)
|
||||
set(PD_ENABLE_OPENGL3 OFF)
|
||||
set(PD_ENABLE_VULKAN OFF)
|
||||
set(PD_ENABLE_CITRO3D ON)
|
||||
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "NintendoSwitch")
|
||||
set(PD_ENABLE_OPENGL2 OFF)
|
||||
set(PD_ENABLE_OPENGL3 ON)
|
||||
set(PD_ENABLE_VULKAN OFF)
|
||||
set(PD_ENABLE_CITRO3D OFF)
|
||||
endif()
|
||||
|
||||
add_library(pd-system STATIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/source/gl-helper.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/source/gfx_opengl2.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/source/gfx_opengl3.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/source/gfx_directx9.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/source/gfx_citro3d.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/source/gl-helper.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/source/gfx_opengl2.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/source/gfx_opengl3.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/source/gfx_directx9.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/source/gfx_citro3d.cpp
|
||||
)
|
||||
|
||||
target_include_directories(pd-system
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:include>
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||
$<INSTALL_INTERFACE:include>
|
||||
)
|
||||
|
||||
target_compile_options(palladium
|
||||
PUBLIC $<$<CXX_COMPILER_ID:GNU,Clang>:
|
||||
PUBLIC $<$<CXX_COMPILER_ID:GNU,Clang>:
|
||||
-fmacro-prefix-map=${CMAKE_CURRENT_SOURCE_DIR}/source=source
|
||||
-fmacro-prefix-map=${CMAKE_CURRENT_SOURCE_DIR}/include=include
|
||||
>
|
||||
)
|
||||
|
||||
target_compile_definitions(pd-system
|
||||
PUBLIC
|
||||
$<$<BOOL:${PD_ENABLE_OPENGL2}>:PD_ENABLE_OPENGL2>
|
||||
$<$<BOOL:${PD_ENABLE_OPENGL3}>:PD_ENABLE_OPENGL3>
|
||||
$<$<BOOL:${PD_ENABLE_VULKAN}>:PD_ENABLE_VULKAN>
|
||||
$<$<BOOL:${PD_ENABLE_DIRECTX9}>:PD_ENABLE_DIRECTX9>
|
||||
$<$<BOOL:${PD_ENABLE_CITRO3D}>:PD_ENABLE_CITRO3D>
|
||||
PUBLIC
|
||||
$<$<BOOL:${PD_ENABLE_OPENGL2}>:PD_ENABLE_OPENGL2>
|
||||
$<$<BOOL:${PD_ENABLE_OPENGL3}>:PD_ENABLE_OPENGL3>
|
||||
$<$<BOOL:${PD_ENABLE_VULKAN}>:PD_ENABLE_VULKAN>
|
||||
$<$<BOOL:${PD_ENABLE_DIRECTX9}>:PD_ENABLE_DIRECTX9>
|
||||
$<$<BOOL:${PD_ENABLE_CITRO3D}>:PD_ENABLE_CITRO3D>
|
||||
)
|
||||
|
||||
# Palladium
|
||||
@@ -54,30 +59,34 @@ target_link_libraries(pd-system PUBLIC palladium::palladium)
|
||||
|
||||
# glad (if we have any OpenGL version included)
|
||||
if(PD_ENABLE_OPENGL2 OR PD_ENABLE_OPENGL3)
|
||||
target_link_libraries(pd-system
|
||||
PUBLIC glad
|
||||
)
|
||||
target_link_libraries(pd-system
|
||||
PUBLIC glad
|
||||
)
|
||||
endif()
|
||||
|
||||
# DirectX9
|
||||
if(PD_ENABLE_DIRECTX9)
|
||||
target_link_libraries(pd-system
|
||||
PUBLIC
|
||||
d3d9
|
||||
d3dcompiler
|
||||
)
|
||||
target_link_libraries(pd-system
|
||||
PUBLIC
|
||||
d3d9
|
||||
d3dcompiler
|
||||
)
|
||||
endif()
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Nintendo3DS")
|
||||
target_link_libraries(pd-system
|
||||
PUBLIC
|
||||
pica::pica
|
||||
citro3d
|
||||
ctru
|
||||
)
|
||||
target_link_libraries(pd-system
|
||||
PUBLIC
|
||||
pica::pica
|
||||
citro3d
|
||||
ctru
|
||||
)
|
||||
else()
|
||||
target_link_libraries(pd-system
|
||||
PUBLIC
|
||||
spirv-helper
|
||||
)
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "NintendoSwitch")
|
||||
target_include_directories(pd-system
|
||||
PUBLIC $ENV{DEVKITPRO}/portlibs/switch/include
|
||||
)
|
||||
endif()
|
||||
target_link_libraries(pd-system
|
||||
PUBLIC spirv-helper
|
||||
)
|
||||
endif()
|
||||
|
||||
@@ -11,9 +11,6 @@ struct GfxCitro3DConfig {
|
||||
// Index Allocator
|
||||
template <typename T>
|
||||
using IndexAlloc = LinearAllocator<T>;
|
||||
|
||||
static constexpr size_t NumVertices = 32768; // 8192*4
|
||||
static constexpr size_t NumIndices = 49152; // 8192*6
|
||||
};
|
||||
|
||||
class GfxCitro3D : public GfxDriverBase<GfxCitro3DConfig> {
|
||||
|
||||
@@ -10,9 +10,6 @@ struct GfxDirectX9Config {
|
||||
// Index Allocator
|
||||
template <typename T>
|
||||
using IndexAlloc = std::allocator<T>;
|
||||
|
||||
static constexpr size_t NumVertices = 32768; // 8192*4
|
||||
static constexpr size_t NumIndices = 49152; // 8192*6
|
||||
};
|
||||
|
||||
class GfxDirectX9 : public GfxDriverBase<GfxDirectX9Config> {
|
||||
|
||||
@@ -10,9 +10,6 @@ struct GfxOpenGL2Config {
|
||||
// Index Allocator
|
||||
template <typename T>
|
||||
using IndexAlloc = std::allocator<T>;
|
||||
|
||||
static constexpr size_t NumVertices = 32768; // 8192*4
|
||||
static constexpr size_t NumIndices = 49152; // 8192*6
|
||||
};
|
||||
|
||||
class GfxOpenGL2 : public GfxDriverBase<GfxOpenGL2Config> {
|
||||
|
||||
@@ -10,9 +10,6 @@ struct GfxOpenGL3Config {
|
||||
// Index Allocator
|
||||
template <typename T>
|
||||
using IndexAlloc = std::allocator<T>;
|
||||
|
||||
static constexpr size_t NumVertices = 32768; // 8192*4
|
||||
static constexpr size_t NumIndices = 49152; // 8192*6
|
||||
};
|
||||
|
||||
class GfxOpenGL3 : public GfxDriverBase<GfxOpenGL3Config> {
|
||||
|
||||
@@ -61,6 +61,8 @@ struct GfxDirectX9::Impl {
|
||||
IDirect3DVertexShader9* VS = nullptr;
|
||||
IDirect3DPixelShader9* FS = nullptr;
|
||||
IDirect3DTexture9* CurrentTex = nullptr;
|
||||
size_t VertexBufferSize = 0;
|
||||
size_t IndexBufferSize = 0;
|
||||
};
|
||||
|
||||
void GfxDirectX9::SysInit() {
|
||||
@@ -78,14 +80,7 @@ void GfxDirectX9::SysInit() {
|
||||
0},
|
||||
D3DDECL_END()};
|
||||
impl->Device->CreateVertexDeclaration(elements, &impl->Decl);
|
||||
impl->Device->CreateVertexBuffer(
|
||||
GfxDirectX9Config::NumVertices * sizeof(PD::Li::Vertex),
|
||||
D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, 0, D3DPOOL_DEFAULT, &impl->VBO,
|
||||
nullptr);
|
||||
impl->Device->CreateIndexBuffer(GfxDirectX9Config::NumIndices * sizeof(u16),
|
||||
D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY,
|
||||
D3DFMT_INDEX16, D3DPOOL_DEFAULT, &impl->IBO,
|
||||
nullptr);
|
||||
|
||||
ID3DBlob* vsBlob = nullptr;
|
||||
ID3DBlob* errBlob = nullptr;
|
||||
HRESULT hr = D3DCompile(g_vsCode, strlen(g_vsCode), nullptr, nullptr,
|
||||
@@ -140,6 +135,32 @@ void GfxDirectX9::Submit(size_t count, size_t start) {
|
||||
impl->Device->SetVertexShaderConstantF(
|
||||
0, reinterpret_cast<const float*>(&Projection), 4);
|
||||
|
||||
if (!impl->VBO || impl->VertexBufferSize != GetVertexPoolSize()) {
|
||||
if (impl->VBO) {
|
||||
impl->VBO->Release();
|
||||
impl->VBO = nullptr;
|
||||
impl->VertexBufferSize = 0;
|
||||
}
|
||||
if (impl->Device->CreateVertexBuffer(
|
||||
GetVertexPoolSize() * sizeof(Li::Vertex),
|
||||
D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, 0, D3DPOOL_DEFAULT,
|
||||
&impl->VBO, nullptr) < 0)
|
||||
return;
|
||||
impl->VertexBufferSize = GetVertexPoolSize();
|
||||
}
|
||||
if (!impl->IBO || impl->IndexBufferSize != GetIndexPoolSize()) {
|
||||
if (impl->IBO) {
|
||||
impl->IBO->Release();
|
||||
impl->IBO = nullptr;
|
||||
impl->IndexBufferSize = 0;
|
||||
}
|
||||
if (impl->Device->CreateIndexBuffer(GetVertexPoolSize() * sizeof(u16),
|
||||
D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY,
|
||||
D3DFMT_INDEX16, D3DPOOL_DEFAULT,
|
||||
&impl->IBO, nullptr) < 0)
|
||||
return;
|
||||
impl->IndexBufferSize = GetIndexPoolSize();
|
||||
}
|
||||
void* vptr;
|
||||
impl->VBO->Lock(0, 0, &vptr, D3DLOCK_DISCARD);
|
||||
memcpy(vptr, GetVertexBufPtr(0), CurrentVertex * sizeof(PD::Li::Vertex));
|
||||
|
||||
+11
-10
@@ -5,10 +5,11 @@
|
||||
#include <pd/lithium/command.hpp>
|
||||
#include <pd/lithium/texture.hpp>
|
||||
|
||||
using LiBackendFlags = PD::u32;
|
||||
enum LiBackendFlags_ {
|
||||
LiBackendFlags_None = 0,
|
||||
LiBackendFlags_FlipUV_Y = 1 << 0, // Essential for font loading
|
||||
using PDBackendFlags = PD::u32;
|
||||
enum PDBackendFlags_ {
|
||||
PDBackendFlags_None = 0,
|
||||
PDBackendFlags_FlipUV_Y = 1 << 0, // Essential for font loading
|
||||
PDBackendFlags_WindingCW = 1 << 0, // Use CW instead of CCW winding
|
||||
};
|
||||
|
||||
namespace PD {
|
||||
@@ -20,7 +21,10 @@ class PD_API GfxDriver : public DriverInterface {
|
||||
virtual ~GfxDriver();
|
||||
|
||||
virtual void Init() {}
|
||||
virtual void Deinit() { SysDeinit(); }
|
||||
virtual void Deinit() {
|
||||
DeleteTexture(pWhite);
|
||||
SysDeinit();
|
||||
}
|
||||
|
||||
void SetViewPort(const ivec2& size);
|
||||
void SetViewPort(int x, int y);
|
||||
@@ -66,9 +70,6 @@ struct DefaultGfxConfig {
|
||||
// Index Allocator
|
||||
template <typename T>
|
||||
using IndexAlloc = std::allocator<T>;
|
||||
|
||||
static constexpr size_t NumVertices = 32768; // 8192*4
|
||||
static constexpr size_t NumIndices = 49152; // 8192*6
|
||||
};
|
||||
|
||||
template <typename Config = DefaultGfxConfig>
|
||||
@@ -81,8 +82,6 @@ class GfxDriverBase : public GfxDriver {
|
||||
virtual ~GfxDriverBase() {}
|
||||
|
||||
void Init() override {
|
||||
// pVtxPool.Init(Config::NumVertices);
|
||||
// pIdxPool.Init(Config::NumIndices);
|
||||
SysInit();
|
||||
std::vector<u8> img(16 * 16 * 4, 0xff);
|
||||
pWhite = LoadTexture(img, 16, 16);
|
||||
@@ -122,6 +121,8 @@ class GfxDriverBase : public GfxDriver {
|
||||
protected:
|
||||
u16* GetIndexBufPtr(size_t start) { return &pIdxPool[start]; }
|
||||
Li::Vertex* GetVertexBufPtr(size_t start) { return &pVtxPool[start]; }
|
||||
size_t GetVertexPoolSize() const { return pVtxPool.size(); }
|
||||
size_t GetIndexPoolSize() const { return pIdxPool.size(); }
|
||||
void ResetPools() override {
|
||||
pVtxPool.Reset();
|
||||
pIdxPool.Reset();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/targets.cmake)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/core)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/gfx)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/gfx)
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 7.7 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 21 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
@@ -0,0 +1,45 @@
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
set(APP_TITLE "App")
|
||||
set(APP_AUTHOR "tobid7")
|
||||
set(APP_VERSION "${CMAKE_PROJECT_VERSION}")
|
||||
set(APP_ICON "icon.png")
|
||||
set(APP_ROMFS "romfs")
|
||||
|
||||
function(make_3ds_target _NAME TITLE AUTHOR _VERSION ICON ROMFS)
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Nintendo3DS")
|
||||
find_program(3DSXTOOL 3dsxtool)
|
||||
find_program(SMDHTOOL smdhtool)
|
||||
add_custom_target(${_NAME}.smdh
|
||||
COMMAND ${SMDHTOOL} --create "${TITLE}" "${_VERSION}" "${AUTHOR}" "${ICON}"
|
||||
${_NAME}.smdh
|
||||
DEPENDS ${_NAME}.elf
|
||||
COMMENT "Creating ${_NAME}.smdh"
|
||||
)
|
||||
add_custom_target(${_NAME}.3dsx
|
||||
COMMAND ${3DSXTOOL} ${_NAME}.elf ${_NAME}.3dsx --smdh=${_NAME}.smdh
|
||||
--romfs="${ROMFS}"
|
||||
DEPENDS ${_NAME}.smdh
|
||||
COMMENT "Creating ${_NAME}.3dsx"
|
||||
)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(make_nx_target _NAME TITLE AUTHOR _VERSION ICON ROMFS)
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "NintendoSwitch")
|
||||
find_program(ELF2NRO elf2nro)
|
||||
find_program(NACPTOOL nacptool)
|
||||
add_custom_target(${_NAME}.nacp
|
||||
COMMAND ${NACPTOOL} --create "${TITLE}" "${AUTHOR}" "${_VERSION}"
|
||||
${_NAME}.nacp
|
||||
DEPENDS ${_NAME}.elf
|
||||
COMMENT "Creating ${_NAME}.nacp"
|
||||
)
|
||||
add_custom_target(${_NAME}.nro
|
||||
COMMAND ${ELF2NRO} ${_NAME}.elf ${_NAME}.nro --nacp=${_NAME}.nacp
|
||||
--romfsdir="${ROMFS}" --icon="${ICON}"
|
||||
DEPENDS ${_NAME}.nacp
|
||||
COMMENT "Creating ${_NAME}.nro"
|
||||
)
|
||||
endif()
|
||||
endfunction()
|
||||
@@ -5,10 +5,42 @@ project(gfx-tests)
|
||||
add_executable(gfx-tests ${CMAKE_CURRENT_SOURCE_DIR}/source/main.cpp)
|
||||
target_link_libraries(gfx-tests PRIVATE palladium::palladium pd-system stb)
|
||||
|
||||
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Nintendo3DS")
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Nintendo3DS")
|
||||
target_link_libraries(gfx-tests PRIVATE ctru)
|
||||
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "NintendoSwitch")
|
||||
target_link_libraries(gfx-tests
|
||||
PRIVATE
|
||||
glad
|
||||
glfw3
|
||||
EGL
|
||||
glapi
|
||||
drm_nouveau
|
||||
nx
|
||||
)
|
||||
target_compile_definitions(gfx-tests PRIVATE __SWITCH__ ENABLE_NXLINK)
|
||||
else()
|
||||
target_link_libraries(gfx-tests PRIVATE glfw)
|
||||
endif()
|
||||
|
||||
install(
|
||||
TARGETS gfx-tests
|
||||
)
|
||||
)
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Nintendo3DS")
|
||||
make_3ds_target(
|
||||
"gfx-tests"
|
||||
"Palladium Gfx Tests"
|
||||
"tobid7"
|
||||
"1.0.0"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../assets/icon48.png"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../assets"
|
||||
)
|
||||
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "NintendoSwitch")
|
||||
make_nx_target(
|
||||
"gfx-tests"
|
||||
"Palladium Gfx Tests"
|
||||
"tobid7"
|
||||
"1.0.0"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../assets/icon.jpg"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../assets"
|
||||
)
|
||||
endif()
|
||||
+71
-23
@@ -1,4 +1,4 @@
|
||||
#ifdef __3DS__
|
||||
#if defined(__3DS__)
|
||||
#include <3ds.h>
|
||||
#include <citro3d.h>
|
||||
const u32 DisplayTransferFlags =
|
||||
@@ -6,6 +6,22 @@ const u32 DisplayTransferFlags =
|
||||
GX_TRANSFER_RAW_COPY(0) | GX_TRANSFER_IN_FORMAT(GX_TRANSFER_FMT_RGBA8) |
|
||||
GX_TRANSFER_OUT_FORMAT(GX_TRANSFER_FMT_RGB8) |
|
||||
GX_TRANSFER_SCALING(GX_TRANSFER_SCALE_NO));
|
||||
#elif defined(__SWITCH__)
|
||||
#define GLFW_INCLUDE_NONE
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <glad/glad.h>
|
||||
#include <stdio.h>
|
||||
#include <switch.h>
|
||||
|
||||
static void errorCallback(int errorCode, const char* description) {
|
||||
printf("Glfw Error %d: %s\n", errorCode, description);
|
||||
}
|
||||
|
||||
#define PASSERT(x) \
|
||||
if (!x) { \
|
||||
printf("%s: %s", __PRETTY_FUNCTION__, #x); \
|
||||
exit(0); \
|
||||
}
|
||||
#else
|
||||
#include <glad/glad.h>
|
||||
//////////////////////////
|
||||
@@ -44,7 +60,32 @@ class App {
|
||||
public:
|
||||
App(Driver d = Driver::OpenGL3) : pDriver(d) {
|
||||
PD::Os::UseDriver<PD::OsDriver>();
|
||||
#ifndef __3DS__
|
||||
#if defined(__3DS__)
|
||||
romfsInit();
|
||||
gfxInitDefault();
|
||||
consoleInit(GFX_BOTTOM, nullptr);
|
||||
C3D_Init(C3D_DEFAULT_CMDBUF_SIZE);
|
||||
Top =
|
||||
C3D_RenderTargetCreate(240, 400, GPU_RB_RGBA8, GPU_RB_DEPTH24_STENCIL8);
|
||||
Bottom =
|
||||
C3D_RenderTargetCreate(240, 320, GPU_RB_RGBA8, GPU_RB_DEPTH24_STENCIL8);
|
||||
C3D_RenderTargetSetOutput(Top, GFX_TOP, GFX_LEFT, DisplayTransferFlags);
|
||||
C3D_RenderTargetSetOutput(Bottom, GFX_BOTTOM, GFX_LEFT,
|
||||
DisplayTransferFlags);
|
||||
PD::Gfx::UseDriver<PD::GfxCitro3D>();
|
||||
#elif defined(__SWITCH__)
|
||||
PASSERT(glfwInit());
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
|
||||
window =
|
||||
glfwCreateWindow(1280, 720, "gfx_test (OpenGL3)", nullptr, nullptr);
|
||||
PASSERT(window);
|
||||
glfwMakeContextCurrent(window);
|
||||
PASSERT(gladLoadGL());
|
||||
glfwSwapInterval(1);
|
||||
PD::Gfx::UseDriver<PD::GfxOpenGL3>();
|
||||
#else
|
||||
glfwInit();
|
||||
std::string winname = "gfx_test";
|
||||
if (d == Driver::OpenGL2) {
|
||||
@@ -94,22 +135,10 @@ class App {
|
||||
}
|
||||
#endif
|
||||
glfwSwapInterval(1);
|
||||
#else
|
||||
gfxInitDefault();
|
||||
consoleInit(GFX_BOTTOM, nullptr);
|
||||
C3D_Init(C3D_DEFAULT_CMDBUF_SIZE);
|
||||
Top =
|
||||
C3D_RenderTargetCreate(240, 400, GPU_RB_RGBA8, GPU_RB_DEPTH24_STENCIL8);
|
||||
Bottom =
|
||||
C3D_RenderTargetCreate(240, 320, GPU_RB_RGBA8, GPU_RB_DEPTH24_STENCIL8);
|
||||
C3D_RenderTargetSetOutput(Top, GFX_TOP, GFX_LEFT, DisplayTransferFlags);
|
||||
C3D_RenderTargetSetOutput(Bottom, GFX_BOTTOM, GFX_LEFT,
|
||||
DisplayTransferFlags);
|
||||
PD::Gfx::UseDriver<PD::GfxCitro3D>();
|
||||
#endif
|
||||
PD::Gfx::Init();
|
||||
#ifdef __3DS__
|
||||
pTex = LoadTex("sdmc:/icon.png");
|
||||
#if defined(__3DS__) || defined(__SWITCH__)
|
||||
pTex = LoadTex("romfs:/icon.png");
|
||||
#else
|
||||
pTex = LoadTex("icon.png");
|
||||
#endif
|
||||
@@ -124,19 +153,30 @@ class App {
|
||||
~App() {
|
||||
PD::Gfx::DeleteTexture(pTex);
|
||||
PD::Gfx::Deinit();
|
||||
#ifndef __3DS__
|
||||
glfwDestroyWindow(window);
|
||||
#if !defined(__3DS__)
|
||||
glfwTerminate();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Run() {
|
||||
#ifdef __3DS__
|
||||
#if defined(__3DS__)
|
||||
while (aptMainLoop()) {
|
||||
PD::Gfx::SetViewPort(400, 240);
|
||||
C3D_FrameBegin(C3D_FRAME_SYNCDRAW);
|
||||
C3D_FrameDrawOn(Top);
|
||||
C3D_RenderTargetClear(Top, C3D_CLEAR_ALL, PD::Color(25, 25, 25, 25), 0);
|
||||
#elif defined(__SWITCH__)
|
||||
while (!glfwWindowShouldClose(window)) {
|
||||
GLFWgamepadstate _gs;
|
||||
if (glfwGetGamepadState(GLFW_JOYSTICK_1, &_gs)) {
|
||||
if (_gs.buttons[GLFW_GAMEPAD_BUTTON_START] == GLFW_PRESS) {
|
||||
glfwSetWindowShouldClose(window, GLFW_TRUE);
|
||||
}
|
||||
}
|
||||
PD::Gfx::SetViewPort(1280, 720);
|
||||
glClearColor(0.1, 0.1, 0.1, 0.1);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glViewport(0, 0, 1280, 720);
|
||||
#else
|
||||
while (!glfwWindowShouldClose(window)) {
|
||||
int ww, wh;
|
||||
@@ -159,7 +199,7 @@ class App {
|
||||
PD::Gfx::Reset();
|
||||
|
||||
PD::Gfx::Draw(pList);
|
||||
#ifdef __3DS__
|
||||
#if defined(__3DS__)
|
||||
C3D_FrameEnd(0);
|
||||
#else
|
||||
glfwPollEvents();
|
||||
@@ -178,7 +218,7 @@ class App {
|
||||
}
|
||||
|
||||
private:
|
||||
#ifdef __3DS__
|
||||
#if defined(__3DS__)
|
||||
C3D_RenderTarget* Top = nullptr;
|
||||
C3D_RenderTarget* Bottom = nullptr;
|
||||
#else
|
||||
@@ -194,6 +234,13 @@ class App {
|
||||
};
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
#if defined(__SWITCH__)
|
||||
socketInitializeDefault();
|
||||
nxlinkStdio();
|
||||
romfsInit();
|
||||
printf("Starting Palladium GFX Tests...\n");
|
||||
glfwSetErrorCallback(errorCallback);
|
||||
#endif
|
||||
Driver drv = Driver::OpenGL3;
|
||||
if (argc == 2) {
|
||||
if (std::string(argv[1]) == "gl2") {
|
||||
@@ -204,7 +251,8 @@ int main(int argc, char** argv) {
|
||||
drv = Driver::DirectX9;
|
||||
}
|
||||
}
|
||||
App app(drv);
|
||||
app.Run();
|
||||
App* app = new App(drv);
|
||||
app->Run();
|
||||
delete app;
|
||||
return 0;
|
||||
}
|
||||
Vendored
+14
-11
@@ -1,22 +1,25 @@
|
||||
cmake_minimum_required(VERSION 3.22)
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Nintendo3DS")
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/libpicasso)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/libpicasso)
|
||||
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "NintendoSwitch")
|
||||
# SPIRV-Helper
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/spirv-helper)
|
||||
else()
|
||||
# GLAD
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/glad)
|
||||
# SPIRV-Helper
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/spirv-helper)
|
||||
# GLAD
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/glad)
|
||||
# SPIRV-Helper
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/spirv-helper)
|
||||
endif()
|
||||
|
||||
# STB
|
||||
add_library(stb INTERFACE)
|
||||
target_include_directories(stb INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/stb)
|
||||
|
||||
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Nintendo3DS")
|
||||
# GLFW
|
||||
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "")
|
||||
set(GLFW_BUILD_TESTS OFF CACHE BOOL "")
|
||||
set(GLFW_BUILD_DOCS OFF CACHE BOOL "")
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/glfw)
|
||||
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Nintendo3DS" AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL "NintendoSwitch")
|
||||
# GLFW
|
||||
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "")
|
||||
set(GLFW_BUILD_TESTS OFF CACHE BOOL "")
|
||||
set(GLFW_BUILD_DOCS OFF CACHE BOOL "")
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/glfw)
|
||||
endif()
|
||||
|
||||
Vendored
+1
-1
Submodule vendor/spirv-helper updated: e05a0a45c2...91f57a5101
Reference in New Issue
Block a user