Skip to content
Open
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
44 changes: 44 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: CD

on:
push:
tags:
- 'v*'
workflow_dispatch:

defaults:
run:
shell: bash

# required for upload
permissions:
contents: write

jobs:

Linux:
runs-on: ${{ matrix.runner }}
strategy:
matrix:
runner: [ ubuntu-24.04, ubuntu-24.04-arm ]
steps:
- uses: actions/checkout@v4

- name: Install dependencies
run: sudo apt update -y && sudo apt install -y libsdl2-dev libglew-dev libpng-dev zip

- name: Build
run: |
make -f Makefile.linux libprism.a
ARCH=`uname -m`
cd bin && zip -9 -r ../libprism-linux-${ARCH} libprism.a


- name: Create GitHub Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: |
*.zip
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ build/*
*.iobj
*.cache
*.psd
*.a

bin/*
bin/*
24 changes: 24 additions & 0 deletions Makefile.linux
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
include Makefile.common

OBJS += linux/drawing_linux.o linux/texture_linux.o linux/input_linux.o \
linux/framerateselect_linux.o linux/file_linux.o linux/math_linux.o linux/system_linux.o linux/log_linux.o \
linux/soundeffect_linux.o linux/sound_linux.o linux/memoryhandler_linux.o web/netplay_web.o linux/romdisk_linux.o \
linux/saveload_linux.o linux/screeneffect_linux.o linux/logoscreen_linux.o \
web/thread_web.o

CXXFLAGS += -DNDEBUG -I ./include -I ./external/imgui/inc `sdl2-config --cflags` -std=c++17 -O2

all: $(TARGET)

$(TARGET): $(OBJS)
$(AR) -rc $@ $^

%.o : %.cpp
$(CC) -c $(CXXFLAGS) -o $@ $<

%.o : %.c
$(CC) -c -o $@ $<

clean:
-rm -f *.o
-rm -rf linux/*.o
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Prism - Library for Dreamcast / Windows game development
[![CD](https://github.com/humbertodias/prism/actions/workflows/cd.yml/badge.svg)](https://github.com/humbertodias/prism/actions/workflows/cd.yml)

A loose collection of components that are often used in games (e.g.: physics, collisions, animations, etc.). The Dreamcast part requires KallistiOS, the Windows part requires SDL.
# Prism - Library for Dreamcast / Windows / Linux game development

A loose collection of components that are often used in games (e.g.: physics, collisions, animations, etc.). The Dreamcast part requires KallistiOS, the Windows/Linux part requires SDL2.

## Dreamcast Usage
Clone in your `$(KOS_ROOT)/addons` folder and compile this library with `make`.
Expand Down
1 change: 1 addition & 0 deletions include/prism/datastructures.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <string>
#include <vector>
#include <cstdint>

namespace prism {

Expand Down
2 changes: 1 addition & 1 deletion include/prism/file.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace prism {

typedef int FileHandler;

#elif defined _WIN32 || defined __EMSCRIPTEN__ || defined VITA
#elif defined _WIN32 || defined __EMSCRIPTEN__ || defined VITA || defined __linux__

#define O_RDONLY 0x1
#define O_WRONLY 0x2
Expand Down
4 changes: 2 additions & 2 deletions include/prism/memoryhandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
namespace prism {
typedef pvr_ptr_t Texture;

#elif defined _WIN32 || defined __EMSCRIPTEN__
#elif defined _WIN32 || defined __EMSCRIPTEN__ || defined __linux__
#include <SDL.h>
#include <GL/glew.h>

Expand Down Expand Up @@ -81,7 +81,7 @@ int getAvailableSoundMemory();

int getAllocatedMemoryBlockAmount();

#ifdef _WIN32
#if defined(_WIN32) || defined(__linux__)
void imguiMemoryHandler();
void imguiTextureMemory(const std::string_view& tName, const TextureMemory& tTextureMemory);
#endif
Expand Down
1 change: 1 addition & 0 deletions include/prism/memorypool.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <stdlib.h>
#include <stdbool.h>
#include <inttypes.h>
#include <stdint.h>

namespace prism {

Expand Down
1 change: 1 addition & 0 deletions include/prism/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ double getInverseFramerateFactor();
void setVGA();
int isOnDreamcast();
int isOnWindows();
int isOnLinux();
int isOnWeb();
int isOnVita();

Expand Down
112 changes: 112 additions & 0 deletions linux/debugimgui_linux.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
#include "prism/windows/debugimgui_win.h"

#include <imgui/imgui.h>
#include <imgui/imgui_impl_opengl3.h>
#include <imgui/imgui_impl_sdl2.h>
#include <GL/glew.h>

#include <prism/debug.h>

namespace prism {

extern SDL_Window* gSDLWindow;
extern SDL_GLContext gGLContext;

static struct {
bool mIsActive;

} gImguiPrismData;

bool isImguiPrismActive()
{
return gImguiPrismData.mIsActive;
}

void imguiPrismInitAfterDrawingSetup()
{
// Setup Dear ImGui context
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO(); (void)io;
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls

// Setup Dear ImGui style
ImGui::StyleColorsDark();

// Setup Platform/Renderer backends
ImGui_ImplSDL2_InitForOpenGL(gSDLWindow, gGLContext);
ImGui_ImplOpenGL3_Init();

gImguiPrismData.mIsActive = isInDevelopMode();
gImguiPrismData.mIsActive = false;
}

void imguiPrismProcessEvent(SDL_Event* tEvent)
{
ImGui_ImplSDL2_ProcessEvent(tEvent);
}

static bool testWindow = false;

void imguiPrismStartFrame()
{
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplSDL2_NewFrame();
ImGui::NewFrame();
}


void imguiPrismRenderStart()
{
ImGuiIO& io = ImGui::GetIO(); (void)io;

if (ImGui::BeginMainMenuBar())
{
if (ImGui::BeginMenu("Prism"))
{
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Screen"))
{
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Blitz"))
{
ImGui::EndMenu();
}

ImGui::SameLine(ImGui::GetWindowWidth() - 140);
ImGui::Text("%.1f ms (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate);

ImGui::EndMainMenuBar();
}
}

void imguiPrismRenderEnd()
{

ImGui::Render();
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
}

void imguiPrismShutdown()
{
ImGui_ImplOpenGL3_Shutdown();
ImGui_ImplSDL2_Shutdown();
ImGui::DestroyContext();
}

void imguiPrismAddTab(const std::string_view& tTabName, const std::string_view& tEntryName, bool* tBool)
{
if (ImGui::BeginMainMenuBar())
{
if (ImGui::BeginMenu(tTabName.data()))
{
ImGui::MenuItem(tEntryName.data(), NULL, tBool);
ImGui::EndMenu();
}
ImGui::EndMainMenuBar();
}
}
}
Loading