Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5919881568 |
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@@ -106,7 +106,7 @@ jobs:
|
|||||||
- name: Copy output files.
|
- name: Copy output files.
|
||||||
run: |
|
run: |
|
||||||
mkdir -p ./git-artifcats/Dusk/apps/Dusk
|
mkdir -p ./git-artifcats/Dusk/apps/Dusk
|
||||||
cp build-wii/Dusk.dol ./git-artifcats/Dusk/apps/Dusk/boot.dol
|
cp build-wii/Dusk.dol ./git-artifcats/Dusk/apps/Dusk/Dusk.dol
|
||||||
cp build-wii/dusk.dsk ./git-artifcats/Dusk/apps/Dusk/dusk.dsk
|
cp build-wii/dusk.dsk ./git-artifcats/Dusk/apps/Dusk/dusk.dsk
|
||||||
cp docker/dolphin/meta.xml ./git-artifcats/Dusk/apps/Dusk/meta.xml
|
cp docker/dolphin/meta.xml ./git-artifcats/Dusk/apps/Dusk/meta.xml
|
||||||
- name: Upload Wii binary
|
- name: Upload Wii binary
|
||||||
|
|||||||
@@ -70,7 +70,6 @@ elseif LINUX then
|
|||||||
inputBind("mouse_x", INPUT_ACTION_POINTERX)
|
inputBind("mouse_x", INPUT_ACTION_POINTERX)
|
||||||
inputBind("mouse_y", INPUT_ACTION_POINTERY)
|
inputBind("mouse_y", INPUT_ACTION_POINTERY)
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
print("Unknown platform, no default input bindings set.")
|
print("Unknown platform, no default input bindings set.")
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ module('text')
|
|||||||
module('tileset')
|
module('tileset')
|
||||||
module('texture')
|
module('texture')
|
||||||
module('input')
|
module('input')
|
||||||
module('shader')
|
|
||||||
|
|
||||||
CELL_STATE_DEFAULT = 0
|
CELL_STATE_DEFAULT = 0
|
||||||
CELL_STATE_HOVER = 1
|
CELL_STATE_HOVER = 1
|
||||||
@@ -63,7 +62,7 @@ function cellDraw(x, y, type)
|
|||||||
slice = cellSliceDisabled
|
slice = cellSliceDisabled
|
||||||
end
|
end
|
||||||
|
|
||||||
spriteBatchPush(
|
spriteBatchPush(textureCell,
|
||||||
x, y,
|
x, y,
|
||||||
x + tilesetCell.tileWidth, y + tilesetCell.tileHeight,
|
x + tilesetCell.tileWidth, y + tilesetCell.tileHeight,
|
||||||
colorWhite(),
|
colorWhite(),
|
||||||
@@ -183,28 +182,18 @@ function sceneUpdate()
|
|||||||
y = y + inputAxis(INPUT_ACTION_UP, INPUT_ACTION_DOWN)
|
y = y + inputAxis(INPUT_ACTION_UP, INPUT_ACTION_DOWN)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function sceneRender()
|
function sceneRender()
|
||||||
-- Update camera
|
-- Update camera
|
||||||
camera.bottom = 0
|
cameraPushMatrix(camera)
|
||||||
camera.top = screenGetHeight()
|
camera.bottom = screenGetHeight()
|
||||||
camera.right = screenGetWidth()
|
camera.right = screenGetWidth()
|
||||||
|
|
||||||
shaderBind(SHADER_UNLIT)
|
|
||||||
proj = cameraGetProjectionMatrix(camera)
|
|
||||||
shaderSetMatrix(SHADER_UNLIT, SHADER_UNLIT_PROJECTION, proj)
|
|
||||||
view = cameraGetViewMatrix(camera)
|
|
||||||
shaderSetMatrix(SHADER_UNLIT, SHADER_UNLIT_VIEW, view)
|
|
||||||
|
|
||||||
shaderSetTexture(SHADER_UNLIT, SHADER_UNLIT_TEXTURE, nil)
|
|
||||||
spriteBatchPush(
|
spriteBatchPush(
|
||||||
x, y,
|
nil,
|
||||||
x + 32, y + 32,
|
x, y, x + 32, y + 32,
|
||||||
colorWhite()
|
colorWhite()
|
||||||
)
|
)
|
||||||
spriteBatchFlush()
|
|
||||||
|
|
||||||
textDraw(10, 10, "Hello World\nHow are you?", colorRed())
|
|
||||||
spriteBatchFlush()
|
|
||||||
|
|
||||||
-- Update mouse position
|
-- Update mouse position
|
||||||
-- if INPUT_POINTER then
|
-- if INPUT_POINTER then
|
||||||
@@ -261,4 +250,7 @@ function sceneRender()
|
|||||||
-- )
|
-- )
|
||||||
-- end
|
-- end
|
||||||
-- end
|
-- end
|
||||||
|
spriteBatchFlush()
|
||||||
|
|
||||||
|
cameraPopMatrix()
|
||||||
end
|
end
|
||||||
BIN
assets/ui/minogram.dpt
Normal file
BIN
assets/ui/minogram.dpt
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
17
cmake/modules/CompileLibZip.cmake
Normal file
17
cmake/modules/CompileLibZip.cmake
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
include(FetchContent)
|
||||||
|
|
||||||
|
set(ENABLE_ZSTD OFF CACHE BOOL "" FORCE)
|
||||||
|
set(BUILD_TOOLS OFF CACHE BOOL "" FORCE)
|
||||||
|
set(BUILD_REGRESS OFF CACHE BOOL "" FORCE)
|
||||||
|
set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
|
||||||
|
set(BUILD_DOC OFF CACHE BOOL "" FORCE)
|
||||||
|
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
|
||||||
|
set(LIBZIP_DO_INSTALL OFF CACHE BOOL "" FORCE)
|
||||||
|
|
||||||
|
FetchContent_Declare(
|
||||||
|
libzip
|
||||||
|
GIT_REPOSITORY https://github.com/nih-at/libzip.git
|
||||||
|
GIT_TAG v1.11.4
|
||||||
|
)
|
||||||
|
|
||||||
|
FetchContent_MakeAvailable(libzip)
|
||||||
20
cmake/modules/CompileLua.cmake
Normal file
20
cmake/modules/CompileLua.cmake
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
# Compile lua
|
||||||
|
include(FetchContent)
|
||||||
|
FetchContent_Declare(
|
||||||
|
liblua
|
||||||
|
URL https://www.lua.org/ftp/lua-5.5.0.tar.gz
|
||||||
|
)
|
||||||
|
FetchContent_MakeAvailable(liblua)
|
||||||
|
set(LUA_SRC_DIR "${liblua_SOURCE_DIR}/src")
|
||||||
|
set(LUA_C_FILES
|
||||||
|
lapi.c lauxlib.c lbaselib.c lcode.c lcorolib.c lctype.c ldblib.c ldebug.c
|
||||||
|
ldo.c ldump.c lfunc.c lgc.c linit.c liolib.c llex.c lmathlib.c lmem.c
|
||||||
|
loadlib.c lobject.c lopcodes.c loslib.c lparser.c lstate.c lstring.c
|
||||||
|
lstrlib.c ltable.c ltablib.c ltm.c lundump.c lutf8lib.c lvm.c lzio.c
|
||||||
|
)
|
||||||
|
list(TRANSFORM LUA_C_FILES PREPEND "${LUA_SRC_DIR}/")
|
||||||
|
add_library(liblua STATIC ${LUA_C_FILES})
|
||||||
|
target_include_directories(liblua PUBLIC "${LUA_SRC_DIR}")
|
||||||
|
target_compile_definitions(liblua PRIVATE LUA_USE_C89)
|
||||||
|
add_library(lua::lua ALIAS liblua)
|
||||||
|
set(Lua_FOUND TRUE CACHE BOOL "Lua found" FORCE)
|
||||||
@@ -1,17 +1,43 @@
|
|||||||
|
|
||||||
|
# Allow user to manually specify libzip paths
|
||||||
|
# LIBZIP_ROOT: root directory for libzip (optional)
|
||||||
|
# LIBZIP_INCLUDE_DIR: path to zip.h (optional)
|
||||||
|
# LIBZIP_LIBRARY: path to libzip library (optional)
|
||||||
|
|
||||||
find_package(ZLIB REQUIRED)
|
find_package(ZLIB REQUIRED)
|
||||||
|
|
||||||
find_path(LIBZIP_INCLUDE_DIR NAMES zip.h)
|
if(NOT LIBZIP_INCLUDE_DIR AND LIBZIP_ROOT)
|
||||||
|
find_path(LIBZIP_INCLUDE_DIR NAMES zip.h HINTS "${LIBZIP_ROOT}/include")
|
||||||
|
endif()
|
||||||
|
if(NOT LIBZIP_INCLUDE_DIR)
|
||||||
|
find_path(LIBZIP_INCLUDE_DIR NAMES zip.h)
|
||||||
|
endif()
|
||||||
mark_as_advanced(LIBZIP_INCLUDE_DIR)
|
mark_as_advanced(LIBZIP_INCLUDE_DIR)
|
||||||
|
|
||||||
find_library(LIBZIP_LIBRARY NAMES zip)
|
if(NOT LIBZIP_LIBRARY AND LIBZIP_ROOT)
|
||||||
|
find_library(LIBZIP_LIBRARY NAMES zip HINTS "${LIBZIP_ROOT}/lib")
|
||||||
|
endif()
|
||||||
|
if(NOT LIBZIP_LIBRARY)
|
||||||
|
find_library(LIBZIP_LIBRARY NAMES zip)
|
||||||
|
endif()
|
||||||
mark_as_advanced(LIBZIP_LIBRARY)
|
mark_as_advanced(LIBZIP_LIBRARY)
|
||||||
|
|
||||||
get_filename_component(_libzip_libdir ${LIBZIP_LIBRARY} DIRECTORY)
|
if(LIBZIP_LIBRARY)
|
||||||
find_file(_libzip_pkgcfg libzip.pc
|
get_filename_component(_libzip_libdir ${LIBZIP_LIBRARY} DIRECTORY)
|
||||||
HINTS ${_libzip_libdir} ${LIBZIP_INCLUDE_DIR}/..
|
endif()
|
||||||
PATH_SUFFIXES pkgconfig lib/pkgconfig libdata/pkgconfig
|
if(NOT _libzip_pkgcfg AND LIBZIP_ROOT)
|
||||||
NO_DEFAULT_PATH
|
find_file(_libzip_pkgcfg libzip.pc
|
||||||
)
|
HINTS "${LIBZIP_ROOT}/lib/pkgconfig" "${LIBZIP_ROOT}/libdata/pkgconfig"
|
||||||
|
NO_DEFAULT_PATH
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
if(NOT _libzip_pkgcfg AND LIBZIP_LIBRARY)
|
||||||
|
find_file(_libzip_pkgcfg libzip.pc
|
||||||
|
HINTS ${_libzip_libdir} ${LIBZIP_INCLUDE_DIR}/..
|
||||||
|
PATH_SUFFIXES pkgconfig lib/pkgconfig libdata/pkgconfig
|
||||||
|
NO_DEFAULT_PATH
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
include(FindPackageHandleStandardArgs)
|
||||||
find_package_handle_standard_args(
|
find_package_handle_standard_args(
|
||||||
|
|||||||
@@ -21,26 +21,7 @@ set(CGLM_SHARED OFF CACHE BOOL "Build cglm shared" FORCE)
|
|||||||
set(CGLM_STATIC ON CACHE BOOL "Build cglm static" FORCE)
|
set(CGLM_STATIC ON CACHE BOOL "Build cglm static" FORCE)
|
||||||
find_package(cglm REQUIRED)
|
find_package(cglm REQUIRED)
|
||||||
|
|
||||||
# Compile lua
|
include(cmake/modules/CompileLua.cmake)
|
||||||
include(FetchContent)
|
|
||||||
FetchContent_Declare(
|
|
||||||
liblua
|
|
||||||
URL https://www.lua.org/ftp/lua-5.5.0.tar.gz
|
|
||||||
)
|
|
||||||
FetchContent_MakeAvailable(liblua)
|
|
||||||
set(LUA_SRC_DIR "${liblua_SOURCE_DIR}/src")
|
|
||||||
set(LUA_C_FILES
|
|
||||||
lapi.c lauxlib.c lbaselib.c lcode.c lcorolib.c lctype.c ldblib.c ldebug.c
|
|
||||||
ldo.c ldump.c lfunc.c lgc.c linit.c liolib.c llex.c lmathlib.c lmem.c
|
|
||||||
loadlib.c lobject.c lopcodes.c loslib.c lparser.c lstate.c lstring.c
|
|
||||||
lstrlib.c ltable.c ltablib.c ltm.c lundump.c lutf8lib.c lvm.c lzio.c
|
|
||||||
)
|
|
||||||
list(TRANSFORM LUA_C_FILES PREPEND "${LUA_SRC_DIR}/")
|
|
||||||
add_library(liblua STATIC ${LUA_C_FILES})
|
|
||||||
target_include_directories(liblua PUBLIC "${LUA_SRC_DIR}")
|
|
||||||
target_compile_definitions(liblua PRIVATE LUA_USE_C89)
|
|
||||||
add_library(lua::lua ALIAS liblua)
|
|
||||||
set(Lua_FOUND TRUE CACHE BOOL "Lua found" FORCE)
|
|
||||||
|
|
||||||
# Link libraries
|
# Link libraries
|
||||||
target_link_libraries(${DUSK_LIBRARY_TARGET_NAME} PRIVATE
|
target_link_libraries(${DUSK_LIBRARY_TARGET_NAME} PRIVATE
|
||||||
|
|||||||
62
cmake/targets/vita.cmake
Normal file
62
cmake/targets/vita.cmake
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
include("${VITASDK}/share/vita.cmake" REQUIRED)
|
||||||
|
|
||||||
|
|
||||||
|
# Manually define libzip for Vita
|
||||||
|
set(LIBZIP_LIBRARY "${VITASDK}/lib/libzip.a" CACHE FILEPATH "libzip library for Vita")
|
||||||
|
set(LIBZIP_INCLUDE_DIR "${VITASDK}/include" CACHE PATH "libzip include dir for Vita")
|
||||||
|
|
||||||
|
set(VITA_APP_NAME "Red Rectangle")
|
||||||
|
set(VITA_TITLEID "VSDK00017")
|
||||||
|
set(VITA_VERSION "01.00")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
target_link_libraries(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
||||||
|
mathneon
|
||||||
|
vitashark
|
||||||
|
kubridge_stub
|
||||||
|
SceAppMgr_stub
|
||||||
|
SceAudio_stub
|
||||||
|
SceCtrl_stub
|
||||||
|
SceCommonDialog_stub
|
||||||
|
SceDisplay_stub
|
||||||
|
SceKernelDmacMgr_stub
|
||||||
|
SceGxm_stub
|
||||||
|
SceShaccCg_stub
|
||||||
|
SceSysmodule_stub
|
||||||
|
ScePower_stub
|
||||||
|
SceTouch_stub
|
||||||
|
SceVshBridge_stub
|
||||||
|
SceIofilemgr_stub
|
||||||
|
SceShaccCgExt
|
||||||
|
SDL2-static
|
||||||
|
libtaihen_stub.a
|
||||||
|
lua::lua
|
||||||
|
zip
|
||||||
|
pthread
|
||||||
|
m
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(${DUSK_LIBRARY_TARGET_NAME} PRIVATE
|
||||||
|
${SDL2_INCLUDE_DIRS}
|
||||||
|
)
|
||||||
|
|
||||||
|
target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
||||||
|
DUSK_SDL2
|
||||||
|
DUSK_OPENGL
|
||||||
|
DUSK_VITA
|
||||||
|
DUSK_INPUT_GAMEPAD
|
||||||
|
DUSK_PLATFORM_ENDIAN_LITTLE
|
||||||
|
DUSK_DISPLAY_WIDTH=960
|
||||||
|
DUSK_DISPLAY_HEIGHT=544
|
||||||
|
)
|
||||||
|
|
||||||
|
vita_create_self(${DUSK_BINARY_TARGET_NAME}.self ${DUSK_BINARY_TARGET_NAME})
|
||||||
|
vita_create_vpk(${DUSK_BINARY_TARGET_NAME}.vpk ${VITA_TITLEID} ${DUSK_BINARY_TARGET_NAME}.self
|
||||||
|
VERSION ${VITA_VERSION}
|
||||||
|
NAME ${VITA_APP_NAME}
|
||||||
|
# FILE sce_sys/icon0.png sce_sys/icon0.png
|
||||||
|
# FILE sce_sys/livearea/contents/bg.png sce_sys/livearea/contents/bg.png
|
||||||
|
# FILE sce_sys/livearea/contents/startup.png sce_sys/livearea/contents/startup.png
|
||||||
|
# FILE sce_sys/livearea/contents/template.xml sce_sys/livearea/contents/template.xml
|
||||||
|
)
|
||||||
64
docker/vita/Dockerfile
Normal file
64
docker/vita/Dockerfile
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
FROM ubuntu:22.04
|
||||||
|
|
||||||
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install -y \
|
||||||
|
cmake \
|
||||||
|
git \
|
||||||
|
curl \
|
||||||
|
sudo \
|
||||||
|
wget \
|
||||||
|
libarchive-tools \
|
||||||
|
python3 \
|
||||||
|
python3-pip \
|
||||||
|
python3-dotenv \
|
||||||
|
python3-polib \
|
||||||
|
python3-pil \
|
||||||
|
python3-pyqt5 \
|
||||||
|
python3-opengl \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
RUN git clone https://github.com/vitasdk/vdpm /vdpm
|
||||||
|
WORKDIR /vdpm
|
||||||
|
RUN ./bootstrap-vitasdk.sh
|
||||||
|
|
||||||
|
ENV VITASDK=/usr/local/vitasdk
|
||||||
|
ENV PATH="${VITASDK}/bin:${PATH}"
|
||||||
|
|
||||||
|
RUN git clone https://github.com/vitasdk/packages.git /vitapackages
|
||||||
|
WORKDIR /vitapackages
|
||||||
|
|
||||||
|
RUN bash -lc '\
|
||||||
|
dir_array=( \
|
||||||
|
zlib \
|
||||||
|
bzip2 \
|
||||||
|
henkaku \
|
||||||
|
taihen \
|
||||||
|
kubridge \
|
||||||
|
openal-soft \
|
||||||
|
openssl \
|
||||||
|
curl \
|
||||||
|
curlpp \
|
||||||
|
expat \
|
||||||
|
opus \
|
||||||
|
opusfile \
|
||||||
|
glm \
|
||||||
|
kuio \
|
||||||
|
vitaShaRK \
|
||||||
|
libmathneon \
|
||||||
|
vitaGL \
|
||||||
|
SceShaccCgExt \
|
||||||
|
sdl2 \
|
||||||
|
libzip \
|
||||||
|
luajit \
|
||||||
|
); \
|
||||||
|
curdir=$(pwd); \
|
||||||
|
for d in "${dir_array[@]}"; do \
|
||||||
|
echo "${curdir}/${d}"; \
|
||||||
|
cd "${curdir}/${d}"; \
|
||||||
|
vita-makepkg; \
|
||||||
|
vdpm *-arm.tar.xz; \
|
||||||
|
done \
|
||||||
|
'
|
||||||
|
|
||||||
|
WORKDIR /workdir
|
||||||
41
editor/.gitignore
vendored
41
editor/.gitignore
vendored
@@ -1,41 +0,0 @@
|
|||||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
|
||||||
|
|
||||||
# dependencies
|
|
||||||
/node_modules
|
|
||||||
/.pnp
|
|
||||||
.pnp.*
|
|
||||||
.yarn/*
|
|
||||||
!.yarn/patches
|
|
||||||
!.yarn/plugins
|
|
||||||
!.yarn/releases
|
|
||||||
!.yarn/versions
|
|
||||||
|
|
||||||
# testing
|
|
||||||
/coverage
|
|
||||||
|
|
||||||
# next.js
|
|
||||||
/.next/
|
|
||||||
/out/
|
|
||||||
|
|
||||||
# production
|
|
||||||
/build
|
|
||||||
|
|
||||||
# misc
|
|
||||||
.DS_Store
|
|
||||||
*.pem
|
|
||||||
|
|
||||||
# debug
|
|
||||||
npm-debug.log*
|
|
||||||
yarn-debug.log*
|
|
||||||
yarn-error.log*
|
|
||||||
.pnpm-debug.log*
|
|
||||||
|
|
||||||
# env files (can opt-in for committing if needed)
|
|
||||||
.env*
|
|
||||||
|
|
||||||
# vercel
|
|
||||||
.vercel
|
|
||||||
|
|
||||||
# typescript
|
|
||||||
*.tsbuildinfo
|
|
||||||
next-env.d.ts
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
import type { NextConfig } from "next";
|
|
||||||
|
|
||||||
const nextConfig: NextConfig = {
|
|
||||||
/* config options here */
|
|
||||||
reactCompiler: true,
|
|
||||||
};
|
|
||||||
|
|
||||||
export default nextConfig;
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "dusk-editor",
|
|
||||||
"version": "0.1.0",
|
|
||||||
"private": true,
|
|
||||||
"scripts": {
|
|
||||||
"start:dev": "next dev",
|
|
||||||
"build:prod": "next build",
|
|
||||||
"start:prod": "next start"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"next": "16.2.1",
|
|
||||||
"react": "19.2.4",
|
|
||||||
"react-dom": "19.2.4",
|
|
||||||
"sass": "^1.98.0"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@types/node": "^20",
|
|
||||||
"@types/react": "^19",
|
|
||||||
"@types/react-dom": "^19",
|
|
||||||
"babel-plugin-react-compiler": "1.0.0",
|
|
||||||
"typescript": "^5"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
import type { Metadata } from "next";
|
|
||||||
import "@/styles/styles.scss";
|
|
||||||
import Navbar from "@/components/Navbar/Navbar";
|
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
|
||||||
title: "Dusk Editor",
|
|
||||||
description: "Editor for the Dusk Game Engine",
|
|
||||||
};
|
|
||||||
|
|
||||||
export default function RootLayout({
|
|
||||||
children,
|
|
||||||
}: Readonly<{
|
|
||||||
children: React.ReactNode;
|
|
||||||
}>) {
|
|
||||||
return (
|
|
||||||
<html lang="en">
|
|
||||||
<body>
|
|
||||||
<Navbar />
|
|
||||||
{children}
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
import Link from "next/link";
|
|
||||||
|
|
||||||
export default function Home() {
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<Link href="/texture-creator">Go to Texture Creator</Link>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
'use client';
|
|
||||||
import React, { createContext, useContext, useState } from "react";
|
|
||||||
|
|
||||||
type TexturePageContextType = {
|
|
||||||
};
|
|
||||||
|
|
||||||
const TexturePageContext = createContext<TexturePageContextType | undefined>(undefined);
|
|
||||||
|
|
||||||
const TextureCreatorPage: React.FC<{ children: React.ReactNode }> = (props) => {
|
|
||||||
return (
|
|
||||||
<TexturePageContext.Provider value={{ }}>
|
|
||||||
<Typography</Typography>
|
|
||||||
</TexturePageContext.Provider>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default TextureCreatorPage;
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import * as styles from './Navbar.module.scss';
|
|
||||||
|
|
||||||
const Navbar:React.FC<{}> = (props) => {
|
|
||||||
return (
|
|
||||||
<nav className={styles.navbar}>
|
|
||||||
navbar
|
|
||||||
</nav>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default Navbar;
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
|
|
||||||
const Typography:React.FC<{
|
|
||||||
element?:string|React.JSXElementConstructor<any>;
|
|
||||||
}> = (props) => {
|
|
||||||
const Element = props.element || 'p';
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Element>
|
|
||||||
{props.children}
|
|
||||||
</Element>
|
|
||||||
)
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Typography;
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
|
|
||||||
import React, { createContext, useContext, useState } from "react";
|
|
||||||
|
|
||||||
type TextureContextType = {
|
|
||||||
};
|
|
||||||
|
|
||||||
const TextureContext = createContext<TextureContextType | undefined>(undefined);
|
|
||||||
|
|
||||||
const TextureCreator: React.FC<{ children: React.ReactNode }> = (props) => {
|
|
||||||
return (
|
|
||||||
<TextureContext.Provider value={{ }}>
|
|
||||||
{props.children}
|
|
||||||
</TextureContext.Provider>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default TextureCreator;
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
a {
|
|
||||||
color: inherit;
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
* {
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
body {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
max-width: 100vw;
|
|
||||||
overflow-x: hidden;
|
|
||||||
font-size: 16px;
|
|
||||||
font-family: Arial, Helvetica, sans-serif;
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
html {
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
max-width: 100vw;
|
|
||||||
overflow-x: hidden;
|
|
||||||
}
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
:root {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
// Elements
|
|
||||||
@use './elements/root.scss';
|
|
||||||
@use './elements/all.scss';
|
|
||||||
@use './elements/a.scss';
|
|
||||||
@use './elements/html.scss';
|
|
||||||
@use './elements/body.scss';
|
|
||||||
|
|
||||||
// Objects
|
|
||||||
|
|
||||||
// Components
|
|
||||||
|
|
||||||
// Utilities
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"target": "ES2017",
|
|
||||||
"lib": ["dom", "dom.iterable", "esnext"],
|
|
||||||
"allowJs": true,
|
|
||||||
"skipLibCheck": true,
|
|
||||||
"strict": true,
|
|
||||||
"noEmit": true,
|
|
||||||
"esModuleInterop": true,
|
|
||||||
"module": "esnext",
|
|
||||||
"moduleResolution": "bundler",
|
|
||||||
"resolveJsonModule": true,
|
|
||||||
"isolatedModules": true,
|
|
||||||
"jsx": "react-jsx",
|
|
||||||
"incremental": true,
|
|
||||||
"plugins": [
|
|
||||||
{
|
|
||||||
"name": "next"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"paths": {
|
|
||||||
"@/*": ["./src/*"]
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"include": [
|
|
||||||
"next-env.d.ts",
|
|
||||||
"**/*.ts",
|
|
||||||
"**/*.tsx",
|
|
||||||
".next/types/**/*.ts",
|
|
||||||
".next/dev/types/**/*.ts",
|
|
||||||
"**/*.mts"
|
|
||||||
],
|
|
||||||
"exclude": ["node_modules"]
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
cmake -S . -B build-knulli -G Ninja \
|
cmake -S . -B build-knulli -G Ninja \
|
||||||
-DDUSK_BUILD_TESTS=ON \
|
|
||||||
-DDUSK_TARGET_SYSTEM=knulli \
|
-DDUSK_TARGET_SYSTEM=knulli \
|
||||||
-DCMAKE_TOOLCHAIN_FILE=./cmake/toolchains/aarch64-linux-gnu.cmake \
|
-DCMAKE_TOOLCHAIN_FILE=./cmake/toolchains/aarch64-linux-gnu.cmake \
|
||||||
-DCMAKE_BUILD_TYPE=Release
|
-DCMAKE_BUILD_TYPE=Release
|
||||||
|
|||||||
3
scripts/build-vita-docker.sh
Executable file
3
scripts/build-vita-docker.sh
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
docker build -t dusk-vita -f docker/vita/Dockerfile .
|
||||||
|
docker run --rm -v $(pwd):/workdir dusk-vita /bin/bash -c "./scripts/build-vita.sh"
|
||||||
6
scripts/build-vita.sh
Executable file
6
scripts/build-vita.sh
Executable file
@@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
cd /workdir
|
||||||
|
cmake -S . -B build-vita \
|
||||||
|
-DDUSK_TARGET_SYSTEM=vita \
|
||||||
|
-DCMAKE_TOOLCHAIN_FILE="$VITASDK/share/vita.toolchain.cmake"
|
||||||
|
cmake --build build-vita -- -j$(nproc)
|
||||||
@@ -4,9 +4,8 @@
|
|||||||
# https://opensource.org/licenses/MIT
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
add_subdirectory(dusk)
|
add_subdirectory(dusk)
|
||||||
add_subdirectory(duskrpg)
|
|
||||||
|
|
||||||
if(DUSK_TARGET_SYSTEM STREQUAL "linux" OR DUSK_TARGET_SYSTEM STREQUAL "knulli")
|
if(DUSK_TARGET_SYSTEM STREQUAL "linux" OR DUSK_TARGET_SYSTEM STREQUAL "knulli" OR DUSK_TARGET_SYSTEM STREQUAL "vita")
|
||||||
add_subdirectory(dusklinux)
|
add_subdirectory(dusklinux)
|
||||||
add_subdirectory(dusksdl2)
|
add_subdirectory(dusksdl2)
|
||||||
add_subdirectory(duskgl)
|
add_subdirectory(duskgl)
|
||||||
|
|||||||
@@ -40,6 +40,9 @@ target_sources(${DUSK_BINARY_TARGET_NAME}
|
|||||||
main.c
|
main.c
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Defs
|
||||||
|
dusk_env_to_h(duskdefs.env duskdefs.h)
|
||||||
|
|
||||||
# Subdirs
|
# Subdirs
|
||||||
add_subdirectory(assert)
|
add_subdirectory(assert)
|
||||||
add_subdirectory(asset)
|
add_subdirectory(asset)
|
||||||
@@ -49,9 +52,12 @@ add_subdirectory(engine)
|
|||||||
add_subdirectory(error)
|
add_subdirectory(error)
|
||||||
add_subdirectory(event)
|
add_subdirectory(event)
|
||||||
add_subdirectory(input)
|
add_subdirectory(input)
|
||||||
|
add_subdirectory(item)
|
||||||
add_subdirectory(locale)
|
add_subdirectory(locale)
|
||||||
|
add_subdirectory(map)
|
||||||
add_subdirectory(scene)
|
add_subdirectory(scene)
|
||||||
add_subdirectory(script)
|
add_subdirectory(script)
|
||||||
|
add_subdirectory(story)
|
||||||
add_subdirectory(time)
|
add_subdirectory(time)
|
||||||
add_subdirectory(ui)
|
add_subdirectory(ui)
|
||||||
add_subdirectory(util)
|
add_subdirectory(util)
|
||||||
|
|||||||
@@ -19,9 +19,12 @@ typedef enum {
|
|||||||
ASSET_TYPE_NULL,
|
ASSET_TYPE_NULL,
|
||||||
|
|
||||||
ASSET_TYPE_TEXTURE,
|
ASSET_TYPE_TEXTURE,
|
||||||
|
// ASSET_TYPE_PALETTE,
|
||||||
ASSET_TYPE_TILESET,
|
ASSET_TYPE_TILESET,
|
||||||
ASSET_TYPE_LANGUAGE,
|
ASSET_TYPE_LANGUAGE,
|
||||||
ASSET_TYPE_SCRIPT,
|
ASSET_TYPE_SCRIPT,
|
||||||
|
ASSET_TYPE_MAP,
|
||||||
|
ASSET_TYPE_MAP_CHUNK,
|
||||||
|
|
||||||
ASSET_TYPE_COUNT,
|
ASSET_TYPE_COUNT,
|
||||||
} assettype_t;
|
} assettype_t;
|
||||||
@@ -57,14 +60,21 @@ static const assettypedef_t ASSET_TYPE_DEFINITIONS[ASSET_TYPE_COUNT] = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
[ASSET_TYPE_TEXTURE] = {
|
[ASSET_TYPE_TEXTURE] = {
|
||||||
.extension = "DTX",
|
.extension = "dpt",
|
||||||
.loadStrategy = ASSET_LOAD_STRAT_ENTIRE,
|
.loadStrategy = ASSET_LOAD_STRAT_ENTIRE,
|
||||||
.dataSize = sizeof(assettexture_t),
|
.dataSize = sizeof(assettexture_t),
|
||||||
.entire = assetTextureLoad
|
.entire = assetTextureLoad
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// [ASSET_TYPE_PALETTE] = {
|
||||||
|
// .extension = "dpf",
|
||||||
|
// .loadStrategy = ASSET_LOAD_STRAT_ENTIRE,
|
||||||
|
// .dataSize = sizeof(palette_t),
|
||||||
|
// .entire = assetPaletteLoad
|
||||||
|
// },
|
||||||
|
|
||||||
[ASSET_TYPE_TILESET] = {
|
[ASSET_TYPE_TILESET] = {
|
||||||
.extension = "DTF",
|
.extension = "dtf",
|
||||||
.loadStrategy = ASSET_LOAD_STRAT_ENTIRE,
|
.loadStrategy = ASSET_LOAD_STRAT_ENTIRE,
|
||||||
.dataSize = sizeof(assettileset_t),
|
.dataSize = sizeof(assettileset_t),
|
||||||
.entire = assetTilesetLoad
|
.entire = assetTilesetLoad
|
||||||
@@ -81,4 +91,16 @@ static const assettypedef_t ASSET_TYPE_DEFINITIONS[ASSET_TYPE_COUNT] = {
|
|||||||
.loadStrategy = ASSET_LOAD_STRAT_CUSTOM,
|
.loadStrategy = ASSET_LOAD_STRAT_CUSTOM,
|
||||||
.custom = assetScriptHandler
|
.custom = assetScriptHandler
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// [ASSET_TYPE_MAP] = {
|
||||||
|
// .extension = "DMF",
|
||||||
|
// .loadStrategy = ASSET_LOAD_STRAT_CUSTOM,
|
||||||
|
// .custom = assetMapHandler
|
||||||
|
// },
|
||||||
|
|
||||||
|
// [ASSET_TYPE_MAP_CHUNK] = {
|
||||||
|
// .extension = "DMC",
|
||||||
|
// .loadStrategy = ASSET_LOAD_STRAT_CUSTOM,
|
||||||
|
// .custom = assetMapChunkHandler
|
||||||
|
// },
|
||||||
};
|
};
|
||||||
@@ -12,67 +12,50 @@
|
|||||||
#include "util/endian.h"
|
#include "util/endian.h"
|
||||||
|
|
||||||
errorret_t assetTextureLoad(assetentire_t entire) {
|
errorret_t assetTextureLoad(assetentire_t entire) {
|
||||||
assertNotNull(entire.data, "Data pointer cannot be NULL.");
|
// assertNotNull(entire.data, "Data pointer cannot be NULL.");
|
||||||
assertNotNull(entire.output, "Output pointer cannot be NULL.");
|
// assertNotNull(entire.output, "Output pointer cannot be NULL.");
|
||||||
|
|
||||||
assettexture_t *assetData = (assettexture_t *)entire.data;
|
// assettexture_t *assetData = (assettexture_t *)entire.data;
|
||||||
texture_t *texture = (texture_t *)entire.output;
|
// texture_t *texture = (texture_t *)entire.output;
|
||||||
|
|
||||||
// Read header and version (first 4 bytes)
|
// // Read header and version (first 4 bytes)
|
||||||
if(
|
// if(
|
||||||
assetData->header[0] != 'D' ||
|
// assetData->header[0] != 'D' ||
|
||||||
assetData->header[1] != 'T' ||
|
// assetData->header[1] != 'P' ||
|
||||||
assetData->header[2] != 'X'
|
// assetData->header[2] != 'T'
|
||||||
) {
|
// ) {
|
||||||
errorThrow("Invalid texture header");
|
// errorThrow("Invalid texture header");
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Version (can only be 1 atm)
|
// // Version (can only be 1 atm)
|
||||||
if(assetData->version != 0x01) {
|
// if(assetData->version != 0x01) {
|
||||||
errorThrow("Unsupported texture version");
|
// errorThrow("Unsupported texture version");
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Fix endian
|
// // Fix endian
|
||||||
assetData->width = endianLittleToHost32(assetData->width);
|
// assetData->width = endianLittleToHost32(assetData->width);
|
||||||
assetData->height = endianLittleToHost32(assetData->height);
|
// assetData->height = endianLittleToHost32(assetData->height);
|
||||||
|
|
||||||
// Check dimensions.
|
// // Check dimensions.
|
||||||
if(
|
// if(
|
||||||
assetData->width == 0 || assetData->width > ASSET_TEXTURE_WIDTH_MAX ||
|
// assetData->width == 0 || assetData->width > ASSET_TEXTURE_WIDTH_MAX ||
|
||||||
assetData->height == 0 || assetData->height > ASSET_TEXTURE_HEIGHT_MAX
|
// assetData->height == 0 || assetData->height > ASSET_TEXTURE_HEIGHT_MAX
|
||||||
) {
|
// ) {
|
||||||
errorThrow("Invalid texture dimensions");
|
// errorThrow("Invalid texture dimensions");
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Validate format
|
// textureInit(
|
||||||
textureformat_t format;
|
// texture,
|
||||||
texturedata_t data;
|
// assetData->width,
|
||||||
|
// assetData->height,
|
||||||
|
// TEXTURE_FORMAT_PALETTE,
|
||||||
|
// (texturedata_t){
|
||||||
|
// .paletted = {
|
||||||
|
// .indices = NULL,
|
||||||
|
// .palette = NULL
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
|
||||||
switch(assetData->type) {
|
// errorOk();
|
||||||
case 0x00: // RGBA8888
|
|
||||||
format = TEXTURE_FORMAT_RGBA;
|
|
||||||
data.rgbaColors = (color_t *)assetData->data;
|
|
||||||
break;
|
|
||||||
|
|
||||||
// case 0x01:
|
|
||||||
// format = TEXTURE_FORMAT_RGB;
|
|
||||||
// break;
|
|
||||||
|
|
||||||
// case 0x02:
|
|
||||||
// format = TEXTURE_FORMAT_RGB565;
|
|
||||||
// break;
|
|
||||||
|
|
||||||
// case 0x03:
|
|
||||||
// format = TEXTURE_FORMAT_RGB5A3;
|
|
||||||
// break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
errorThrow("Unsupported texture format");
|
|
||||||
}
|
|
||||||
|
|
||||||
errorChain(textureInit(
|
|
||||||
texture, assetData->width, assetData->height, format, data
|
|
||||||
));
|
|
||||||
|
|
||||||
errorOk();
|
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "error/error.h"
|
#include "error/error.h"
|
||||||
#include "display/color.h"
|
|
||||||
|
|
||||||
#define ASSET_TEXTURE_WIDTH_MAX 2048
|
#define ASSET_TEXTURE_WIDTH_MAX 2048
|
||||||
#define ASSET_TEXTURE_HEIGHT_MAX 2048
|
#define ASSET_TEXTURE_HEIGHT_MAX 2048
|
||||||
@@ -21,10 +20,9 @@ typedef struct assetentire_s assetentire_t;
|
|||||||
typedef struct {
|
typedef struct {
|
||||||
char_t header[3];
|
char_t header[3];
|
||||||
uint8_t version;
|
uint8_t version;
|
||||||
uint8_t type;
|
|
||||||
uint32_t width;
|
uint32_t width;
|
||||||
uint32_t height;
|
uint32_t height;
|
||||||
uint8_t data[ASSET_TEXTURE_SIZE_MAX * sizeof(color4b_t)];
|
uint8_t palette[ASSET_TEXTURE_SIZE_MAX];
|
||||||
} assettexture_t;
|
} assettexture_t;
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ void cameraInitOrthographic(camera_t *camera) {
|
|||||||
camera->orthographic.right = SCREEN.width;
|
camera->orthographic.right = SCREEN.width;
|
||||||
camera->orthographic.top = 0.0f;
|
camera->orthographic.top = 0.0f;
|
||||||
camera->orthographic.bottom = SCREEN.height;
|
camera->orthographic.bottom = SCREEN.height;
|
||||||
camera->nearClip = 0.1f;
|
camera->nearClip = -1.0f;
|
||||||
camera->farClip = 1.0f;
|
camera->farClip = 1.0f;
|
||||||
|
|
||||||
camera->viewType = CAMERA_VIEW_TYPE_2D;
|
camera->viewType = CAMERA_VIEW_TYPE_2D;
|
||||||
@@ -84,7 +84,7 @@ void cameraGetViewMatrix(camera_t *camera, mat4 dest) {
|
|||||||
assertNotNull(dest, "Destination matrix must not be null");
|
assertNotNull(dest, "Destination matrix must not be null");
|
||||||
|
|
||||||
if(camera->viewType == CAMERA_VIEW_TYPE_MATRIX) {
|
if(camera->viewType == CAMERA_VIEW_TYPE_MATRIX) {
|
||||||
glm_mat4_ucopy(camera->view, dest);
|
glm_mat4_copy(camera->view, dest);
|
||||||
} else if(camera->viewType == CAMERA_VIEW_TYPE_LOOKAT) {
|
} else if(camera->viewType == CAMERA_VIEW_TYPE_LOOKAT) {
|
||||||
glm_mat4_identity(dest);
|
glm_mat4_identity(dest);
|
||||||
glm_lookat(
|
glm_lookat(
|
||||||
|
|||||||
@@ -21,3 +21,4 @@ lime,0.75,1,0,1
|
|||||||
navy,0,0,0.5,1
|
navy,0,0,0.5,1
|
||||||
teal,0,0.5,0.5,1
|
teal,0,0.5,0.5,1
|
||||||
cornflower_blue,0.39,0.58,0.93,1
|
cornflower_blue,0.39,0.58,0.93,1
|
||||||
|
salmon,1,0.5,0.5,1
|
||||||
|
@@ -20,27 +20,11 @@
|
|||||||
#include "display/shader/shaderunlit.h"
|
#include "display/shader/shaderunlit.h"
|
||||||
#include "time/time.h"
|
#include "time/time.h"
|
||||||
|
|
||||||
#include "script/module/display/moduleshader.h"
|
|
||||||
|
|
||||||
display_t DISPLAY = { 0 };
|
display_t DISPLAY = { 0 };
|
||||||
mesh_t mesh;
|
|
||||||
meshvertex_t vertices[3] = {
|
texture_t PALETTE_TEXTURE;
|
||||||
{
|
texture_t UNCOMPRESSED_TEXTURE;
|
||||||
.color = { 255, 0, 0, 255 },
|
texture_t COMPRESSED_TEXTURE;
|
||||||
.uv = { 0.0f, 0.0f },
|
|
||||||
.pos = { 0.0f, 0.5f, 0.0f }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.color = { 0, 255, 0, 255 },
|
|
||||||
.uv = { 0.5f, 1.0f },
|
|
||||||
.pos = { -0.5f, -0.5f, 0.0f }
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.color = { 0, 0, 255, 255 },
|
|
||||||
.uv = { 1.0f, 0.0f },
|
|
||||||
.pos = { 0.5f, -0.5f, 0.0f }
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
errorret_t displayInit(void) {
|
errorret_t displayInit(void) {
|
||||||
memoryZero(&DISPLAY, sizeof(DISPLAY));
|
memoryZero(&DISPLAY, sizeof(DISPLAY));
|
||||||
@@ -48,27 +32,64 @@ errorret_t displayInit(void) {
|
|||||||
#ifdef displayPlatformInit
|
#ifdef displayPlatformInit
|
||||||
errorChain(displayPlatformInit());
|
errorChain(displayPlatformInit());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
errorChain(shaderInit(&SHADER_UNLIT, &SHADER_UNLIT_DEFINITION));
|
||||||
errorChain(quadInit());
|
errorChain(quadInit());
|
||||||
errorChain(frameBufferInitBackBuffer());
|
errorChain(frameBufferInitBackBuffer());
|
||||||
errorChain(spriteBatchInit());
|
errorChain(spriteBatchInit());
|
||||||
errorChain(textInit());
|
errorChain(textInit());
|
||||||
errorChain(screenInit());
|
errorChain(screenInit());
|
||||||
|
|
||||||
// Setup initial shader with default values
|
// PALETTES[0].colors[0] = COLOR_RED;
|
||||||
errorChain(shaderInit(&SHADER_UNLIT, &SHADER_UNLIT_DEFINITION));
|
// PALETTES[0].colors[1] = COLOR_GREEN;
|
||||||
camera_t cam;
|
// PALETTES[0].colors[2] = COLOR_BLUE;
|
||||||
cameraInit(&cam);
|
// PALETTES[0].colors[3] = COLOR_WHITE;
|
||||||
mat4 mat;
|
// PALETTES[0].colors[4] = COLOR_MAGENTA;
|
||||||
cameraGetProjectionMatrix(&cam, mat);
|
// PALETTES[0].colors[5] = COLOR_CYAN;
|
||||||
errorChain(shaderBind(&SHADER_UNLIT));
|
// PALETTES[0].colors[6] = COLOR_YELLOW;
|
||||||
errorChain(shaderSetMatrix(&SHADER_UNLIT, SHADER_UNLIT_PROJECTION, mat));
|
// PALETTES[0].colors[7] = COLOR_BLACK;
|
||||||
cameraGetViewMatrix(&cam, mat);
|
// PALETTES[0].count = 8;
|
||||||
errorChain(shaderSetMatrix(&SHADER_UNLIT, SHADER_UNLIT_VIEW, mat));
|
|
||||||
glm_mat4_identity(mat);
|
|
||||||
errorChain(shaderSetMatrix(&SHADER_UNLIT, SHADER_UNLIT_MODEL, mat));
|
|
||||||
errorChain(shaderSetTexture(&SHADER_UNLIT, SHADER_UNLIT_TEXTURE, NULL));
|
|
||||||
|
|
||||||
errorChain(meshInit(&mesh, MESH_PRIMITIVE_TYPE_TRIANGLES, 3, vertices));
|
// uint8_t indices[64] = {
|
||||||
|
// 0,0,0,0,0,0,0,0,
|
||||||
|
// 1,1,1,1,1,1,1,1,
|
||||||
|
// 2,2,2,2,2,2,2,2,
|
||||||
|
// 3,3,3,3,3,3,3,3,
|
||||||
|
// 4,4,4,4,4,4,4,4,
|
||||||
|
// 5,5,5,5,5,5,5,5,
|
||||||
|
// 6,6,6,6,6,6,6,6,
|
||||||
|
// 7,7,7,7,7,7,7,7
|
||||||
|
// };
|
||||||
|
|
||||||
|
// errorChain(textureInit(
|
||||||
|
// &PALETTE_TEXTURE,
|
||||||
|
// 8, 8,
|
||||||
|
// TEXTURE_FORMAT_PALETTE,
|
||||||
|
// (texturedata_t){
|
||||||
|
// .paletted = {
|
||||||
|
// .indices = indices,
|
||||||
|
// .palette = &PALETTES[0]
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// ));
|
||||||
|
|
||||||
|
errorChain(textureInit(
|
||||||
|
&UNCOMPRESSED_TEXTURE,
|
||||||
|
8, 8,
|
||||||
|
TEXTURE_FORMAT_RGBA,
|
||||||
|
(texturedata_t){
|
||||||
|
.rgbaColors = (color_t[]){
|
||||||
|
COLOR_RED, COLOR_GREEN, COLOR_BLUE, COLOR_WHITE, COLOR_MAGENTA, COLOR_CYAN, COLOR_YELLOW, COLOR_BLACK,
|
||||||
|
COLOR_GREEN, COLOR_BLUE, COLOR_WHITE, COLOR_MAGENTA, COLOR_CYAN, COLOR_YELLOW, COLOR_BLACK, COLOR_RED,
|
||||||
|
COLOR_BLUE, COLOR_WHITE, COLOR_MAGENTA, COLOR_CYAN, COLOR_YELLOW, COLOR_BLACK, COLOR_RED, COLOR_GREEN,
|
||||||
|
COLOR_WHITE, COLOR_MAGENTA, COLOR_CYAN, COLOR_YELLOW, COLOR_BLACK, COLOR_RED, COLOR_GREEN, COLOR_BLUE,
|
||||||
|
COLOR_MAGENTA, COLOR_CYAN, COLOR_YELLOW, COLOR_BLACK, COLOR_RED, COLOR_GREEN, COLOR_BLUE, COLOR_WHITE,
|
||||||
|
COLOR_CYAN, COLOR_YELLOW, COLOR_BLACK, COLOR_RED, COLOR_GREEN, COLOR_BLUE, COLOR_WHITE, COLOR_MAGENTA,
|
||||||
|
COLOR_YELLOW, COLOR_BLACK, COLOR_RED, COLOR_GREEN, COLOR_BLUE, COLOR_WHITE, COLOR_MAGENTA, COLOR_CYAN,
|
||||||
|
COLOR_BLACK, COLOR_RED, COLOR_GREEN, COLOR_BLUE, COLOR_WHITE, COLOR_MAGENTA, COLOR_CYAN, COLOR_YELLOW
|
||||||
|
}
|
||||||
|
}
|
||||||
|
));
|
||||||
|
|
||||||
errorOk();
|
errorOk();
|
||||||
}
|
}
|
||||||
@@ -89,7 +110,38 @@ errorret_t displayUpdate(void) {
|
|||||||
SCREEN.background
|
SCREEN.background
|
||||||
);
|
);
|
||||||
|
|
||||||
errorChain(sceneRender());
|
camera_t camera;
|
||||||
|
// cameraInitOrthographic(&camera);
|
||||||
|
// camera.orthographic.left = 0.0f;
|
||||||
|
// camera.orthographic.right = SCREEN.width;
|
||||||
|
// camera.orthographic.top = SCREEN.height;
|
||||||
|
// camera.orthographic.bottom = 0.0f;
|
||||||
|
cameraInitPerspective(&camera);
|
||||||
|
camera.lookat.position[0] = 3.0f;
|
||||||
|
camera.lookat.position[1] = 3.0f;
|
||||||
|
camera.lookat.position[2] = 3.0f;
|
||||||
|
|
||||||
|
mat4 proj, view, model;
|
||||||
|
cameraGetProjectionMatrix(&camera, proj);
|
||||||
|
cameraGetViewMatrix(&camera, view);
|
||||||
|
glm_mat4_identity(model);
|
||||||
|
|
||||||
|
errorChain(shaderBind(&SHADER_UNLIT));
|
||||||
|
errorChain(shaderSetMatrix(&SHADER_UNLIT, SHADER_UNLIT_PROJECTION, proj));
|
||||||
|
errorChain(shaderSetMatrix(&SHADER_UNLIT, SHADER_UNLIT_VIEW, view));
|
||||||
|
errorChain(shaderSetMatrix(&SHADER_UNLIT, SHADER_UNLIT_MODEL, model));
|
||||||
|
// errorChain(shaderSetTexture(&SHADER_UNLIT, SHADER_UNLIT_TEXTURE, &PALETTE_TEXTURE));
|
||||||
|
errorChain(shaderSetTexture(&SHADER_UNLIT, SHADER_UNLIT_TEXTURE, &UNCOMPRESSED_TEXTURE));
|
||||||
|
errorChain(spriteBatchPush(
|
||||||
|
0.0f, 0.0f,
|
||||||
|
1.0f, 1.0f,
|
||||||
|
COLOR_WHITE,
|
||||||
|
0.0f, 0.0f,
|
||||||
|
1.0f, 1.0f
|
||||||
|
));
|
||||||
|
errorChain(spriteBatchFlush());
|
||||||
|
|
||||||
|
// errorCatch(errorPrint(sceneRender()));
|
||||||
|
|
||||||
// Render UI
|
// Render UI
|
||||||
// uiRender();
|
// uiRender();
|
||||||
|
|||||||
@@ -7,5 +7,4 @@
|
|||||||
target_sources(${DUSK_LIBRARY_TARGET_NAME}
|
target_sources(${DUSK_LIBRARY_TARGET_NAME}
|
||||||
PUBLIC
|
PUBLIC
|
||||||
shader.c
|
shader.c
|
||||||
shaderunlit.c
|
|
||||||
)
|
)
|
||||||
@@ -8,19 +8,15 @@
|
|||||||
#include "shader.h"
|
#include "shader.h"
|
||||||
#include "assert/assert.h"
|
#include "assert/assert.h"
|
||||||
|
|
||||||
shader_t *bound = NULL;
|
|
||||||
|
|
||||||
errorret_t shaderInit(shader_t *shader, const shaderdefinition_t *def) {
|
errorret_t shaderInit(shader_t *shader, const shaderdefinition_t *def) {
|
||||||
assertNotNull(shader, "Shader cannot be null");
|
assertNotNull(shader, "Shader cannot be null");
|
||||||
errorChain(shaderInitPlatform(shader, def));
|
errorChain(shaderInitPlatform(shader, def));
|
||||||
bound = NULL;
|
|
||||||
errorOk();
|
errorOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
errorret_t shaderBind(shader_t *shader) {
|
errorret_t shaderBind(shader_t *shader) {
|
||||||
assertNotNull(shader, "Shader cannot be null");
|
assertNotNull(shader, "Shader cannot be null");
|
||||||
errorChain(shaderBindPlatform(shader));
|
errorChain(shaderBindPlatform(shader));
|
||||||
bound = shader;
|
|
||||||
errorOk();
|
errorOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,7 +28,6 @@ errorret_t shaderSetMatrix(
|
|||||||
assertNotNull(shader, "Shader cannot be null");
|
assertNotNull(shader, "Shader cannot be null");
|
||||||
assertStrLenMin(name, 1, "Uniform name cannot be empty");
|
assertStrLenMin(name, 1, "Uniform name cannot be empty");
|
||||||
assertNotNull(matrix, "Matrix cannot be null");
|
assertNotNull(matrix, "Matrix cannot be null");
|
||||||
assertTrue(bound == shader, "Shader must be bound.");
|
|
||||||
errorChain(shaderSetMatrixPlatform(shader, name, matrix));
|
errorChain(shaderSetMatrixPlatform(shader, name, matrix));
|
||||||
errorOk();
|
errorOk();
|
||||||
}
|
}
|
||||||
@@ -44,7 +39,6 @@ errorret_t shaderSetTexture(
|
|||||||
) {
|
) {
|
||||||
assertNotNull(shader, "Shader cannot be null");
|
assertNotNull(shader, "Shader cannot be null");
|
||||||
assertStrLenMin(name, 1, "Uniform name cannot be empty");
|
assertStrLenMin(name, 1, "Uniform name cannot be empty");
|
||||||
assertTrue(bound == shader, "Shader must be bound.");
|
|
||||||
errorChain(shaderSetTexturePlatform(shader, name, texture));
|
errorChain(shaderSetTexturePlatform(shader, name, texture));
|
||||||
errorOk();
|
errorOk();
|
||||||
}
|
}
|
||||||
@@ -62,7 +56,6 @@ errorret_t shaderSetTexture(
|
|||||||
|
|
||||||
errorret_t shaderDispose(shader_t *shader) {
|
errorret_t shaderDispose(shader_t *shader) {
|
||||||
assertNotNull(shader, "Shader cannot be null");
|
assertNotNull(shader, "Shader cannot be null");
|
||||||
bound = NULL;
|
|
||||||
errorChain(shaderDisposePlatform(shader));
|
errorChain(shaderDisposePlatform(shader));
|
||||||
errorOk();
|
errorOk();
|
||||||
}
|
}
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2026 Dominic Masters
|
|
||||||
*
|
|
||||||
* This software is released under the MIT License.
|
|
||||||
* https://opensource.org/licenses/MIT
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "shaderunlit.h"
|
|
||||||
|
|
||||||
shader_t SHADER_UNLIT = { 0 };
|
|
||||||
@@ -15,4 +15,4 @@
|
|||||||
// #define SHADER_UNLIT_COLOR "u_Color"
|
// #define SHADER_UNLIT_COLOR "u_Color"
|
||||||
|
|
||||||
extern shaderdefinition_t SHADER_UNLIT_DEFINITION;
|
extern shaderdefinition_t SHADER_UNLIT_DEFINITION;
|
||||||
extern shader_t SHADER_UNLIT;
|
static shader_t SHADER_UNLIT;
|
||||||
@@ -35,13 +35,14 @@ errorret_t spriteBatchPush(
|
|||||||
const float_t u1,
|
const float_t u1,
|
||||||
const float_t v1
|
const float_t v1
|
||||||
) {
|
) {
|
||||||
return spriteBatchPush3D(
|
errorChain(spriteBatchPush3D(
|
||||||
(vec3){ minX, minY, 0 },
|
(vec3){ minX, minY, 0 },
|
||||||
(vec3){ maxX, maxY, 0 },
|
(vec3){ maxX, maxY, 0 },
|
||||||
color,
|
color,
|
||||||
(vec2){ u0, v0 },
|
(vec2){ u0, v0 },
|
||||||
(vec2){ u1, v1 }
|
(vec2){ u1, v1 }
|
||||||
);
|
));
|
||||||
|
errorOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
errorret_t spriteBatchPush3D(
|
errorret_t spriteBatchPush3D(
|
||||||
@@ -52,14 +53,11 @@ errorret_t spriteBatchPush3D(
|
|||||||
const vec2 uv1
|
const vec2 uv1
|
||||||
) {
|
) {
|
||||||
// Need to flush?
|
// Need to flush?
|
||||||
if(SPRITEBATCH.spriteCount >= SPRITEBATCH_SPRITES_MAX_PER_FLUSH) {
|
if(SPRITEBATCH.spriteCount >= SPRITEBATCH_SPRITES_MAX) {
|
||||||
errorChain(spriteBatchFlush());
|
errorChain(spriteBatchFlush());
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t vertexOffset = (
|
size_t vertexOffset = SPRITEBATCH.spriteCount * QUAD_VERTEX_COUNT;
|
||||||
SPRITEBATCH.spriteCount +
|
|
||||||
(SPRITEBATCH.spriteFlush * SPRITEBATCH_SPRITES_MAX_PER_FLUSH)
|
|
||||||
) * QUAD_VERTEX_COUNT;
|
|
||||||
quadBuffer3D(
|
quadBuffer3D(
|
||||||
&SPRITEBATCH_VERTICES[vertexOffset],
|
&SPRITEBATCH_VERTICES[vertexOffset],
|
||||||
min, max, color, uv0, uv1
|
min, max, color, uv0, uv1
|
||||||
@@ -70,7 +68,6 @@ errorret_t spriteBatchPush3D(
|
|||||||
|
|
||||||
void spriteBatchClear() {
|
void spriteBatchClear() {
|
||||||
SPRITEBATCH.spriteCount = 0;
|
SPRITEBATCH.spriteCount = 0;
|
||||||
SPRITEBATCH.spriteFlush = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
errorret_t spriteBatchFlush() {
|
errorret_t spriteBatchFlush() {
|
||||||
@@ -79,19 +76,9 @@ errorret_t spriteBatchFlush() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
size_t vertexCount = QUAD_VERTEX_COUNT * SPRITEBATCH.spriteCount;
|
size_t vertexCount = QUAD_VERTEX_COUNT * SPRITEBATCH.spriteCount;
|
||||||
size_t vertexOffset = (
|
errorChain(meshFlush(&SPRITEBATCH.mesh, 0, vertexCount));
|
||||||
SPRITEBATCH.spriteFlush * SPRITEBATCH_SPRITES_MAX_PER_FLUSH *
|
errorChain(meshDraw(&SPRITEBATCH.mesh, 0, vertexCount));
|
||||||
QUAD_VERTEX_COUNT
|
spriteBatchClear();
|
||||||
);
|
|
||||||
errorChain(meshFlush(&SPRITEBATCH.mesh, vertexOffset, vertexCount));
|
|
||||||
errorChain(meshDraw(&SPRITEBATCH.mesh, vertexOffset, vertexCount));
|
|
||||||
|
|
||||||
SPRITEBATCH.spriteFlush++;
|
|
||||||
if(SPRITEBATCH.spriteFlush >= SPRITEBATCH_FLUSH_COUNT) {
|
|
||||||
SPRITEBATCH.spriteFlush = 0;
|
|
||||||
}
|
|
||||||
SPRITEBATCH.spriteCount = 0;
|
|
||||||
|
|
||||||
errorOk();
|
errorOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,17 +8,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "display/mesh/quad.h"
|
#include "display/mesh/quad.h"
|
||||||
|
|
||||||
#define SPRITEBATCH_SPRITES_MAX 32
|
#define SPRITEBATCH_SPRITES_MAX 16
|
||||||
#define SPRITEBATCH_VERTEX_COUNT (SPRITEBATCH_SPRITES_MAX * QUAD_VERTEX_COUNT)
|
#define SPRITEBATCH_VERTEX_COUNT (SPRITEBATCH_SPRITES_MAX * QUAD_VERTEX_COUNT)
|
||||||
#define SPRITEBATCH_FLUSH_COUNT 4
|
|
||||||
#define SPRITEBATCH_SPRITES_MAX_PER_FLUSH (\
|
|
||||||
SPRITEBATCH_SPRITES_MAX / SPRITEBATCH_FLUSH_COUNT \
|
|
||||||
)
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
mesh_t mesh;
|
mesh_t mesh;
|
||||||
int32_t spriteCount;
|
int32_t spriteCount;
|
||||||
int32_t spriteFlush;
|
|
||||||
} spritebatch_t;
|
} spritebatch_t;
|
||||||
|
|
||||||
// Have to define these seperately because of alignment in certain platforms.
|
// Have to define these seperately because of alignment in certain platforms.
|
||||||
|
|||||||
@@ -11,19 +11,17 @@
|
|||||||
#include "display/spritebatch/spritebatch.h"
|
#include "display/spritebatch/spritebatch.h"
|
||||||
#include "asset/asset.h"
|
#include "asset/asset.h"
|
||||||
|
|
||||||
#include "display/shader/shaderunlit.h"
|
|
||||||
|
|
||||||
texture_t DEFAULT_FONT_TEXTURE;
|
texture_t DEFAULT_FONT_TEXTURE;
|
||||||
tileset_t DEFAULT_FONT_TILESET;
|
tileset_t DEFAULT_FONT_TILESET;
|
||||||
|
|
||||||
errorret_t textInit(void) {
|
errorret_t textInit(void) {
|
||||||
errorChain(assetLoad("ui/minogram.dtx", &DEFAULT_FONT_TEXTURE));
|
// errorChain(assetLoad("ui/minogram.dpt", &DEFAULT_FONT_TEXTURE));
|
||||||
errorChain(assetLoad("ui/minogram.dtf", &DEFAULT_FONT_TILESET));
|
// errorChain(assetLoad("ui/minogram.dtf", &DEFAULT_FONT_TILESET));
|
||||||
errorOk();
|
errorOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
errorret_t textDispose(void) {
|
errorret_t textDispose(void) {
|
||||||
errorChain(textureDispose(&DEFAULT_FONT_TEXTURE));
|
// errorChain(textureDispose(&DEFAULT_FONT_TEXTURE));
|
||||||
errorOk();
|
errorOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,7 +45,6 @@ errorret_t textDrawChar(
|
|||||||
vec4 uv;
|
vec4 uv;
|
||||||
tilesetTileGetUV(tileset, tileIndex, uv);
|
tilesetTileGetUV(tileset, tileIndex, uv);
|
||||||
|
|
||||||
|
|
||||||
errorChain(spriteBatchPush(
|
errorChain(spriteBatchPush(
|
||||||
// texture,
|
// texture,
|
||||||
x, y,
|
x, y,
|
||||||
@@ -73,8 +70,6 @@ errorret_t textDraw(
|
|||||||
float_t posX = x;
|
float_t posX = x;
|
||||||
float_t posY = y;
|
float_t posY = y;
|
||||||
|
|
||||||
errorChain(shaderSetTexture(&SHADER_UNLIT, SHADER_UNLIT_TEXTURE, texture));
|
|
||||||
|
|
||||||
char_t c;
|
char_t c;
|
||||||
int32_t i = 0;
|
int32_t i = 0;
|
||||||
while((c = text[i++]) != '\0') {
|
while((c = text[i++]) != '\0') {
|
||||||
|
|||||||
45
src/dusk/duskdefs.env
Normal file
45
src/dusk/duskdefs.env
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
# Copyright (c) 2025 Dominic Masters
|
||||||
|
#
|
||||||
|
# This software is released under the MIT License.
|
||||||
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
ENTITY_DIR_SOUTH = 0
|
||||||
|
ENTITY_DIR_WEST = 1
|
||||||
|
ENTITY_DIR_EAST = 2
|
||||||
|
ENTITY_DIR_NORTH = 3
|
||||||
|
|
||||||
|
ENTITY_COUNT = 128
|
||||||
|
|
||||||
|
ENTITY_TYPE_NULL = 0
|
||||||
|
ENTITY_TYPE_PLAYER = 1
|
||||||
|
ENTITY_TYPE_NPC = 2
|
||||||
|
ENTITY_TYPE_COUNT = 3
|
||||||
|
|
||||||
|
CHUNK_WIDTH = 16
|
||||||
|
CHUNK_HEIGHT = 16
|
||||||
|
CHUNK_DEPTH = 4
|
||||||
|
# CHUNK_VERTEX_COUNT_MAX = QUAD_VERTEXES * CHUNK_WIDTH * CHUNK_HEIGHT * 4
|
||||||
|
CHUNK_VERTEX_COUNT_MAX=6144
|
||||||
|
CHUNK_MESH_COUNT_MAX = 14
|
||||||
|
CHUNK_ENTITY_COUNT_MAX = 8
|
||||||
|
|
||||||
|
TILE_WIDTH = 16.0
|
||||||
|
TILE_HEIGHT = 16.0
|
||||||
|
TILE_DEPTH = 16.0
|
||||||
|
|
||||||
|
TILE_SHAPE_NULL = 0
|
||||||
|
TILE_SHAPE_FLOOR = 1
|
||||||
|
TILE_SHAPE_RAMP_SOUTH = 2
|
||||||
|
TILE_SHAPE_RAMP_WEST = 3
|
||||||
|
TILE_SHAPE_RAMP_EAST = 4
|
||||||
|
TILE_SHAPE_RAMP_NORTH = 5
|
||||||
|
TILE_SHAPE_RAMP_SOUTHWEST = 6
|
||||||
|
TILE_SHAPE_RAMP_SOUTHEAST = 7
|
||||||
|
TILE_SHAPE_RAMP_NORTHWEST = 8
|
||||||
|
TILE_SHAPE_RAMP_NORTHEAST = 9
|
||||||
|
|
||||||
|
RPG_CAMERA_FOV = 70
|
||||||
|
RPG_CAMERA_PIXELS_PER_UNIT = 1.0
|
||||||
|
RPG_CAMERA_Z_OFFSET = 24.0
|
||||||
|
|
||||||
|
ASSET_LANG_CHUNK_CHAR_COUNT = 6144
|
||||||
@@ -22,7 +22,7 @@ errorret_t sceneInit(void) {
|
|||||||
|
|
||||||
errorret_t sceneUpdate(void) {
|
errorret_t sceneUpdate(void) {
|
||||||
#ifdef DUSK_TIME_DYNAMIC
|
#ifdef DUSK_TIME_DYNAMIC
|
||||||
if(TIME.dynamicUpdate) {
|
if(!TIME.dynamicUpdate) {
|
||||||
errorOk();
|
errorOk();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -7,8 +7,11 @@
|
|||||||
add_subdirectory(display)
|
add_subdirectory(display)
|
||||||
add_subdirectory(event)
|
add_subdirectory(event)
|
||||||
add_subdirectory(input)
|
add_subdirectory(input)
|
||||||
|
add_subdirectory(item)
|
||||||
add_subdirectory(locale)
|
add_subdirectory(locale)
|
||||||
|
add_subdirectory(map)
|
||||||
add_subdirectory(system)
|
add_subdirectory(system)
|
||||||
add_subdirectory(scene)
|
add_subdirectory(scene)
|
||||||
|
add_subdirectory(story)
|
||||||
add_subdirectory(time)
|
add_subdirectory(time)
|
||||||
add_subdirectory(ui)
|
add_subdirectory(ui)
|
||||||
@@ -15,5 +15,4 @@ target_sources(${DUSK_LIBRARY_TARGET_NAME}
|
|||||||
modulescreen.c
|
modulescreen.c
|
||||||
moduletileset.c
|
moduletileset.c
|
||||||
moduletexture.c
|
moduletexture.c
|
||||||
moduleshader.c
|
|
||||||
)
|
)
|
||||||
@@ -69,16 +69,6 @@ void moduleCamera(scriptcontext_t *context) {
|
|||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
lua_register(context->luaState, "cameraCreate", moduleCameraCreate);
|
lua_register(context->luaState, "cameraCreate", moduleCameraCreate);
|
||||||
lua_register(
|
|
||||||
context->luaState,
|
|
||||||
"cameraGetProjectionMatrix",
|
|
||||||
moduleCameraGetProjectionMatrix
|
|
||||||
);
|
|
||||||
lua_register(
|
|
||||||
context->luaState,
|
|
||||||
"cameraGetViewMatrix",
|
|
||||||
moduleCameraGetViewMatrix
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int moduleCameraCreate(lua_State *L) {
|
int moduleCameraCreate(lua_State *L) {
|
||||||
@@ -126,7 +116,7 @@ int moduleCameraCreate(lua_State *L) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int moduleCameraIndex(lua_State *l) {
|
int moduleCameraIndex(lua_State *l) {
|
||||||
assertNotNull(l, "Lua state cannot be NULL.");
|
assertNotNull(l, "Lua state cannot be NULL.");
|
||||||
|
|
||||||
const char_t *key = luaL_checkstring(l, 2);
|
const char_t *key = luaL_checkstring(l, 2);
|
||||||
@@ -299,35 +289,3 @@ int moduleCameraNewIndex(lua_State *l) {
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int moduleCameraGetProjectionMatrix(lua_State *L) {
|
|
||||||
assertNotNull(L, "Lua state cannot be NULL.");
|
|
||||||
|
|
||||||
camera_t *cam = (camera_t *)luaL_checkudata(L, 1, "camera_mt");
|
|
||||||
assertNotNull(cam, "Camera pointer cannot be NULL.");
|
|
||||||
|
|
||||||
// Create mat4
|
|
||||||
mat4 test;
|
|
||||||
cameraGetProjectionMatrix(cam, test);
|
|
||||||
|
|
||||||
// Lua needs to own this matrix now
|
|
||||||
mat4 *m = (mat4 *)lua_newuserdata(L, sizeof(mat4));
|
|
||||||
memoryCopy(m, test, sizeof(mat4));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
int moduleCameraGetViewMatrix(lua_State *L) {
|
|
||||||
assertNotNull(L, "Lua state cannot be NULL.");
|
|
||||||
|
|
||||||
camera_t *cam = (camera_t *)luaL_checkudata(L, 1, "camera_mt");
|
|
||||||
assertNotNull(cam, "Camera pointer cannot be NULL.");
|
|
||||||
|
|
||||||
// Create mat4
|
|
||||||
mat4 test;
|
|
||||||
cameraGetViewMatrix(cam, test);
|
|
||||||
|
|
||||||
// Lua needs to own this matrix now
|
|
||||||
mat4 *m = (mat4 *)lua_newuserdata(L, sizeof(mat4));
|
|
||||||
memoryCopy(m, test, sizeof(mat4));
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
@@ -36,19 +36,3 @@ int moduleCameraIndex(lua_State *l);
|
|||||||
* @param l The Lua state.
|
* @param l The Lua state.
|
||||||
*/
|
*/
|
||||||
int moduleCameraNewIndex(lua_State *l);
|
int moduleCameraNewIndex(lua_State *l);
|
||||||
|
|
||||||
/**
|
|
||||||
* Script binding for getting a camera's projection matrix.
|
|
||||||
*
|
|
||||||
* @param L The Lua state.
|
|
||||||
* @return Number of return values on the Lua stack.
|
|
||||||
*/
|
|
||||||
int moduleCameraGetProjectionMatrix(lua_State *L);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Script binding for getting a camera's view matrix.
|
|
||||||
*
|
|
||||||
* @param L The Lua state.
|
|
||||||
* @return Number of return values on the Lua stack.
|
|
||||||
*/
|
|
||||||
int moduleCameraGetViewMatrix(lua_State *L);
|
|
||||||
@@ -1,120 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2026 Dominic Masters
|
|
||||||
*
|
|
||||||
* This software is released under the MIT License.
|
|
||||||
* https://opensource.org/licenses/MIT
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "moduleshader.h"
|
|
||||||
#include "assert/assert.h"
|
|
||||||
#include "display/shader/shader.h"
|
|
||||||
#include "display/shader/shaderunlit.h"
|
|
||||||
#include "display/camera/camera.h"
|
|
||||||
|
|
||||||
void moduleShader(scriptcontext_t *context) {
|
|
||||||
assertNotNull(context, "Context cannot be NULL.");
|
|
||||||
|
|
||||||
// Shader unlit defs
|
|
||||||
lua_pushlightuserdata(context->luaState, &SHADER_UNLIT);
|
|
||||||
lua_setglobal(context->luaState, "SHADER_UNLIT");
|
|
||||||
|
|
||||||
lua_pushstring(context->luaState, SHADER_UNLIT_PROJECTION);
|
|
||||||
lua_setglobal(context->luaState, "SHADER_UNLIT_PROJECTION");
|
|
||||||
lua_pushstring(context->luaState, SHADER_UNLIT_VIEW);
|
|
||||||
lua_setglobal(context->luaState, "SHADER_UNLIT_VIEW");
|
|
||||||
lua_pushstring(context->luaState, SHADER_UNLIT_MODEL);
|
|
||||||
lua_setglobal(context->luaState, "SHADER_UNLIT_MODEL");
|
|
||||||
lua_pushstring(context->luaState, SHADER_UNLIT_TEXTURE);
|
|
||||||
lua_setglobal(context->luaState, "SHADER_UNLIT_TEXTURE");
|
|
||||||
|
|
||||||
// Shader methods
|
|
||||||
lua_register(context->luaState, "shaderBind", moduleShaderBind);
|
|
||||||
lua_register(context->luaState, "shaderSetMatrix", moduleShaderSetMatrix);
|
|
||||||
lua_register(context->luaState, "shaderSetTexture", moduleShaderSetTexture);
|
|
||||||
}
|
|
||||||
|
|
||||||
int moduleShaderBind(lua_State *l) {
|
|
||||||
assertNotNull(l, "Lua state cannot be NULL.");
|
|
||||||
|
|
||||||
// Should be passed a shader userdata pointer only.
|
|
||||||
shader_t *shader = (shader_t *)lua_touserdata(l, 1);
|
|
||||||
assertNotNull(shader, "Shader pointer cannot be NULL.");
|
|
||||||
|
|
||||||
errorret_t ret = shaderBind(shader);
|
|
||||||
if(ret.code != ERROR_OK) {
|
|
||||||
luaL_error(l, "Failed to bind shader: %s", ret.state->message);
|
|
||||||
errorCatch(errorPrint(ret));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int moduleShaderSetMatrix(lua_State *l) {
|
|
||||||
assertNotNull(l, "Lua state cannot be NULL.");
|
|
||||||
|
|
||||||
// Expect shader, string and matrix.
|
|
||||||
if(!lua_isuserdata(l, 1)) {
|
|
||||||
luaL_error(l, "First argument must be a shader_mt userdata.");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!lua_isstring(l, 2)) {
|
|
||||||
luaL_error(l, "Second argument must be a string.");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!lua_isuserdata(l, 3)) {
|
|
||||||
luaL_error(l, "Third argument must be a mat4_mt userdata.");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
shader_t *shader = (shader_t *)lua_touserdata(l, 1);
|
|
||||||
assertNotNull(shader, "Shader pointer cannot be NULL.");
|
|
||||||
|
|
||||||
const char_t *uniformName = luaL_checkstring(l, 2);
|
|
||||||
assertStrLenMin(uniformName, 1, "Uniform name cannot be empty.");
|
|
||||||
|
|
||||||
mat4 *mat = (mat4 *)lua_touserdata(l, 3);
|
|
||||||
assertNotNull(mat, "Matrix pointer cannot be NULL.");
|
|
||||||
|
|
||||||
errorret_t ret = shaderSetMatrix(shader, uniformName, *mat);
|
|
||||||
if(ret.code != ERROR_OK) {
|
|
||||||
luaL_error(l, "Failed to set shader matrix: %s", ret.state->message);
|
|
||||||
errorCatch(errorPrint(ret));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int moduleShaderSetTexture(lua_State *l) {
|
|
||||||
assertNotNull(l, "Lua state cannot be NULL.");
|
|
||||||
|
|
||||||
shader_t *shader = (shader_t *)lua_touserdata(l, 1);
|
|
||||||
assertNotNull(shader, "Shader pointer cannot be NULL.");
|
|
||||||
|
|
||||||
const char_t *uniformName = luaL_checkstring(l, 2);
|
|
||||||
assertStrLenMin(uniformName, 1, "Uniform name cannot be empty.");
|
|
||||||
|
|
||||||
texture_t *texture;
|
|
||||||
// Texture can be Nil or a pointer, if not nil it must be a texture pointer.
|
|
||||||
if(lua_isnil(l, 3)) {
|
|
||||||
texture = NULL;
|
|
||||||
} else if(lua_isuserdata(l, 3)) {
|
|
||||||
texture = (texture_t *)lua_touserdata(l, 3);
|
|
||||||
assertNotNull(texture, "Texture pointer cannot be NULL.");
|
|
||||||
} else {
|
|
||||||
luaL_error(l, "Third argument must be a texture_mt userdata or nil.");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
errorret_t ret = shaderSetTexture(shader, uniformName, texture);
|
|
||||||
if(ret.code != ERROR_OK) {
|
|
||||||
luaL_error(l, "Failed to set shader texture: %s", ret.state->message);
|
|
||||||
errorCatch(errorPrint(ret));
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2026 Dominic Masters
|
|
||||||
*
|
|
||||||
* This software is released under the MIT License.
|
|
||||||
* https://opensource.org/licenses/MIT
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#include "script/scriptcontext.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register shader functions to the given script context.
|
|
||||||
*
|
|
||||||
* @param context The script context to register shader functions to.
|
|
||||||
*/
|
|
||||||
void moduleShader(scriptcontext_t *context);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Script binding for binding a shader.
|
|
||||||
*
|
|
||||||
* @param l The Lua state.
|
|
||||||
* @return Number of return values on the Lua stack.
|
|
||||||
*/
|
|
||||||
int moduleShaderBind(lua_State *l);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Script binding for setting a matrix uniform in a shader.
|
|
||||||
*
|
|
||||||
* @param l The Lua state.
|
|
||||||
* @return Number of return values on the Lua stack.
|
|
||||||
*/
|
|
||||||
int moduleShaderSetMatrix(lua_State *l);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Script binding for setting a texture uniform in a shader.
|
|
||||||
*
|
|
||||||
* @param l The Lua state.
|
|
||||||
* @return Number of return values on the Lua stack.
|
|
||||||
*/
|
|
||||||
int moduleShaderSetTexture(lua_State *l);
|
|
||||||
|
|
||||||
errorret_t doThing();
|
|
||||||
@@ -10,6 +10,7 @@
|
|||||||
#include "script/module/input/moduleinput.h"
|
#include "script/module/input/moduleinput.h"
|
||||||
#include "script/module/moduleplatform.h"
|
#include "script/module/moduleplatform.h"
|
||||||
#include "script/module/scene/modulescene.h"
|
#include "script/module/scene/modulescene.h"
|
||||||
|
#include "script/module/item/moduleitem.h"
|
||||||
#include "script/module/locale/modulelocale.h"
|
#include "script/module/locale/modulelocale.h"
|
||||||
#include "script/module/time/moduletime.h"
|
#include "script/module/time/moduletime.h"
|
||||||
#include "script/module/event/moduleevent.h"
|
#include "script/module/event/moduleevent.h"
|
||||||
@@ -17,13 +18,13 @@
|
|||||||
#include "script/module/display/modulespritebatch.h"
|
#include "script/module/display/modulespritebatch.h"
|
||||||
#include "script/module/display/modulecamera.h"
|
#include "script/module/display/modulecamera.h"
|
||||||
#include "script/module/display/moduleglm.h"
|
#include "script/module/display/moduleglm.h"
|
||||||
#include "script/module/display/moduleshader.h"
|
|
||||||
#include "script/module/ui/moduleui.h"
|
#include "script/module/ui/moduleui.h"
|
||||||
#include "script/module/display/moduletext.h"
|
#include "script/module/display/moduletext.h"
|
||||||
#include "script/module/display/modulescreen.h"
|
#include "script/module/display/modulescreen.h"
|
||||||
|
#include "script/module/story/modulestoryflag.h"
|
||||||
|
#include "script/module/map/modulemap.h"
|
||||||
#include "script/module/display/moduletexture.h"
|
#include "script/module/display/moduletexture.h"
|
||||||
#include "script/module/display/moduletileset.h"
|
#include "script/module/display/moduletileset.h"
|
||||||
#include "script/scriptgame.h"
|
|
||||||
#include "util/string.h"
|
#include "util/string.h"
|
||||||
|
|
||||||
const scriptmodule_t SCRIPT_MODULE_LIST[] = {
|
const scriptmodule_t SCRIPT_MODULE_LIST[] = {
|
||||||
@@ -32,6 +33,7 @@ const scriptmodule_t SCRIPT_MODULE_LIST[] = {
|
|||||||
{ .name = "platform", .callback = modulePlatform },
|
{ .name = "platform", .callback = modulePlatform },
|
||||||
{ .name = "color", .callback = moduleColor },
|
{ .name = "color", .callback = moduleColor },
|
||||||
{ .name = "scene", .callback = moduleScene },
|
{ .name = "scene", .callback = moduleScene },
|
||||||
|
{ .name = "item", .callback = moduleItem },
|
||||||
{ .name = "locale", .callback = moduleLocale },
|
{ .name = "locale", .callback = moduleLocale },
|
||||||
{ .name = "time", .callback = moduleTime },
|
{ .name = "time", .callback = moduleTime },
|
||||||
{ .name = "event", .callback = moduleEvent },
|
{ .name = "event", .callback = moduleEvent },
|
||||||
@@ -41,13 +43,10 @@ const scriptmodule_t SCRIPT_MODULE_LIST[] = {
|
|||||||
{ .name = "ui", .callback = moduleUi },
|
{ .name = "ui", .callback = moduleUi },
|
||||||
{ .name = "text", .callback = moduleText },
|
{ .name = "text", .callback = moduleText },
|
||||||
{ .name = "screen", .callback = moduleScreen },
|
{ .name = "screen", .callback = moduleScreen },
|
||||||
|
{ .name = "storyflag", .callback = moduleStoryFlag },
|
||||||
|
{ .name = "map", .callback = moduleMap },
|
||||||
{ .name = "texture", .callback = moduleTexture },
|
{ .name = "texture", .callback = moduleTexture },
|
||||||
{ .name = "tileset", .callback = moduleTileset },
|
{ .name = "tileset", .callback = moduleTileset },
|
||||||
{ .name = "shader", .callback = moduleShader },
|
|
||||||
|
|
||||||
#ifdef SCRIPT_GAME_LIST
|
|
||||||
SCRIPT_GAME_LIST
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define SCRIPT_MODULE_COUNT ( \
|
#define SCRIPT_MODULE_COUNT ( \
|
||||||
|
|||||||
@@ -11,10 +11,6 @@
|
|||||||
|
|
||||||
void cameraPushMatrixDolphin(camera_t *camera) {
|
void cameraPushMatrixDolphin(camera_t *camera) {
|
||||||
assertNotNull(camera, "Camera cannot be null");
|
assertNotNull(camera, "Camera cannot be null");
|
||||||
assertTrue(
|
|
||||||
camera->nearClip > 0.0f,
|
|
||||||
"Camera near clip must be greater than 0 for Dolphin"
|
|
||||||
);
|
|
||||||
|
|
||||||
Mtx44 guProjection;
|
Mtx44 guProjection;
|
||||||
Mtx guView;
|
Mtx guView;
|
||||||
|
|||||||
@@ -77,8 +77,7 @@ errorret_t displayInitDolphin(void) {
|
|||||||
|
|
||||||
// Setup cull modes
|
// Setup cull modes
|
||||||
GX_SetCullMode(GX_CULL_NONE);
|
GX_SetCullMode(GX_CULL_NONE);
|
||||||
GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR);
|
GX_SetZMode(GX_FALSE, GX_ALWAYS, GX_FALSE);
|
||||||
GX_SetZMode(GX_TRUE, GX_ALWAYS, GX_FALSE);
|
|
||||||
GX_SetDispCopyGamma(GX_GM_1_0);
|
GX_SetDispCopyGamma(GX_GM_1_0);
|
||||||
GX_SetColorUpdate(GX_TRUE);
|
GX_SetColorUpdate(GX_TRUE);
|
||||||
|
|
||||||
|
|||||||
@@ -60,8 +60,6 @@ errorret_t meshDrawDolphin(
|
|||||||
GX_SetArray(GX_VA_CLR0, (void*)&mesh->vertices[vertexOffset].color.r, stride);
|
GX_SetArray(GX_VA_CLR0, (void*)&mesh->vertices[vertexOffset].color.r, stride);
|
||||||
GX_SetArray(GX_VA_TEX0, (void*)&mesh->vertices[vertexOffset].uv[0], stride);
|
GX_SetArray(GX_VA_TEX0, (void*)&mesh->vertices[vertexOffset].uv[0], stride);
|
||||||
|
|
||||||
GX_InvVtxCache();
|
|
||||||
|
|
||||||
GX_Begin(mesh->primitiveType, GX_VTXFMT0, (uint16_t)vertexCount);
|
GX_Begin(mesh->primitiveType, GX_VTXFMT0, (uint16_t)vertexCount);
|
||||||
for(uint16_t i = 0; i < (uint16_t)vertexCount; ++i) {
|
for(uint16_t i = 0; i < (uint16_t)vertexCount; ++i) {
|
||||||
GX_Position1x16(i);
|
GX_Position1x16(i);
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ void cameraPushMatrixGL(camera_t *camera) {
|
|||||||
|
|
||||||
switch(camera->viewType) {
|
switch(camera->viewType) {
|
||||||
case CAMERA_VIEW_TYPE_MATRIX:
|
case CAMERA_VIEW_TYPE_MATRIX:
|
||||||
glm_mat4_ucopy(camera->view, view);
|
glm_mat4_copy(camera->view, view);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CAMERA_VIEW_TYPE_LOOKAT:
|
case CAMERA_VIEW_TYPE_LOOKAT:
|
||||||
|
|||||||
@@ -11,6 +11,13 @@ errorret_t displayOpenGLInit(void) {
|
|||||||
glDisable(GL_CULL_FACE);
|
glDisable(GL_CULL_FACE);
|
||||||
errorChain(errorGLCheck());
|
errorChain(errorGLCheck());
|
||||||
|
|
||||||
|
#if DUSK_OPENGL_LEGACY
|
||||||
|
glDisable(GL_LIGHTING);// PSP defaults this on?
|
||||||
|
errorChain(errorGLCheck());
|
||||||
|
glShadeModel(GL_SMOOTH); // Fixes color on PSP?
|
||||||
|
errorChain(errorGLCheck());
|
||||||
|
#endif
|
||||||
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
errorChain(errorGLCheck());
|
errorChain(errorGLCheck());
|
||||||
glDepthFunc(GL_LEQUAL);
|
glDepthFunc(GL_LEQUAL);
|
||||||
@@ -25,12 +32,5 @@ errorret_t displayOpenGLInit(void) {
|
|||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||||
errorChain(errorGLCheck());
|
errorChain(errorGLCheck());
|
||||||
|
|
||||||
#if DUSK_OPENGL_LEGACY
|
|
||||||
glDisable(GL_LIGHTING);// PSP defaults this on?
|
|
||||||
errorChain(errorGLCheck());
|
|
||||||
glShadeModel(GL_SMOOTH); // Fixes color on PSP?
|
|
||||||
errorChain(errorGLCheck());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
errorOk();
|
errorOk();
|
||||||
}
|
}
|
||||||
@@ -113,10 +113,8 @@ errorret_t meshFlushGL(
|
|||||||
errorChain(errorGLCheck());
|
errorChain(errorGLCheck());
|
||||||
glBufferData(
|
glBufferData(
|
||||||
GL_ARRAY_BUFFER,
|
GL_ARRAY_BUFFER,
|
||||||
mesh->vertexCount * sizeof(meshvertex_t),
|
vertCount * sizeof(meshvertex_t),
|
||||||
mesh->vertices,
|
&mesh->vertices[vertOffset],
|
||||||
// vertCount * sizeof(meshvertex_t),
|
|
||||||
// &mesh->vertices[vertOffset],
|
|
||||||
GL_DYNAMIC_DRAW
|
GL_DYNAMIC_DRAW
|
||||||
);
|
);
|
||||||
errorChain(errorGLCheck());
|
errorChain(errorGLCheck());
|
||||||
|
|||||||
@@ -157,10 +157,11 @@ errorret_t shaderParamGetLocationGL(
|
|||||||
#ifdef DUSK_OPENGL_LEGACY
|
#ifdef DUSK_OPENGL_LEGACY
|
||||||
assertUnreachable("Cannot get uniform locations on legacy opengl.");
|
assertUnreachable("Cannot get uniform locations on legacy opengl.");
|
||||||
#else
|
#else
|
||||||
*location = glGetUniformLocation(shader->shaderProgramId, name);
|
shadergl_t *shaderGL = (shadergl_t *)shader;
|
||||||
errorChain(errorGLCheck());
|
*location = glGetUniformLocation(shaderGL->shaderProgramId, name);
|
||||||
if(*location == -1) {
|
errorret_t err = errorGLCheck();
|
||||||
errorThrow("Uniform '%s' not found in shader.", name);
|
if(err.code != ERROR_OK) {
|
||||||
|
errorChain(err);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -173,26 +174,25 @@ errorret_t shaderSetMatrixGL(
|
|||||||
mat4 mat
|
mat4 mat
|
||||||
) {
|
) {
|
||||||
assertNotNull(shader, "Shader cannot be null");
|
assertNotNull(shader, "Shader cannot be null");
|
||||||
assertStrLenMin(name, 1, "Uniform name cannot be empty");
|
|
||||||
assertNotNull(mat, "Matrix data cannot be null");
|
assertNotNull(mat, "Matrix data cannot be null");
|
||||||
|
assertStrLenMin(name, 1, "Uniform name cannot be empty");
|
||||||
|
|
||||||
#ifdef DUSK_OPENGL_LEGACY
|
#ifdef DUSK_OPENGL_LEGACY
|
||||||
assertTrue(
|
assertTrue(
|
||||||
SHADER_LEGACY.boundShader == shader,
|
SHADER_LEGACY.boundShader == shader,
|
||||||
"Shader must be bound to set legacy matrices."
|
"Shader must be bound to set legacy matrices."
|
||||||
);
|
);
|
||||||
// Use unaligned copy to safely handle possibly unaligned input matrices
|
|
||||||
if(stringCompare(name, SHADER_UNLIT_PROJECTION) == 0) {
|
if(stringCompare(name, SHADER_UNLIT_PROJECTION) == 0) {
|
||||||
SHADER_LEGACY.dirty |= SHADER_LEGACY_DIRTY_PROJ;
|
SHADER_LEGACY.dirty |= SHADER_LEGACY_DIRTY_PROJ;
|
||||||
glm_mat4_ucopy(mat, shader->proj);
|
glm_mat4_copy(mat, shader->proj);
|
||||||
|
|
||||||
} else if(stringCompare(name, SHADER_UNLIT_VIEW) == 0) {
|
} else if(stringCompare(name, SHADER_UNLIT_VIEW) == 0) {
|
||||||
SHADER_LEGACY.dirty |= SHADER_LEGACY_DIRTY_VIEW;
|
SHADER_LEGACY.dirty |= SHADER_LEGACY_DIRTY_VIEW;
|
||||||
glm_mat4_ucopy(mat, shader->view);
|
glm_mat4_copy(mat, shader->view);
|
||||||
|
|
||||||
} else if(stringCompare(name, SHADER_UNLIT_MODEL) == 0) {
|
} else if(stringCompare(name, SHADER_UNLIT_MODEL) == 0) {
|
||||||
SHADER_LEGACY.dirty |= SHADER_LEGACY_DIRTY_MODEL;
|
SHADER_LEGACY.dirty |= SHADER_LEGACY_DIRTY_MODEL;
|
||||||
glm_mat4_ucopy(mat, shader->model);
|
glm_mat4_copy(mat, shader->model);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
assertUnreachable("Cannot use a custom matrix on legacy opengl.");
|
assertUnreachable("Cannot use a custom matrix on legacy opengl.");
|
||||||
@@ -233,8 +233,6 @@ errorret_t shaderSetTextureGL(
|
|||||||
errorChain(errorGLCheck());
|
errorChain(errorGLCheck());
|
||||||
glBindTexture(GL_TEXTURE_2D, texture->id);
|
glBindTexture(GL_TEXTURE_2D, texture->id);
|
||||||
errorChain(errorGLCheck());
|
errorChain(errorGLCheck());
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
|
||||||
errorChain(errorGLCheck());
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
if(shader->setTexture == NULL) {
|
if(shader->setTexture == NULL) {
|
||||||
|
|||||||
@@ -122,7 +122,7 @@
|
|||||||
// Uniforms
|
// Uniforms
|
||||||
"uniform sampler2D u_Texture;\n"
|
"uniform sampler2D u_Texture;\n"
|
||||||
"uniform int u_TextureType;\n"
|
"uniform int u_TextureType;\n"
|
||||||
"uniform uint u_Colors[256];\n"// For paletted textures.
|
"uniform vec4 u_Colors[256];\n"// For paletted textures.
|
||||||
"uniform int u_ColorCount;\n"
|
"uniform int u_ColorCount;\n"
|
||||||
// Fragment shader inputs
|
// Fragment shader inputs
|
||||||
"in vec4 v_Color;\n"
|
"in vec4 v_Color;\n"
|
||||||
@@ -140,13 +140,8 @@
|
|||||||
" }\n"
|
" }\n"
|
||||||
" if(u_TextureType == 2) {\n"// Paletted texture
|
" if(u_TextureType == 2) {\n"// Paletted texture
|
||||||
" vec4 texColor = texture(u_Texture, v_TexCoord);\n"
|
" vec4 texColor = texture(u_Texture, v_TexCoord);\n"
|
||||||
" uint index = uint(floor(texColor.r * 255.0));\n"
|
" int index = int(floor(texColor.r * 255.0));\n"
|
||||||
" uint palColor = u_Colors[index];\n"
|
" vec4 paletteColor = u_Colors[index];\n"
|
||||||
" float r = float((palColor >> 24) & 0xFFu) / 255.0;\n"
|
|
||||||
" float g = float((palColor >> 16) & 0xFFu) / 255.0;\n"
|
|
||||||
" float b = float((palColor >> 8) & 0xFFu) / 255.0;\n"
|
|
||||||
" float a = float((palColor >> 0) & 0xFFu) / 255.0;\n"
|
|
||||||
" vec4 paletteColor = vec4(r, g, b, a);\n"
|
|
||||||
" FragColor = paletteColor;\n"
|
" FragColor = paletteColor;\n"
|
||||||
" return;\n"
|
" return;\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
|
|||||||
@@ -78,6 +78,10 @@ errorret_t textureInitGL(
|
|||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||||
errorChain(errorGLCheck());
|
errorChain(errorGLCheck());
|
||||||
|
|
||||||
|
#ifdef DUSK_OPENGL_LEGACY
|
||||||
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|
||||||
|
#endif
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
glBindTexture(GL_TEXTURE_2D, 0);
|
||||||
errorChain(errorGLCheck());
|
errorChain(errorGLCheck());
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,9 @@
|
|||||||
#define glClearDepth(depth) glClearDepthf(depth)
|
#define glClearDepth(depth) glClearDepthf(depth)
|
||||||
#else
|
#else
|
||||||
#define GL_GLEXT_PROTOTYPES
|
#define GL_GLEXT_PROTOTYPES
|
||||||
#include <GL/gl.h>
|
#include <vitaGL.h>
|
||||||
#include <GL/glext.h>
|
|
||||||
|
#define GL_COLOR_INDEX8_EXT 0x80E5
|
||||||
|
|
||||||
|
// #include <GL/glext.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
# Copyright (c) 2026 Dominic Masters
|
|
||||||
#
|
|
||||||
# This software is released under the MIT License.
|
|
||||||
# https://opensource.org/licenses/MIT
|
|
||||||
|
|
||||||
# Includes
|
|
||||||
target_include_directories(${DUSK_LIBRARY_TARGET_NAME}
|
|
||||||
PUBLIC
|
|
||||||
${CMAKE_CURRENT_LIST_DIR}
|
|
||||||
)
|
|
||||||
|
|
||||||
# Subdirs
|
|
||||||
add_subdirectory(item)
|
|
||||||
add_subdirectory(map)
|
|
||||||
add_subdirectory(story)
|
|
||||||
add_subdirectory(script)
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
# Copyright (c) 2026 Dominic Masters
|
|
||||||
#
|
|
||||||
# This software is released under the MIT License.
|
|
||||||
# https://opensource.org/licenses/MIT
|
|
||||||
|
|
||||||
# Subdirs
|
|
||||||
add_subdirectory(module)
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
# Copyright (c) 2026 Dominic Masters
|
|
||||||
#
|
|
||||||
# This software is released under the MIT License.
|
|
||||||
# https://opensource.org/licenses/MIT
|
|
||||||
|
|
||||||
# Subdirectories
|
|
||||||
add_subdirectory(item)
|
|
||||||
add_subdirectory(map)
|
|
||||||
add_subdirectory(story)
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2026 Dominic Masters
|
|
||||||
*
|
|
||||||
* This software is released under the MIT License.
|
|
||||||
* https://opensource.org/licenses/MIT
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#include "script/module/item/moduleitem.h"
|
|
||||||
#include "script/module/story/modulestoryflag.h"
|
|
||||||
#include "script/module/map/modulemap.h"
|
|
||||||
|
|
||||||
#define SCRIPT_GAME_LIST \
|
|
||||||
{ .name = "item", .callback = moduleItem }, \
|
|
||||||
{ .name = "storyflag", .callback = moduleStoryFlag }, \
|
|
||||||
{ .name = "map", .callback = moduleMap },
|
|
||||||
@@ -4,3 +4,4 @@
|
|||||||
# https://opensource.org/licenses/MIT
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
add_subdirectory(run_python)
|
add_subdirectory(run_python)
|
||||||
|
add_subdirectory(env_to_h)
|
||||||
15
tools/env_to_h/CMakeLists.txt
Normal file
15
tools/env_to_h/CMakeLists.txt
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
# Copyright (c) 2026 Dominic Masters
|
||||||
|
#
|
||||||
|
# This software is released under the MIT License.
|
||||||
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
function(dusk_env_to_h INPUT_PATH OUTPUT_NAME_RELATIVE)
|
||||||
|
set(DUSK_DEFS_TARGET_NAME "DUSK_DEFS_${OUTPUT_NAME_RELATIVE}")
|
||||||
|
dusk_run_python(
|
||||||
|
${DUSK_DEFS_TARGET_NAME}
|
||||||
|
tools.env_to_h
|
||||||
|
--env "${CMAKE_CURRENT_LIST_DIR}/${INPUT_PATH}"
|
||||||
|
--output ${DUSK_GENERATED_HEADERS_DIR}/${OUTPUT_NAME_RELATIVE}
|
||||||
|
)
|
||||||
|
add_dependencies(${DUSK_LIBRARY_TARGET_NAME} ${DUSK_DEFS_TARGET_NAME})
|
||||||
|
endfunction()
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user