Compare commits
129 Commits
v2.0.0
..
88d6e25f1a
| Author | SHA1 | Date | |
|---|---|---|---|
|
88d6e25f1a
|
|||
|
3b2f25c6c4
|
|||
|
c1d4f7b9db
|
|||
|
a5e3fc57b3
|
|||
| 92c58f28b8 | |||
| d4dc1ac4c5 | |||
| bf1c41f3e1 | |||
| 92734168a2 | |||
| c0f5f06eb4 | |||
| b7bc5f2f0a | |||
| e8c0cfce1f | |||
| 1e396fb1a3 | |||
| 2b5839a4a8 | |||
| 0810f12949 | |||
| 04d105ca0e | |||
| 93e7aa5e19 | |||
| 3c2ad09870 | |||
| 1dbd2d6a5a | |||
| 4f21626136 | |||
| 50a9070d2d | |||
| 8ed34abb83 | |||
| f6ebd079f5 | |||
| 0f7083aa5b | |||
| 9baad8199a | |||
| 5eafc0bdba | |||
| c3c649dcdc | |||
| 1c4a84dffa | |||
| f727dae150 | |||
| 9b24ea3bb6 | |||
| 586180764e | |||
| a329ea73cc | |||
| 5418e28b73 | |||
| d773173ece | |||
| aa21baaaf2 | |||
| 0c0fcd697f | |||
| e07cfc502a | |||
| ab08a385a6 | |||
| 8642959d70 | |||
| 19ae6de1c7 | |||
| c40558bd54 | |||
| 700e878e61 | |||
| 9ee1df81e6 | |||
| 22ecaffe1b | |||
| 26285c54e9 | |||
| a52e2bec0e | |||
| 5583c7bc92 | |||
| b8e5309119 | |||
| fdc5450181 | |||
| 39a962c59b | |||
| b84bd99059 | |||
| caa0fd4db3 | |||
| daee3b4971 | |||
| 02a23cd415 | |||
| c2e653c059 | |||
| 676ac34ec3 | |||
| e229b34ad3 | |||
| 67f70f80d8 | |||
| 1e046d9dda | |||
| 383cdb3675 | |||
| 795910de69 | |||
| b344fd4141 | |||
| b3ff38af06 | |||
| 19c673767c | |||
| 15a2dbb854 | |||
| f4f527b877 | |||
| ce4e2f663f | |||
| 7736f00d71 | |||
| 878adf5dbb | |||
| d2da130771 | |||
| 588f45e870 | |||
| b19d4f42f5 | |||
| ea5849095e | |||
| e2790d93b6 | |||
| 7401926202 | |||
| 200a68e219 | |||
| 699e5f0ff5 | |||
| e63ae14792 | |||
| 87b983153a | |||
| cab934763f | |||
| 20d2291a88 | |||
| 4f6e55c0b0 | |||
| fbcb38d37a | |||
| a25594b95c | |||
| 86c0ab74f1 | |||
| 17d2d93d45 | |||
| f546604ba3 | |||
| d196290a3f | |||
| 481ccd0cf9 | |||
| e3726600fd | |||
| 8b8500a1c9 | |||
| 789c795c14 | |||
| a0be9022ff | |||
| 77c6702f80 | |||
| d54cba9e58 | |||
| 958ddb4ab7 | |||
| edff3a85d5 | |||
| 165cc4221e | |||
| cc42bbf56b | |||
| a340540d55 | |||
| d790349ab9 | |||
| 0cecbf0a7d | |||
| f46b058ecf | |||
| c833f93db2 | |||
| 6dc73982f9 | |||
| 1fe12962b8 | |||
| e359bcbe2b | |||
| 13f4b5e626 | |||
| 2ae1ccd761 | |||
| d7013f302b | |||
| b3fe92c996 | |||
| 822663f95e | |||
| 3f9bb33177 | |||
| fa173f1e87 | |||
| f08da7b358 | |||
| 945b9c462b | |||
| c9535412a7 | |||
| 2c41930cb2 | |||
| 2a4e2a2109 | |||
| 286b9e43a7 | |||
| f62eaff37b | |||
| 48fa642cef | |||
| cad720a399 | |||
| cf3f5b3443 | |||
| 48a0eec86b | |||
| 6a9f3c6683 | |||
| 325fea1a8b | |||
| ce00f58b89 | |||
| 5d4d2b0f06 | |||
| ca25a6de03 |
@@ -0,0 +1,70 @@
|
|||||||
|
name: Official build
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ master ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container: h4570/tyra
|
||||||
|
steps:
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y git make wget nodejs
|
||||||
|
|
||||||
|
- name: Set git safe directory
|
||||||
|
run: |
|
||||||
|
git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||||
|
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Compile engine
|
||||||
|
run: |
|
||||||
|
make clean all -C engine
|
||||||
|
|
||||||
|
- name: Compile tutorials
|
||||||
|
run: |
|
||||||
|
make clean all -C tutorials/01-hello
|
||||||
|
make clean all -C tutorials/02-sprite
|
||||||
|
make clean all -C tutorials/03-minecraft
|
||||||
|
make clean all -C tutorials/04-de_dust2
|
||||||
|
make clean all -C tutorials/05-animation
|
||||||
|
make clean all -C tutorials/06-audio
|
||||||
|
make clean all -C tutorials/07-lighting
|
||||||
|
make clean all -C tutorials/08-skybox-debug
|
||||||
|
make clean all -C tutorials/09-manual-mode
|
||||||
|
make clean all -C tutorials/10-sprite-sheet
|
||||||
|
|
||||||
|
- name: Compile demo
|
||||||
|
run: |
|
||||||
|
make clean all -C demo
|
||||||
|
|
||||||
|
- name: Upload tutorials
|
||||||
|
if: ${{ success() }}
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: tutorials-elf
|
||||||
|
path: |
|
||||||
|
tutorials/01-hello/bin
|
||||||
|
tutorials/02-sprite/bin
|
||||||
|
tutorials/03-minecraft/bin
|
||||||
|
tutorials/04-de_dust2/bin
|
||||||
|
tutorials/05-animation/bin
|
||||||
|
tutorials/06-audio/bin
|
||||||
|
tutorials/07-lighting/bin
|
||||||
|
tutorials/08-skybox-debug/bin
|
||||||
|
tutorials/09-manual-mode/bin
|
||||||
|
tutorials/10-sprite-sheet/bin
|
||||||
|
|
||||||
|
- name: Upload demo
|
||||||
|
if: ${{ success() }}
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: demo-elf
|
||||||
|
path: |
|
||||||
|
demo/bin
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
name: PR build check
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches: [ master ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container: h4570/tyra
|
||||||
|
steps:
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
|
apt-get update
|
||||||
|
apt-get install -y git make wget nodejs
|
||||||
|
|
||||||
|
- name: Set git safe directory
|
||||||
|
run: |
|
||||||
|
git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
||||||
|
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Compile engine
|
||||||
|
run: |
|
||||||
|
make clean all -C engine
|
||||||
|
|
||||||
|
- name: Compile tutorials
|
||||||
|
run: |
|
||||||
|
make clean all -C tutorials/01-hello
|
||||||
|
make clean all -C tutorials/02-sprite
|
||||||
|
make clean all -C tutorials/03-minecraft
|
||||||
|
make clean all -C tutorials/04-de_dust2
|
||||||
|
make clean all -C tutorials/05-animation
|
||||||
|
make clean all -C tutorials/06-audio
|
||||||
|
make clean all -C tutorials/07-lighting
|
||||||
|
make clean all -C tutorials/08-skybox-debug
|
||||||
|
make clean all -C tutorials/09-manual-mode
|
||||||
|
make clean all -C tutorials/10-sprite-sheet
|
||||||
|
|
||||||
|
- name: Compile demo
|
||||||
|
run: |
|
||||||
|
make clean all -C demo
|
||||||
|
|
||||||
|
- name: Get short SHA
|
||||||
|
id: slug
|
||||||
|
run: |
|
||||||
|
echo "SHA8=$(echo ${GITHUB_SHA} | cut -c1-8)" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Get branch
|
||||||
|
id: branch
|
||||||
|
run: |
|
||||||
|
BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/} | sed 's/refs\///g' | sed 's/\//_/g')
|
||||||
|
echo "BRANCH=${BRANCH_NAME}" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Upload build artifacts
|
||||||
|
if: ${{ success() }}
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: binaries-${{ env.SHA8 }}-${{ env.BRANCH }}
|
||||||
|
path: |
|
||||||
|
tutorials/01-hello/bin
|
||||||
|
tutorials/02-sprite/bin
|
||||||
|
tutorials/03-minecraft/bin
|
||||||
|
tutorials/04-de_dust2/bin
|
||||||
|
tutorials/05-animation/bin
|
||||||
|
tutorials/06-audio/bin
|
||||||
|
tutorials/07-lighting/bin
|
||||||
|
tutorials/08-skybox-debug/bin
|
||||||
|
tutorials/09-manual-mode/bin
|
||||||
|
tutorials/10-sprite-sheet/bin
|
||||||
|
demo/bin
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
#This is a modified version of the clang format check used on Open-PS2-Loader
|
||||||
|
name: PR C++ format check
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
paths:
|
||||||
|
- '**.hpp'
|
||||||
|
- '**.cpp'
|
||||||
|
- '**.'
|
||||||
|
- '**.h'
|
||||||
|
- './engine/inc/tyra'
|
||||||
|
- '.github/workflows/check-format.yml'
|
||||||
|
- '.clang-format'
|
||||||
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- '**.hpp'
|
||||||
|
- '**.cpp'
|
||||||
|
- '**.'
|
||||||
|
- '**.h'
|
||||||
|
- './engine/inc/tyra'
|
||||||
|
- '.github/workflows/check-format.yml'
|
||||||
|
- '.clang-format'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check-format:
|
||||||
|
name: Check clang format
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Install Node
|
||||||
|
run: |
|
||||||
|
apt-get update -y
|
||||||
|
apt-get install -y nodejs
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: DoozyX/clang-format-lint-action@v0.12
|
||||||
|
with:
|
||||||
|
source: '.'
|
||||||
|
extensions: 'hpp, cpp, h'
|
||||||
|
clangFormatVersion: 12
|
||||||
|
inplace: False
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
[submodule "template"]
|
||||||
|
path = template
|
||||||
|
url = https://git.ruifpb.pt/RuiFPB/tyra-linux-template
|
||||||
@@ -4,3 +4,4 @@
|
|||||||
/c_cpp_properties.json
|
/c_cpp_properties.json
|
||||||
/tasks.json
|
/tasks.json
|
||||||
/settings.json
|
/settings.json
|
||||||
|
/ps2dev-intellisense
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
{
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Docker PS2SDK (Linux)",
|
||||||
|
"includePath": [
|
||||||
|
"${workspaceFolder}/**",
|
||||||
|
"~/ps2dev-intellisense/ps2sdk/common/include/**",
|
||||||
|
"~/ps2dev-intellisense/ps2sdk/ee/include/**",
|
||||||
|
"~/ps2dev-intellisense/ps2sdk/iop/include/**",
|
||||||
|
"~/ps2dev-intellisense/ps2sdk/ports/include/**",
|
||||||
|
"~/ps2dev-intellisense/ee/include/**",
|
||||||
|
"~/ps2dev-intellisense/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/include/**",
|
||||||
|
"~/ps2dev-intellisense/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/include-fixed/**",
|
||||||
|
"~/ps2dev-intellisense/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/install-tools/include/**",
|
||||||
|
"~/ps2dev-intellisense/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/plugin/include/**",
|
||||||
|
"~/ps2dev-intellisense/ee/mips64r5900el-ps2-elf/include/**",
|
||||||
|
"~/ps2dev-intellisense/ee/mips64r5900el-ps2-elf/sys-include/**",
|
||||||
|
"~/ps2dev-intellisense/gsKit/include/**",
|
||||||
|
"~/ps2dev-intellisense/iop/lib/gcc/mipsel-ps2-elf/11.3.0/include/**",
|
||||||
|
"~/ps2dev-intellisense/iop/lib/gcc/mipsel-ps2-elf/11.3.0/install-tools/include/**",
|
||||||
|
"~/ps2dev-intellisense/iop/lib/gcc/mipsel-ps2-elf/11.3.0/plugin/include/**",
|
||||||
|
"~/ps2dev-intellisense/iop/lib/gcc/mipsel-ps2-elf/11.3.0/include-fixed/**",
|
||||||
|
"~/ps2dev-intellisense/iop/lib/gcc/mipsel-ps2-irx/11.3.0/include/**",
|
||||||
|
"~/ps2dev-intellisense/iop/lib/gcc/mipsel-ps2-irx/11.3.0/install-tools/include/**",
|
||||||
|
"~/ps2dev-intellisense/iop/lib/gcc/mipsel-ps2-irx/11.3.0/plugin/include/**",
|
||||||
|
"~/ps2dev-intellisense/iop/lib/gcc/mipsel-ps2-irx/11.3.0/include-fixed/**"
|
||||||
|
],
|
||||||
|
"defines": [
|
||||||
|
"_EE",
|
||||||
|
"_IOP",
|
||||||
|
"__SPU__",
|
||||||
|
"INTELLISENSE"
|
||||||
|
],
|
||||||
|
"cppStandard": "c++20",
|
||||||
|
"compilerPath": "", // Should be empty
|
||||||
|
"intelliSenseMode": "linux-gcc-x86",
|
||||||
|
"configurationProvider": "ms-vscode.cpptools"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version": 4
|
||||||
|
}
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"buildDirectory": "./",
|
"buildDirectory": "demo",
|
||||||
"C_Cpp.default.intelliSenseMode": "gcc-x86",
|
"C_Cpp.default.intelliSenseMode": "gcc-x86",
|
||||||
"files.associations": {
|
"files.associations": {
|
||||||
"*.vcl": "asm-collection",
|
"*.vcl": "asm-collection",
|
||||||
+11
-22
@@ -18,12 +18,12 @@
|
|||||||
{
|
{
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"label": "1. Copy source code to docker volume",
|
"label": "1. Copy source code to docker volume",
|
||||||
"command": "docker exec -t tyra-game-compiler sh -c 'rsync -ac --delete --exclude \".git\" --exclude \".vscode\" --exclude \"*obj*/**\" --exclude \"*bin*/**\" /host/ /src/'"
|
"command": "docker exec -t tyra-compiler sh -c 'rsync -ac --delete --exclude \".git\" --exclude \"docs\" --exclude \".vscode\" --exclude \"tools\" --exclude \"obj\" --exclude \"bin\" /host/ /src/'"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"label": "2. Compile via docker container",
|
"label": "2. Compile via docker container",
|
||||||
"command": "docker exec -t tyra-game-compiler sh -c 'cd ${config:buildDirectory} && make'",
|
"command": "docker exec -t tyra-compiler sh -c 'cd ${config:buildDirectory} && make build-engine all'",
|
||||||
"problemMatcher": {
|
"problemMatcher": {
|
||||||
"base": "$gcc",
|
"base": "$gcc",
|
||||||
"fileLocation": [
|
"fileLocation": [
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
{
|
{
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"label": "3. Copy binaries to host",
|
"label": "3. Copy binaries to host",
|
||||||
"command": "docker exec -t tyra-game-compiler sh -c 'rsync -zac --include=\"*/\" --include=\"*bin*/**\" --exclude=\"*\" /src/ /host/'",
|
"command": "docker exec -t tyra-compiler sh -c 'rsync -zac --include=\"*/\" --include=\"bin/**\" --exclude=\"*\" /src/ /host/'"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
"options": {
|
"options": {
|
||||||
"cwd": "${config:buildDirectory}"
|
"cwd": "${config:buildDirectory}"
|
||||||
},
|
},
|
||||||
"command": "./run.ps1"
|
"command": "./run.sh"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
@@ -50,27 +50,22 @@
|
|||||||
"dependsOn": [
|
"dependsOn": [
|
||||||
"1. Copy source code to docker volume"
|
"1. Copy source code to docker volume"
|
||||||
],
|
],
|
||||||
"command": "docker exec -t tyra-game-compiler sh -c 'adpenc ${input:wav2adpcmSource} ${input:wav2adpcmTarget} && rsync -zac /src/${input:wav2adpcmTarget} /host/${input:wav2adpcmTarget}'"
|
"command": "docker exec -t tyra-compiler sh -c 'adpenc ${input:wav2adpcmSource} ${input:wav2adpcmTarget} && rsync -zac /src/${input:wav2adpcmTarget} /host/${input:wav2adpcmTarget}'"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"label": "Cleanup",
|
"label": "Cleanup",
|
||||||
"command": "docker exec -t tyra-game-compiler sh -c 'rm -rf /src/*'"
|
"command": "docker exec -t tyra-compiler sh -c 'rm -rf /src/*'"
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "shell",
|
|
||||||
"label": "Update Tyra",
|
|
||||||
"command": "docker exec -t tyra-game-compiler sh -c 'rm -rf /tyra && mkdir -p /tyra && git clone https://github.com/h4570/tyra.git /tyra && cd /tyra && git checkout ${input:tyraBranch} && cd engine && make'"
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"label": "Send to PS2",
|
"label": "Send to PS2",
|
||||||
"command": "docker exec -t tyra-game-compiler sh -c 'cd ${config:buildDirectory}/bin && killall -v ps2client || true && ps2client -h ${input:ps2Ip} reset && ps2client -h ${input:ps2Ip} reset && ps2client -h ${input:ps2Ip} execee host:$(find . -maxdepth 1 -type f -name \"*.elf\")'"
|
"command": "docker exec -t tyra-compiler sh -c 'cd ${config:buildDirectory}/bin && killall -v ps2client || true && ps2client -h ${input:ps2Ip} reset && ps2client -h ${input:ps2Ip} reset && ps2client -h ${input:ps2Ip} execee host:$(find . -maxdepth 1 -type f -name \"*.elf\")'"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"label": "Open PS2 output logger",
|
"label": "Open PS2 output logger",
|
||||||
"command": "docker stop ps2-logs || $true && docker run -t --rm --name=ps2-logs -p ${input:local2Ip}:18194:18194/udp h4570/tyra sh -c 'ps2client -h ${input:ps2Ip} listen'",
|
"command": "docker stop ps2-logs || true && docker run -t --rm --name=ps2-logs -p ${input:local2Ip}:18194:18194/udp h4570/tyra sh -c 'ps2client -h ${input:ps2Ip} listen'",
|
||||||
"runOptions": {
|
"runOptions": {
|
||||||
"instanceLimit": 1
|
"instanceLimit": 1
|
||||||
},
|
},
|
||||||
@@ -92,20 +87,20 @@
|
|||||||
{
|
{
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"label": "[Debug] Copy obj directory to host",
|
"label": "[Debug] Copy obj directory to host",
|
||||||
"command": "docker exec -t tyra-game-compiler sh -c 'rsync -zac --include=\"*/\" --include=\"obj/**\" --exclude=\"*\" /src/ /host/'"
|
"command": "docker exec -t tyra-compiler sh -c 'rsync -zac --include=\"*/\" --include=\"obj/**\" --exclude=\"*\" /src/ /host/'"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"inputs": [
|
"inputs": [
|
||||||
{
|
{
|
||||||
"id": "wav2adpcmSource",
|
"id": "wav2adpcmSource",
|
||||||
"description": "Source file path (ex. ):",
|
"description": "Source file path (ex. ):",
|
||||||
"default": "res/sound.wav",
|
"default": "demo/res/sound.wav",
|
||||||
"type": "promptString"
|
"type": "promptString"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "wav2adpcmTarget",
|
"id": "wav2adpcmTarget",
|
||||||
"description": "Target file path (ex. ):",
|
"description": "Target file path (ex. ):",
|
||||||
"default": "res/sound.adpcm",
|
"default": "demo/res/sound.adpcm",
|
||||||
"type": "promptString"
|
"type": "promptString"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -119,12 +114,6 @@
|
|||||||
"description": "Local ip address:",
|
"description": "Local ip address:",
|
||||||
"default": "192.168.1.245",
|
"default": "192.168.1.245",
|
||||||
"type": "promptString"
|
"type": "promptString"
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "tyraBranch",
|
|
||||||
"description": "Tyra branch:",
|
|
||||||
"default": "master",
|
|
||||||
"type": "promptString"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
+3
-3
@@ -42,7 +42,7 @@
|
|||||||
"options": {
|
"options": {
|
||||||
"cwd": "${config:buildDirectory}"
|
"cwd": "${config:buildDirectory}"
|
||||||
},
|
},
|
||||||
"command": "./run.ps1"
|
"command": "Start-Job { ./run.ps1 } | Receive-Job -Wait"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
@@ -60,12 +60,12 @@
|
|||||||
{
|
{
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"label": "Send to PS2",
|
"label": "Send to PS2",
|
||||||
"command": "docker exec -t tyra-compiler sh -c 'cd ${config:buildDirectory}/bin && killall -v ps2client || true && ps2client -h ${input:ps2Ip} reset && ps2client -h ${input:ps2Ip} reset && ps2client -h ${input:ps2Ip} execee host:$(find . -maxdepth 1 -type f -name \"*.elf\")'"
|
"command": "docker exec -t tyra-compiler sh -c 'cd ${config:buildDirectory}/bin && killall -v ps2client || $true && ps2client -h ${input:ps2Ip} reset && ps2client -h ${input:ps2Ip} reset && ps2client -h ${input:ps2Ip} execee host:$(find . -maxdepth 1 -type f -name \"*.elf\")'"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"label": "Open PS2 output logger",
|
"label": "Open PS2 output logger",
|
||||||
"command": "docker stop ps2-logs || true && docker run -t --rm --name=ps2-logs -p ${input:local2Ip}:18194:18194/udp h4570/tyra sh -c 'ps2client -h ${input:ps2Ip} listen'",
|
"command": "docker stop ps2-logs || $true && docker run -t --rm --name=ps2-logs -p ${input:local2Ip}:18194:18194/udp h4570/tyra sh -c 'ps2client -h ${input:ps2Ip} listen'",
|
||||||
"runOptions": {
|
"runOptions": {
|
||||||
"instanceLimit": 1
|
"instanceLimit": 1
|
||||||
},
|
},
|
||||||
|
|||||||
Vendored
+2
-1
@@ -3,6 +3,7 @@
|
|||||||
"ms-vscode.cpptools-extension-pack",
|
"ms-vscode.cpptools-extension-pack",
|
||||||
"ryzngard.vscode-header-source",
|
"ryzngard.vscode-header-source",
|
||||||
"maziac.asm-code-lens",
|
"maziac.asm-code-lens",
|
||||||
"dmnsgn.vscode-wavefront"
|
"dmnsgn.vscode-wavefront",
|
||||||
|
"spmeesseman.vscode-taskexplorer"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
+1
-2
@@ -31,8 +31,7 @@ RUN make
|
|||||||
# Download VCL
|
# Download VCL
|
||||||
RUN mkdir -p /temp/vcl
|
RUN mkdir -p /temp/vcl
|
||||||
WORKDIR "/temp/vcl"
|
WORKDIR "/temp/vcl"
|
||||||
RUN wget http://apgcglz.cluster028.hosting.ovh.net/tyra/vcl.zip
|
RUN wget https://github.com/h4570/tyra/raw/master/assets/vcl
|
||||||
RUN unzip vcl.zip
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@ IRXEMBEDDEDEXT := irx-em
|
|||||||
CFLAGS += -D_EE -Wall -O3
|
CFLAGS += -D_EE -Wall -O3
|
||||||
LINKFLAGS += -O3 -Wl,-zmax-page-size=128
|
LINKFLAGS += -O3 -Wl,-zmax-page-size=128
|
||||||
ASFLAGS += -O3
|
ASFLAGS += -O3
|
||||||
LIB += -lstdc++ -ldma -lpacket2 -lgraph -ldraw -lmath3d -lpng -lz -lpad -laudsrv -lpatches -lcdvd
|
LIB += -lstdc++ -ldma -lpacket2 -lgraph -ldraw -lmath3d -lpng -ldebug -lz -lpad -laudsrv -lpatches -lcdvd
|
||||||
INC += -I$(PS2DEV)/ps2sdk/ee/include -I$(PS2DEV)/ps2sdk/common/include -I$(PS2DEV)/ps2sdk/ports/include
|
INC += -I$(PS2DEV)/ps2sdk/ee/include -I$(PS2DEV)/ps2sdk/common/include -I$(PS2DEV)/ps2sdk/ports/include
|
||||||
|
|
||||||
#---------------------------------------------------------------------------------
|
#---------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
[](https://www.codacy.com/gh/h4570/tyra/dashboard?utm_source=github.com&utm_medium=referral&utm_content=h4570/tyra&utm_campaign=Badge_Grade)
|
||||||
[![Contributors][contributors-shield]][contributors-url]
|
[![Contributors][contributors-shield]][contributors-url]
|
||||||
[![MIT License][license-shield]][license-url]
|
[![MIT License][license-shield]][license-url]
|
||||||
[](https://discord.gg/NhhTmg3Gm5)
|
[](https://discord.gg/NhhTmg3Gm5)
|
||||||
@@ -6,14 +7,16 @@
|
|||||||
<br />
|
<br />
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://github.com/h4570/tyra">
|
<a href="https://github.com/h4570/tyra">
|
||||||
<img src="http://apgcglz.cluster028.hosting.ovh.net/tyra/github-splash.png" alt="Logo" width="100%" height="auto">
|
<img src="https://raw.githubusercontent.com/h4570/tyra/master/assets/github-splash.png" alt="Logo" width="100%" height="auto">
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<h3 align="center">Tyra - 2.0.0</h3>
|
<h3 align="center">Tyra</h3>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
Open source game engine for PlayStation 2™
|
Open source game engine for PlayStation 2™
|
||||||
<br />
|
<br />
|
||||||
|
<a href="https://www.youtube.com/watch?v=DGR4vWDjkmc"><strong>Showcase video »</strong></a>
|
||||||
|
|
||||||
<a href="https://youtube.com/playlist?list=PLdQVLBcXRRWvtMi-OqccDWLTEFEisD5RH"><strong>YouTube tutorials »</strong></a>
|
<a href="https://youtube.com/playlist?list=PLdQVLBcXRRWvtMi-OqccDWLTEFEisD5RH"><strong>YouTube tutorials »</strong></a>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
@@ -24,51 +27,50 @@
|
|||||||
</p>
|
</p>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
[](https://github.com/h4570/tyra/stargazers)
|
|
||||||
|
|
||||||
## Table of Contents
|
## Table of Contents
|
||||||
|
|
||||||
* [About the project](#about-the-project)
|
* [About the project](#about-the-project)
|
||||||
* [Description](#description)
|
* [Description](#description)
|
||||||
* [Tutorials](#tutorials)
|
* [Tutorials](#tutorials)
|
||||||
* [Features](#features)
|
* [Features](#features)
|
||||||
* [Branches](#branches)
|
|
||||||
* [Contributing](#contributing)
|
* [Contributing](#contributing)
|
||||||
|
* [Games](#games)
|
||||||
* [License](#license)
|
* [License](#license)
|
||||||
* [Built With](#built-with)
|
* [Built With](#built-with)
|
||||||
* [Acronyms](#acronyms)
|
* [Acronyms](#acronyms)
|
||||||
* [Thanks](#thanks)
|
* [Credits](#credits)
|
||||||
|
|
||||||
<br />
|
|
||||||
|
|
||||||
## About the Project
|
## About the Project
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="http://apgcglz.cluster028.hosting.ovh.net/tyra/tyra_code.gif" alt="Sample code" width="500" height="auto">
|
<img src="https://raw.githubusercontent.com/h4570/tyra/master/assets/tyra_code.gif" alt="Sample code" width="500" height="auto">
|
||||||
<img src="http://apgcglz.cluster028.hosting.ovh.net/tyra/showcase.gif " alt="Sample game" width="500" height="auto">
|
<img src="https://raw.githubusercontent.com/h4570/tyra/master/assets/showcase.gif " alt="Sample game" width="500" height="auto">
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
---
|
---
|
||||||
### Description
|
### Description
|
||||||
Tyra is a project that allows you to easily create games for the PlayStation 2 console.
|
Tyra is a project that allows you to easily create games for the PlayStation 2 console.
|
||||||
When I tried to make a game for PS2 a few years ago, I realized how many things had to be done to tame this exotic console architecture.
|
When I tried to make a game for PS2 a few years ago, I realized how many things had to be done to tame this exotic console architecture.
|
||||||
Decision was simple - I need to create an engine which will handle 3D file loading, 2D/3D rendering, animation, audio, handling between PS2 CPUs, synchronization and it should be simple as possible - so people with no experience can create a simple game in a few hours.
|
Decision was simple - I need to create an engine which will handle 3D file loading, 2D/3D rendering, animation, audio, handling between PS2 CPUs, synchronization.. It should be simple as possible - so people with no experience can create a simple game in a few hours.
|
||||||
**And that's what Tyra is all about.**
|
**And that's what Tyra is all about.**
|
||||||
|
|
||||||
### Tutorials
|
### Tutorials
|
||||||
* Setup environment - [Text tutorial](https://github.com/h4570/tyra/tree/master/docs/install) or [Video (soon)](https://www.youtube.com/playlist?list=PLdQVLBcXRRWvtMi-OqccDWLTEFEisD5RH)
|
* 01 - Setup environment - [Text tutorial](https://github.com/h4570/tyra/tree/master/docs/install) or [Video](https://www.youtube.com/watch?v=9IXOU1SPdzc)
|
||||||
* Cook game assets - [Video (soon)](https://www.youtube.com/playlist?list=PLdQVLBcXRRWvtMi-OqccDWLTEFEisD5RH)
|
* 02 - Cooking game assets - [Video](https://www.youtube.com/watch?v=hpVDeTTLyjI)
|
||||||
* Create game from template - [Video (soon)](https://www.youtube.com/playlist?list=PLdQVLBcXRRWvtMi-OqccDWLTEFEisD5RH)
|
* 03 - Create a game repository - [Video](https://www.youtube.com/watch?v=DKfIKar3GUM)
|
||||||
|
* 04 - Run game from USB in PS2 - [Video](https://www.youtube.com/watch?v=ZX8fTQqiNho)
|
||||||
---
|
---
|
||||||
* 01 - [Code](https://github.com/h4570/tyra/tree/master/tutorials/01-hello), [Video (soon)](https://www.youtube.com/playlist?list=PLdQVLBcXRRWvtMi-OqccDWLTEFEisD5RH) - Hello world
|
* 01 - [Code](https://github.com/h4570/tyra/tree/master/tutorials/01-hello) - Hello world
|
||||||
* 02 - [Code](https://github.com/h4570/tyra/tree/master/tutorials/02-sprite), [Video (soon)](https://www.youtube.com/playlist?list=PLdQVLBcXRRWvtMi-OqccDWLTEFEisD5RH) - 2D rendering
|
* 02 - [Code](https://github.com/h4570/tyra/tree/master/tutorials/02-sprite) - 2D rendering
|
||||||
* 03 - [Code](https://github.com/h4570/tyra/tree/master/tutorials/03-minecraft), [Video (soon)](https://www.youtube.com/playlist?list=PLdQVLBcXRRWvtMi-OqccDWLTEFEisD5RH) - 3D minecraft blocks
|
* 03 - [Code](https://github.com/h4570/tyra/tree/master/tutorials/03-minecraft) - 3D minecraft blocks
|
||||||
* 04 - [Code](https://github.com/h4570/tyra/tree/master/tutorials/04-de_dust2), [Video (soon)](https://www.youtube.com/playlist?list=PLdQVLBcXRRWvtMi-OqccDWLTEFEisD5RH) - `de_dust2.obj` rendering
|
* 04 - [Code](https://github.com/h4570/tyra/tree/master/tutorials/04-de_dust2) - `de_dust2.obj` rendering
|
||||||
* 05 - [Code](https://github.com/h4570/tyra/tree/master/tutorials/05-animation), [Video (soon)](https://www.youtube.com/playlist?list=PLdQVLBcXRRWvtMi-OqccDWLTEFEisD5RH) - 3D animation
|
* 05 - [Code](https://github.com/h4570/tyra/tree/master/tutorials/05-animation) - 3D animation
|
||||||
* 06 - [Code](https://github.com/h4570/tyra/tree/master/tutorials/06-audio), [Video (soon)](https://www.youtube.com/playlist?list=PLdQVLBcXRRWvtMi-OqccDWLTEFEisD5RH) - Background music and sound effects
|
* 06 - [Code](https://github.com/h4570/tyra/tree/master/tutorials/06-audio) - Background music and sound effects
|
||||||
* 07 - [Code](https://github.com/h4570/tyra/tree/master/tutorials/07-lighting), [Video (soon)](https://www.youtube.com/playlist?list=PLdQVLBcXRRWvtMi-OqccDWLTEFEisD5RH) - Static lightmap and dynamic directional lights
|
* 07 - [Code](https://github.com/h4570/tyra/tree/master/tutorials/07-lighting) - Static lightmap and dynamic directional lights
|
||||||
* 08 - [Code](https://github.com/h4570/tyra/tree/master/tutorials/08-skybox-debug), [Video (soon)](https://www.youtube.com/playlist?list=PLdQVLBcXRRWvtMi-OqccDWLTEFEisD5RH) - Skybox and debug rendering
|
* 08 - [Code](https://github.com/h4570/tyra/tree/master/tutorials/08-skybox-debug) - Skybox and debug rendering
|
||||||
* 09 - [Code](https://github.com/h4570/tyra/tree/master/tutorials/09-manual-mode), [Video (soon)](https://www.youtube.com/playlist?list=PLdQVLBcXRRWvtMi-OqccDWLTEFEisD5RH) - Manual rendering (a'la OpenGL)
|
* 09 - [Code](https://github.com/h4570/tyra/tree/master/tutorials/09-manual-mode) - Manual rendering (a'la OpenGL)
|
||||||
|
* 10 - [Code](https://github.com/h4570/tyra/tree/master/tutorials/10-sprite-sheet) - Sprite sheet (font)
|
||||||
|
* 11 - [Code](https://github.com/h4570/tyra/tree/master/tutorials/11-texture-region-repeat) - Texture repeating
|
||||||
|
* Demo game - [Code](https://github.com/h4570/tyra/tree/master/demo)
|
||||||
---
|
---
|
||||||
|
|
||||||
### Features
|
### Features
|
||||||
@@ -85,25 +87,21 @@ Decision was simple - I need to create an engine which will handle 3D file loadi
|
|||||||
* Precise - culling only visible parts of mesh
|
* Precise - culling only visible parts of mesh
|
||||||
* Clipping:
|
* Clipping:
|
||||||
* Standard "fake", but fast PS2 clipping done in `VU1`
|
* Standard "fake", but fast PS2 clipping done in `VU1`
|
||||||
* Software triangle done in `EE Core`
|
* Software clipping done in `EE Core`
|
||||||
* Optimized math functions via `VU0` coprocessor
|
* Optimized math functions via `VU0` coprocessor
|
||||||
* Background music and sound effects support
|
* Background music and sound effects support
|
||||||
* Pad support
|
* Pad support
|
||||||
|
* USB support
|
||||||
|
* Memory card support
|
||||||
* `.wav` Audio file support
|
* `.wav` Audio file support
|
||||||
* `.obj` 3D file support
|
* `.obj` 3D file support
|
||||||
* `.md2` 3D file support
|
* `.md2` 3D file support
|
||||||
* `.png` Texture file support
|
* `.png` Texture file support
|
||||||
|
|
||||||
### Branches
|
## Contributing
|
||||||
* `master` - stable releases - tested on PS2 & PCSX2.
|
|
||||||
* `develop` - daily builds.
|
|
||||||
|
|
||||||
See the [open issues](https://github.com/h4570/tyra/issues) for a list of proposed features (and known issues).
|
See the [open issues](https://github.com/h4570/tyra/issues) for a list of proposed features (and known issues).
|
||||||
|
|
||||||
<br />
|
|
||||||
|
|
||||||
## Contributing
|
|
||||||
|
|
||||||
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are **greatly appreciated**.
|
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are **greatly appreciated**.
|
||||||
|
|
||||||
1. Fork the Project
|
1. Fork the Project
|
||||||
@@ -112,22 +110,26 @@ Contributions are what make the open source community such an amazing place to b
|
|||||||
4. Push to the Branch (`git push origin feature/amazing-feature`)
|
4. Push to the Branch (`git push origin feature/amazing-feature`)
|
||||||
5. Open a Pull Request
|
5. Open a Pull Request
|
||||||
|
|
||||||
<br />
|
## Games
|
||||||
|
|
||||||
|
List of games developed with Tyra.
|
||||||
|
If you created one, please contact me - I will add it to the list :)
|
||||||
|
|
||||||
|
* [Tyracraft](https://github.com/Wellinator/tyracraft) by [Wellinator](https://github.com/Wellinator)
|
||||||
|
* [Game with car](https://github.com/freebytego/gwc-ps2) by [freebytego](https://github.com/freebytego)
|
||||||
|
* [Rock, paper, scissors](https://github.com/GuidoDQR/my-ps2-game) by [GuidoDQR](https://github.com/GuidoDQR)
|
||||||
|
* [TyraTale](https://github.com/Br4k2n/TyraTale) by [Br4k2n](https://github.com/Br4k2n)
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
Distributed under the Apache License 2.0 License. See `LICENSE` for more information.
|
Distributed under the Apache License 2.0 License. See `LICENSE` for more information.
|
||||||
|
|
||||||
<br />
|
|
||||||
|
|
||||||
## Built With
|
## Built With
|
||||||
|
|
||||||
* [PS2DEV](https://github.com/ps2dev/ps2dev)
|
* [PS2DEV](https://github.com/ps2dev/ps2dev)
|
||||||
* [VCLPP](https://github.com/glampert/vclpp)
|
* [VCLPP](https://github.com/glampert/vclpp)
|
||||||
* Sony VCL
|
* Sony VCL
|
||||||
|
|
||||||
<br />
|
|
||||||
|
|
||||||
## Acronyms
|
## Acronyms
|
||||||
* EE (Emotion Engine) - whole set of processors and subsystems that make up the PlayStation 2
|
* EE (Emotion Engine) - whole set of processors and subsystems that make up the PlayStation 2
|
||||||
* EE Core - main PS2 CPU (c++ done here)
|
* EE Core - main PS2 CPU (c++ done here)
|
||||||
@@ -136,28 +138,26 @@ Distributed under the Apache License 2.0 License. See `LICENSE` for more informa
|
|||||||
* VU1 - programmable (ASM) vector processor, which is similar to vertex shader. Accessed via DMA.
|
* VU1 - programmable (ASM) vector processor, which is similar to vertex shader. Accessed via DMA.
|
||||||
* IOP - I/O processor which enables access to peripheral devices, such the game controller
|
* IOP - I/O processor which enables access to peripheral devices, such the game controller
|
||||||
|
|
||||||
<br />
|
|
||||||
|
|
||||||
## Credits
|
## Credits
|
||||||
|
|
||||||
Without these guys, Tyra would not happen:
|
Without these guys, Tyra would not happen:
|
||||||
* Dr Henry Fortuna - for code sources, PS2 academy tutorials
|
* [Dr Henry Fortuna](http://ps2-edu.tensioncore.com/index.html) - for code sources, PS2 academy tutorials
|
||||||
* Rick Gaiser, fjtrujy - for maintaining PS2DEV
|
* Whole [PS2DEV](https://github.com/ps2dev) team, and specially to [Rick Gaiser](https://github.com/rickgaiser), [fjtrujy](https://github.com/fjtrujy) - for a lot of good tips!
|
||||||
* Wellington Carvalho - for testing, contributing to Tyra and sharing cool ideas!
|
* [Wellington Carvalho](https://github.com/Wellinator), [André Guilheme](https://github.com/Wolf3s), [Matías Israelson](https://github.com/israpps), [Guido Diego Quispe Robles](https://github.com/israpps) - for testing, contributing to Tyra and sharing cool ideas!
|
||||||
* Lukasz D.K. - for huge archive of PS2 stuff
|
* [Leonardo Ono](https://github.com/leonardo-ono) - for software renderer example (with clipping!)
|
||||||
* Guilherme Lampert - for code sources
|
* [Lukasz D.K.](https://github.com/lukaszdk) - for huge archive of PS2 stuff
|
||||||
* Jesper Svennevid, Daniel Collin - for openvcl's code samples
|
* [Guilherme Lampert](https://github.com/glampert) - for code sources
|
||||||
* Whole PS2DEV team
|
* [Jesper Svennevid](https://github.com/jsvennevid), [Daniel Collin](https://github.com/emoon) - for openvcl's code samples
|
||||||
* Manieq - for nice splash screens!
|
* [Manieq](https://www.facebook.com/mvnieq) - for nice splash screens!
|
||||||
* And so many other guys. Thanks!
|
* And so many other guys. Thanks!
|
||||||
|
|
||||||
Project Link: [https://github.com/h4570/tyra](https://github.com/h4570/tyra)
|
Project Link: [https://github.com/h4570/tyra](https://github.com/h4570/tyra)
|
||||||
Sandro Sobczyński - sandro.sobczynski@gmail.com
|
Sandro Sobczyński - sandro.sobczynski@gmail.com (<a href="https://hasto.pl">hasto.pl</a>)
|
||||||
[![LinkedIn][linkedin-shield]](https://linkedin.com/in/sandro-sobczyński-28820b15a)
|
[![LinkedIn][linkedin-shield]](https://linkedin.com/in/sandro-sobczyński-28820b15a)
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
<a href="https://github.com/h4570/tyra">
|
<a href="https://github.com/h4570/tyra">
|
||||||
<img src="http://apgcglz.cluster028.hosting.ovh.net/tyra/github-splash2.png" alt="Logo" width="100%" height="auto">
|
<img src="https://raw.githubusercontent.com/h4570/tyra/master/assets/github-splash2.png" alt="Logo" width="100%" height="auto">
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
[contributors-shield]: https://img.shields.io/github/contributors/h4570/tyra.svg?style=flat-square
|
[contributors-shield]: https://img.shields.io/github/contributors/h4570/tyra.svg?style=flat-square
|
||||||
|
|||||||
-23
@@ -1,23 +0,0 @@
|
|||||||
------------ Tyra's v2.0 roadmap to publish on GitHub ------------
|
|
||||||
- [General] Readme Credits: clipping, obj loader
|
|
||||||
- [Video] How to setup environment
|
|
||||||
- [Video] How to work with Tyra
|
|
||||||
- [Video] How to create own game
|
|
||||||
- [Video] How to cook assets (audio, textures, obj)
|
|
||||||
- [Video] Tutorial videos
|
|
||||||
- [Video] How to run game from USB
|
|
||||||
|
|
||||||
------------ Github issues for Tyra v2 ------------
|
|
||||||
- [Demo] BBox constructors
|
|
||||||
- [General] Add cpp lint checker in GitHub / static code analysis
|
|
||||||
- [General] Smart pointers and std::array instead of raw pointers
|
|
||||||
- [General] Control generated id to avoid duplication. Maybe Just increment from 0? Add interface IIdentificable?
|
|
||||||
- [renderer] fog
|
|
||||||
- [General] CI in Github via docker image
|
|
||||||
- [MD2] Refactor
|
|
||||||
- [2D] Add zbuffer support (z-index)
|
|
||||||
- [3DUtility] Add zbuffer support (z-index), cupMesh->translation.translateZ(10.0F) - wylaczyc zeby widziec problem
|
|
||||||
- [2D] Fixed font support
|
|
||||||
- [File] Async file loading
|
|
||||||
- [tyrdat] Custom 3D data file with precalculated bboxes with support of async loading
|
|
||||||
- [Renderer] Interlacing, and then 640x448 resolution
|
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 99 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 43 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.6 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 90 KiB |
BIN
Binary file not shown.
@@ -12,6 +12,6 @@
|
|||||||
|
|
||||||
namespace Demo {
|
namespace Demo {
|
||||||
|
|
||||||
const bool IS_REAL_PS2 = false;
|
const bool IS_REAL_PS2_VIA_USB = false;
|
||||||
|
|
||||||
} // namespace Demo
|
} // namespace Demo
|
||||||
|
|||||||
Executable
+4
@@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
SCRIPT_DIR=$(dirname "$(readlink -f "$0")")
|
||||||
|
cd "$SCRIPT_DIR" || exit 1
|
||||||
|
../linux-pcsx2.sh
|
||||||
+1
-1
@@ -15,7 +15,7 @@
|
|||||||
int main() {
|
int main() {
|
||||||
Tyra::EngineOptions options;
|
Tyra::EngineOptions options;
|
||||||
|
|
||||||
if (Demo::IS_REAL_PS2) {
|
if (Demo::IS_REAL_PS2_VIA_USB) {
|
||||||
options.writeLogsToFile = true;
|
options.writeLogsToFile = true;
|
||||||
options.loadUsbDriver = true;
|
options.loadUsbDriver = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ EnemyManager::EnemyManager(Engine* engine, const Heightmap& heightmap) {
|
|||||||
|
|
||||||
auto data = loader.load(FileUtils::fromCwd("game/models/zombie/zombie.obj"),
|
auto data = loader.load(FileUtils::fromCwd("game/models/zombie/zombie.obj"),
|
||||||
objOptions);
|
objOptions);
|
||||||
data->normalsEnabled = false;
|
data->loadNormals = false;
|
||||||
motherMesh = new DynamicMesh(data.get());
|
motherMesh = new DynamicMesh(data.get());
|
||||||
|
|
||||||
bodyTexture = textureRepo->add(
|
bodyTexture = textureRepo->add(
|
||||||
@@ -45,7 +45,7 @@ EnemyManager::EnemyManager(Engine* engine, const Heightmap& heightmap) {
|
|||||||
auto* death = engine->audio.adpcm.load(
|
auto* death = engine->audio.adpcm.load(
|
||||||
FileUtils::fromCwd("game/models/zombie/death.adpcm"));
|
FileUtils::fromCwd("game/models/zombie/death.adpcm"));
|
||||||
|
|
||||||
const int enemyCount = IS_REAL_PS2 ? 8 : 12;
|
const int enemyCount = IS_REAL_PS2_VIA_USB ? 8 : 12;
|
||||||
for (int i = 0; i < enemyCount; i++) {
|
for (int i = 0; i < enemyCount; i++) {
|
||||||
EnemyInfo info;
|
EnemyInfo info;
|
||||||
info.adpcmChannel = 9 + i;
|
info.adpcmChannel = 9 + i;
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ void GameState::onStart() {
|
|||||||
|
|
||||||
engine->audio.song.setVolume(85);
|
engine->audio.song.setVolume(85);
|
||||||
|
|
||||||
if (IS_REAL_PS2) engine->renderer.setFrameLimit(false);
|
if (IS_REAL_PS2_VIA_USB) engine->renderer.setFrameLimit(false);
|
||||||
|
|
||||||
initialized = true;
|
initialized = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ Weapon::Weapon(Engine* engine) {
|
|||||||
auto* repo = &engine->renderer.core.texture.repository;
|
auto* repo = &engine->renderer.core.texture.repository;
|
||||||
auto data =
|
auto data =
|
||||||
loader.load(FileUtils::fromCwd("game/models/ak47/ak47.obj"), objOptions);
|
loader.load(FileUtils::fromCwd("game/models/ak47/ak47.obj"), objOptions);
|
||||||
data->normalsEnabled = false;
|
data->loadNormals = false;
|
||||||
mesh = new StaticMesh(data.get());
|
mesh = new StaticMesh(data.get());
|
||||||
|
|
||||||
mesh->translation.translateX(2.85F);
|
mesh->translation.translateX(2.85F);
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ Skybox::Skybox(TextureRepository* repo) {
|
|||||||
|
|
||||||
auto data = loader.load(FileUtils::fromCwd("game/models/skybox/skybox.obj"),
|
auto data = loader.load(FileUtils::fromCwd("game/models/skybox/skybox.obj"),
|
||||||
objOptions);
|
objOptions);
|
||||||
data->normalsEnabled = false;
|
data->loadNormals = false;
|
||||||
mesh = new StaticMesh(data.get());
|
mesh = new StaticMesh(data.get());
|
||||||
|
|
||||||
repo->addByMesh(mesh, FileUtils::fromCwd("game/models/skybox/"), "png");
|
repo->addByMesh(mesh, FileUtils::fromCwd("game/models/skybox/"), "png");
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ Terrain::Terrain(TextureRepository* repo)
|
|||||||
|
|
||||||
auto data = loader.load(FileUtils::fromCwd("game/models/terrain/terrain.obj"),
|
auto data = loader.load(FileUtils::fromCwd("game/models/terrain/terrain.obj"),
|
||||||
objOptions);
|
objOptions);
|
||||||
data->normalsEnabled = false;
|
data->loadNormals = false;
|
||||||
mesh = new StaticMesh(data.get());
|
mesh = new StaticMesh(data.get());
|
||||||
|
|
||||||
repo->addByMesh(mesh, FileUtils::fromCwd("game/models/terrain/"), "png");
|
repo->addByMesh(mesh, FileUtils::fromCwd("game/models/terrain/"), "png");
|
||||||
|
|||||||
+1
-1
@@ -11,4 +11,4 @@ services:
|
|||||||
container_name: tyra-compiler
|
container_name: tyra-compiler
|
||||||
volumes:
|
volumes:
|
||||||
- tyra-volume:/src
|
- tyra-volume:/src
|
||||||
- ./:/host
|
- ./:/host:z
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
1. Git
|
1. Git
|
||||||
2. VSCode
|
2. VSCode
|
||||||
3. Docker with PowerShell as a default terminal
|
3. Docker with PowerShell as a default terminal
|
||||||
4. [PCSX2](https://github.com/h4570/tyra/blob/master/docs/install/pcsx2.md#)
|
4. [Configured PCSX2](https://github.com/h4570/tyra/blob/master/docs/install/pcsx2.md#)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -17,9 +17,10 @@
|
|||||||
docker pull h4570/tyra
|
docker pull h4570/tyra
|
||||||
git clone https://github.com/h4570/tyra.git
|
git clone https://github.com/h4570/tyra.git
|
||||||
```
|
```
|
||||||
3. Open `VSCode` and open previously cloned directory.
|
3. Download the [assets.zip](https://github.com/h4570/tyra/releases) file and unzip it into the tyra directory
|
||||||
4. In `VSCode` open `.vscode/configurations/windows-docker` and copy configuration files into `.vscode/`
|
4. Open `VSCode` and open previously cloned directory.
|
||||||
5. In `c_cpp_properties.json` fix all `YOUR-INTELLISENSE-PATH` with path from point 2.
|
5. In `VSCode` open `.vscode/configurations/windows-docker` and copy configuration files into `.vscode/`
|
||||||
6. Click `CTRL+SHIFT+P`, type `Tasks: Run task` and run `Start docker container` - Repeat this step every time you want to start working with Tyra (every reboot)
|
6. In `c_cpp_properties.json` fix all `YOUR-INTELLISENSE-PATH` with path from point 2.
|
||||||
7. Click `CTRL+SHIFT+P`, type `Tasks: Run build task`
|
7. Click `CTRL+SHIFT+P`, type `Tasks: Run task` and run `Start docker container` - Repeat this step every time you want to start working with Tyra (every reboot)
|
||||||
8. Tyra should automatically compile engine, `demo` game and run `PCSX2`. If you want to compile & run tutorials, please change `buildDirectory` in `settings.json` to example `tutorials/01-hello`
|
8. Click `CTRL+SHIFT+P`, type `Tasks: Run build task`
|
||||||
|
9. Tyra should automatically compile engine, `demo` game and run `PCSX2`. If you want to compile & run tutorials, please change `buildDirectory` in `settings.json` to example `tutorials/01-hello`
|
||||||
|
|||||||
+15
-11
@@ -1,15 +1,9 @@
|
|||||||
## Install & configure PCSX2
|
## PCSX2 preparation
|
||||||
|
|
||||||
- Download & install PCSX2 (1.6+ version) from https://pcsx2.net/
|
- Download PCSX2 from https://pcsx2.net/
|
||||||
|
- Install
|
||||||
- Extract bios files from https://romsmania.cc/bios/pcsx2-playstation-2-bios-3 to `%UserProfile%\Documents\PCSX2\bios`
|
- Extract bios files from https://romsmania.cc/bios/pcsx2-playstation-2-bios-3 to `%UserProfile%\Documents\PCSX2\bios`
|
||||||
- Close `PCSX2` if you have opened!
|
- Map pad to your keyboard, for example:
|
||||||
- Open `%UserProfile%\Documents\PCSX2\inis\PCSX2_vm.ini` in notepad
|
|
||||||
|
|
||||||
```
|
|
||||||
HostFs=enabled
|
|
||||||
```
|
|
||||||
|
|
||||||
- Open PCSX2 and map pad to your keyboard, for example:
|
|
||||||
|
|
||||||
```
|
```
|
||||||
WASD = Left joy
|
WASD = Left joy
|
||||||
@@ -18,4 +12,14 @@ Space = X
|
|||||||
Circle = C
|
Circle = C
|
||||||
```
|
```
|
||||||
|
|
||||||
- Enable **"EE timing hack"** in PCSX2 hacks!
|
### For PCSX2 1.6.X
|
||||||
|
- Close `PCSX2` if you have opened!
|
||||||
|
- Open `%UserProfile%\Documents\PCSX2\inis\PCSX2_vm.ini` in notepad and change HostFs option:
|
||||||
|
|
||||||
|
```
|
||||||
|
HostFs=enabled
|
||||||
|
```
|
||||||
|
|
||||||
|
### For PCSX2 1.7.X
|
||||||
|
- Open `PCSX2`
|
||||||
|
- Go to Settings -> Emulation -> Enable `Host file system`
|
||||||
+23
-14
@@ -20,6 +20,7 @@
|
|||||||
#else // IF Debug
|
#else // IF Debug
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <debug.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
@@ -48,9 +49,7 @@ class TyraDebug {
|
|||||||
(void)expander{0, (void(ss << std::forward<Args>(args)), 0)...};
|
(void)expander{0, (void(ss << std::forward<Args>(args)), 0)...};
|
||||||
|
|
||||||
if (Tyra::Info::writeLogsToFile) {
|
if (Tyra::Info::writeLogsToFile) {
|
||||||
auto* logFile = getLogFile();
|
writeInLogFile(&ss);
|
||||||
*logFile << ss.str();
|
|
||||||
logFile->flush();
|
|
||||||
} else {
|
} else {
|
||||||
printf("%s", ss.str().c_str());
|
printf("%s", ss.str().c_str());
|
||||||
}
|
}
|
||||||
@@ -65,9 +64,7 @@ class TyraDebug {
|
|||||||
ss1 << "|\n";
|
ss1 << "|\n";
|
||||||
|
|
||||||
if (Tyra::Info::writeLogsToFile) {
|
if (Tyra::Info::writeLogsToFile) {
|
||||||
auto* logFile = getLogFile();
|
writeInLogFile(&ss1);
|
||||||
*logFile << ss1.str();
|
|
||||||
logFile->flush();
|
|
||||||
} else {
|
} else {
|
||||||
printf("%s", ss1.str().c_str());
|
printf("%s", ss1.str().c_str());
|
||||||
}
|
}
|
||||||
@@ -80,20 +77,22 @@ class TyraDebug {
|
|||||||
ss2 << "====================================\n\n";
|
ss2 << "====================================\n\n";
|
||||||
|
|
||||||
if (Tyra::Info::writeLogsToFile) {
|
if (Tyra::Info::writeLogsToFile) {
|
||||||
auto* logFile = getLogFile();
|
writeInLogFile(&ss2);
|
||||||
*logFile << ss2.str();
|
|
||||||
logFile->flush();
|
|
||||||
} else {
|
} else {
|
||||||
printf("%s", ss2.str().c_str());
|
printf("%s", ss2.str().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
init_scr();
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
scr_setXY(20, 10);
|
||||||
|
scr_printf(ss1.str().c_str());
|
||||||
|
writeAssertLinesInScreen(args...);
|
||||||
|
scr_printf(ss2.str().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static std::unique_ptr<std::ofstream> logFile;
|
static void writeInLogFile(std::stringstream* ss);
|
||||||
static std::ofstream* getLogFile();
|
|
||||||
|
|
||||||
template <typename Arg, typename... Args>
|
template <typename Arg, typename... Args>
|
||||||
static void writeAssertLines(Arg&& arg, Args&&... args) {
|
static void writeAssertLines(Arg&& arg, Args&&... args) {
|
||||||
@@ -105,13 +104,23 @@ class TyraDebug {
|
|||||||
0, (void(ss << "| " << std::forward<Args>(args) << "\n"), 0)...};
|
0, (void(ss << "| " << std::forward<Args>(args) << "\n"), 0)...};
|
||||||
|
|
||||||
if (Tyra::Info::writeLogsToFile) {
|
if (Tyra::Info::writeLogsToFile) {
|
||||||
auto* logfile = getLogFile();
|
writeInLogFile(&ss);
|
||||||
*logfile << ss.str();
|
|
||||||
logFile->flush();
|
|
||||||
} else {
|
} else {
|
||||||
printf("%s", ss.str().c_str());
|
printf("%s", ss.str().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename Arg, typename... Args>
|
||||||
|
static void writeAssertLinesInScreen(Arg&& arg, Args&&... args) {
|
||||||
|
std::stringstream ss;
|
||||||
|
|
||||||
|
ss << "| " << std::forward<Arg>(arg) << "\n";
|
||||||
|
using expander = int[];
|
||||||
|
(void)expander{
|
||||||
|
0, (void(ss << "| " << std::forward<Args>(args) << "\n"), 0)...};
|
||||||
|
|
||||||
|
scr_printf(ss.str().c_str());
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // NDEBUG
|
#endif // NDEBUG
|
||||||
@@ -11,6 +11,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <syslimits.h>
|
||||||
|
|
||||||
namespace Tyra {
|
namespace Tyra {
|
||||||
|
|
||||||
@@ -32,14 +34,19 @@ class FileUtils {
|
|||||||
static std::string fromCwd(const std::string& relativePath);
|
static std::string fromCwd(const std::string& relativePath);
|
||||||
static std::string fromCwd(const char* relativePath);
|
static std::string fromCwd(const char* relativePath);
|
||||||
|
|
||||||
|
static std::string getFilenameFromPath(const std::string& path);
|
||||||
|
static std::string getPathFromFilename(const std::string& path);
|
||||||
|
static std::string getFilenameWithoutExtension(const std::string& filename);
|
||||||
|
static std::string getExtensionOfFilename(const std::string& filename);
|
||||||
|
|
||||||
const char* getElfName() const { return elfName; };
|
const char* getElfName() const { return elfName; };
|
||||||
const char* getElfPath() const { return elfPath; };
|
const char* getElfPath() const { return elfPath; };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Argv name+path & just path
|
// Argv name+path & just path
|
||||||
char cwd[255];
|
char cwd[NAME_MAX];
|
||||||
char elfName[255];
|
char elfName[NAME_MAX];
|
||||||
char elfPath[255 - 14];
|
char elfPath[NAME_MAX - 14];
|
||||||
|
|
||||||
void setPathInfo(const char* path);
|
void setPathInfo(const char* path);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class Version {
|
|||||||
~Version() {}
|
~Version() {}
|
||||||
|
|
||||||
static const u8 major = 2;
|
static const u8 major = 2;
|
||||||
static const u8 minor = 0;
|
static const u8 minor = 2;
|
||||||
static const u8 patch = 0;
|
static const u8 patch = 0;
|
||||||
|
|
||||||
static std::string toString() {
|
static std::string toString() {
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ class IrxLoader {
|
|||||||
void loadSio2man(const bool& verbose);
|
void loadSio2man(const bool& verbose);
|
||||||
void loadPadman(const bool& verbose);
|
void loadPadman(const bool& verbose);
|
||||||
void loadLibsd(const bool& verbose);
|
void loadLibsd(const bool& verbose);
|
||||||
|
void loadIO(const bool& verbose);
|
||||||
void loadUsbModules(const bool& verbose);
|
void loadUsbModules(const bool& verbose);
|
||||||
void loadAudsrv(const bool& verbose);
|
void loadAudsrv(const bool& verbose);
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class MeshBuilderData {
|
|||||||
|
|
||||||
std::vector<MeshBuilderMaterialData*> materials;
|
std::vector<MeshBuilderMaterialData*> materials;
|
||||||
|
|
||||||
bool textureCoordsEnabled, normalsEnabled, lightMapEnabled;
|
bool loadNormals, loadLightmap;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Tyra
|
} // namespace Tyra
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <optional>
|
||||||
#include "./mesh_builder_material_frame_data.hpp"
|
#include "./mesh_builder_material_frame_data.hpp"
|
||||||
#include "renderer/models/color.hpp"
|
#include "renderer/models/color.hpp"
|
||||||
|
|
||||||
@@ -25,6 +26,7 @@ class MeshBuilderMaterialData {
|
|||||||
|
|
||||||
std::vector<MeshBuilderMaterialFrameData*> frames;
|
std::vector<MeshBuilderMaterialFrameData*> frames;
|
||||||
std::string name;
|
std::string name;
|
||||||
|
std::optional<std::string> texturePath;
|
||||||
Color ambient;
|
Color ambient;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../../loader.hpp"
|
|
||||||
#include "../builder/mesh_builder_data.hpp"
|
#include "../builder/mesh_builder_data.hpp"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
@@ -23,7 +22,7 @@ struct MD2LoaderOptions {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/** Class responsible for loading & parsing Quake's II ".md2" 3D files */
|
/** Class responsible for loading & parsing Quake's II ".md2" 3D files */
|
||||||
class MD2Loader : public Loader {
|
class MD2Loader {
|
||||||
public:
|
public:
|
||||||
static std::unique_ptr<MeshBuilderData> load(const char* fullpath);
|
static std::unique_ptr<MeshBuilderData> load(const char* fullpath);
|
||||||
static std::unique_ptr<MeshBuilderData> load(const char* fullpath,
|
static std::unique_ptr<MeshBuilderData> load(const char* fullpath,
|
||||||
|
|||||||
@@ -10,12 +10,12 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../../loader.hpp"
|
|
||||||
#include "../builder/mesh_builder_data.hpp"
|
#include "../builder/mesh_builder_data.hpp"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "renderer/models/color.hpp"
|
#include "renderer/models/color.hpp"
|
||||||
#include "loaders/3d/obj_loader/tiny_obj_loader.hpp"
|
#include "loaders/3d/obj_loader/tiny_obj_loader.hpp"
|
||||||
#include <memory.h>
|
#include <memory.h>
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
namespace Tyra {
|
namespace Tyra {
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ struct MaterialVertexCount {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/** Class responsible for loading & parsing obj files */
|
/** Class responsible for loading & parsing obj files */
|
||||||
class ObjLoader : public Loader {
|
class ObjLoader {
|
||||||
public:
|
public:
|
||||||
static std::unique_ptr<MeshBuilderData> load(const char* fullpath);
|
static std::unique_ptr<MeshBuilderData> load(const char* fullpath);
|
||||||
static std::unique_ptr<MeshBuilderData> load(const char* fullpath,
|
static std::unique_ptr<MeshBuilderData> load(const char* fullpath,
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
/*
|
|
||||||
# _____ ____ ___
|
|
||||||
# | \/ ____| |___|
|
|
||||||
# | | | \ | |
|
|
||||||
#-----------------------------------------------------------------------
|
|
||||||
# Copyright 2022, tyra - https://github.com/h4570/tyra
|
|
||||||
# Licensed under Apache License 2.0
|
|
||||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace Tyra {
|
|
||||||
|
|
||||||
class Loader {
|
|
||||||
protected:
|
|
||||||
static std::string getFilenameFromPath(const std::string& path);
|
|
||||||
static std::string getPathFromFilename(const std::string& path);
|
|
||||||
static std::string getFilenameWithoutExtension(const std::string& filename);
|
|
||||||
static std::string getExtensionOfFilename(const std::string& filename);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Tyra
|
|
||||||
@@ -10,13 +10,12 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "loaders/loader.hpp"
|
|
||||||
#include "loaders/texture/builder/texture_builder_data.hpp"
|
#include "loaders/texture/builder/texture_builder_data.hpp"
|
||||||
#include "renderer/core/texture/models/texture_bpp.hpp"
|
#include "renderer/core/texture/models/texture_bpp.hpp"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace Tyra {
|
namespace Tyra {
|
||||||
class TextureLoader : public Loader {
|
class TextureLoader {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Loads texture data from file.
|
* @brief Loads texture data from file.
|
||||||
|
|||||||
@@ -33,4 +33,5 @@ class TextureBuilderData {
|
|||||||
TextureBpp clutBpp;
|
TextureBpp clutBpp;
|
||||||
unsigned char clutGsComponents;
|
unsigned char clutGsComponents;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Tyra
|
} // namespace Tyra
|
||||||
|
|||||||
@@ -36,9 +36,6 @@ class Math {
|
|||||||
static int randomi(const int& min, const int& max);
|
static int randomi(const int& min, const int& max);
|
||||||
static bool equalf(const float& a, const float& b,
|
static bool equalf(const float& a, const float& b,
|
||||||
const float& epsilon = 0.00001F);
|
const float& epsilon = 0.00001F);
|
||||||
|
|
||||||
private:
|
|
||||||
Math();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Tyra
|
} // namespace Tyra
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
#include "debug/debug.hpp"
|
#include "debug/debug.hpp"
|
||||||
#include "./mesh_material_frame.hpp"
|
#include "./mesh_material_frame.hpp"
|
||||||
#include "loaders/3d/builder/mesh_builder_data.hpp"
|
#include "loaders/3d/builder/mesh_builder_data.hpp"
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
namespace Tyra {
|
namespace Tyra {
|
||||||
|
|
||||||
@@ -23,11 +24,9 @@ class MeshMaterial {
|
|||||||
~MeshMaterial();
|
~MeshMaterial();
|
||||||
|
|
||||||
bool isMother, lightmapFlag;
|
bool isMother, lightmapFlag;
|
||||||
|
|
||||||
u32 id;
|
u32 id;
|
||||||
|
|
||||||
std::string name;
|
std::string name;
|
||||||
|
std::optional<std::string> textureName;
|
||||||
Color ambient;
|
Color ambient;
|
||||||
|
|
||||||
std::vector<MeshMaterialFrame*> frames;
|
std::vector<MeshMaterialFrame*> frames;
|
||||||
|
|||||||
@@ -44,8 +44,7 @@ class DynPipRenderer {
|
|||||||
void uploadPrograms();
|
void uploadPrograms();
|
||||||
void setDoubleBuffer();
|
void setDoubleBuffer();
|
||||||
|
|
||||||
void addBufferDataToPacket(DynPipVU1Program* program, DynPipBag** bags,
|
void addBufferDataToPacket(DynPipBag** bags, const u32& count);
|
||||||
const u32& count);
|
|
||||||
void sendPacket();
|
void sendPacket();
|
||||||
|
|
||||||
prim_t* prim;
|
prim_t* prim;
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ class DynamicPipeline : public Renderer3DPipeline {
|
|||||||
|
|
||||||
void setBuffer(DynPipBag* buffers, DynPipBag* buffer, u16* bufferIndex);
|
void setBuffer(DynPipBag* buffers, DynPipBag* buffer, u16* bufferIndex);
|
||||||
|
|
||||||
void sendRestOfBuffers(DynPipBag* buffers, u16* bufferIndex);
|
void sendRestOfBuffers(DynPipBag* buffers, const u16& bufferIndex);
|
||||||
|
|
||||||
void addVertices(const MeshMaterialFrame* materialFrameFrom,
|
void addVertices(const MeshMaterialFrame* materialFrameFrom,
|
||||||
const MeshMaterialFrame* materialFrameTo, DynPipBag* bag,
|
const MeshMaterialFrame* materialFrameTo, DynPipBag* bag,
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
#include "debug/debug.hpp"
|
#include "debug/debug.hpp"
|
||||||
#include "renderer/core/2d/sprite/sprite.hpp"
|
#include "renderer/core/2d/sprite/sprite.hpp"
|
||||||
#include "renderer/core/texture/renderer_core_texture_buffers.hpp"
|
#include "renderer/core/texture/renderer_core_texture_buffers.hpp"
|
||||||
|
#include "renderer/3d/pipeline/shared/pipeline_texture_mapping_type.hpp"
|
||||||
#include "renderer/core/texture/models/texture.hpp"
|
#include "renderer/core/texture/models/texture.hpp"
|
||||||
#include "renderer/renderer_settings.hpp"
|
#include "renderer/renderer_settings.hpp"
|
||||||
#include <packet2_utils.h>
|
#include <packet2_utils.h>
|
||||||
@@ -30,6 +31,9 @@ class RendererCore2D {
|
|||||||
void render(const Sprite& sprite,
|
void render(const Sprite& sprite,
|
||||||
const RendererCoreTextureBuffers& texBuffers, Texture* texture);
|
const RendererCoreTextureBuffers& texBuffers, Texture* texture);
|
||||||
|
|
||||||
|
void setTextureMappingType(
|
||||||
|
const PipelineTextureMappingType textureMappingType);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setPrim();
|
void setPrim();
|
||||||
void setLod();
|
void setLod();
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ class Sprite {
|
|||||||
~Sprite();
|
~Sprite();
|
||||||
|
|
||||||
u32 id;
|
u32 id;
|
||||||
Vec2 position, size;
|
Vec2 position, size, offset;
|
||||||
float scale;
|
float scale;
|
||||||
Color color;
|
Color color;
|
||||||
SpriteMode mode;
|
SpriteMode mode;
|
||||||
|
|||||||
@@ -62,7 +62,8 @@ class Texture {
|
|||||||
|
|
||||||
/** Set texture wrapping */
|
/** Set texture wrapping */
|
||||||
void setWrapSettings(const TextureWrap t_horizontal,
|
void setWrapSettings(const TextureWrap t_horizontal,
|
||||||
const TextureWrap t_vertical);
|
const TextureWrap t_vertical, int minu = 0, int minv = 0,
|
||||||
|
int maxu = 0, int maxv = 0);
|
||||||
|
|
||||||
// ----
|
// ----
|
||||||
// Other
|
// Other
|
||||||
@@ -96,9 +97,10 @@ class Texture {
|
|||||||
void print(const std::string& name) const { print(name.c_str()); }
|
void print(const std::string& name) const { print(name.c_str()); }
|
||||||
std::string getPrint(const char* name = nullptr) const;
|
std::string getPrint(const char* name = nullptr) const;
|
||||||
|
|
||||||
|
void setDefaultWrapSettings();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setPsm();
|
void setPsm();
|
||||||
void setDefaultWrapSettings();
|
|
||||||
|
|
||||||
texwrap_t wrap;
|
texwrap_t wrap;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -29,6 +29,12 @@ class RendererCoreTexture {
|
|||||||
|
|
||||||
RendererCoreTextureBuffers useTexture(const Texture* t_tex);
|
RendererCoreTextureBuffers useTexture(const Texture* t_tex);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by user after changing texture wrap settings
|
||||||
|
* Updates texture packet without reallocate it
|
||||||
|
*/
|
||||||
|
RendererCoreTextureBuffers updateTextureInfo(const Texture* t_tex);
|
||||||
|
|
||||||
/** Called by renderer during initialization */
|
/** Called by renderer during initialization */
|
||||||
void init(RendererCoreGS* gs, Path3* path3);
|
void init(RendererCoreGS* gs, Path3* path3);
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#include "./models/texture.hpp"
|
#include "./models/texture.hpp"
|
||||||
#include "renderer/3d/mesh/mesh.hpp"
|
#include "renderer/3d/mesh/mesh.hpp"
|
||||||
#include "renderer/core/2d/sprite/sprite.hpp"
|
#include "renderer/core/2d/sprite/sprite.hpp"
|
||||||
|
#include "./renderer_core_texture_buffers.hpp"
|
||||||
#include "loaders/texture/base/texture_loader_selector.hpp"
|
#include "loaders/texture/base/texture_loader_selector.hpp"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@@ -25,6 +26,8 @@ class TextureRepository {
|
|||||||
TextureRepository();
|
TextureRepository();
|
||||||
~TextureRepository();
|
~TextureRepository();
|
||||||
|
|
||||||
|
void init(std::vector<RendererCoreTextureBuffers>* textureBuffers);
|
||||||
|
|
||||||
/** Returns all repository textures. */
|
/** Returns all repository textures. */
|
||||||
std::vector<Texture*>* getAll() { return &textures; }
|
std::vector<Texture*>* getAll() { return &textures; }
|
||||||
|
|
||||||
@@ -99,6 +102,13 @@ class TextureRepository {
|
|||||||
void freeByMesh(const Mesh& mesh);
|
void freeByMesh(const Mesh& mesh);
|
||||||
void freeByMesh(const Mesh* mesh);
|
void freeByMesh(const Mesh* mesh);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* remove texture buffer id if exist.
|
||||||
|
* Texture buffer is NOT destructed.
|
||||||
|
* easy way to create another texture buffer.
|
||||||
|
*/
|
||||||
|
int removeBufferId(const u32& t_texId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove texture from repository.
|
* Remove texture from repository.
|
||||||
* Texture is NOT destructed.
|
* Texture is NOT destructed.
|
||||||
@@ -110,6 +120,7 @@ class TextureRepository {
|
|||||||
void removeByIndex(const u32& t_index);
|
void removeByIndex(const u32& t_index);
|
||||||
|
|
||||||
std::vector<Texture*> textures;
|
std::vector<Texture*> textures;
|
||||||
|
std::vector<RendererCoreTextureBuffers>* textureBuffers;
|
||||||
TextureLoaderSelector texLoaderSelector;
|
TextureLoaderSelector texLoaderSelector;
|
||||||
};
|
};
|
||||||
} // namespace Tyra
|
} // namespace Tyra
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ class RendererSettings {
|
|||||||
height(448.0F),
|
height(448.0F),
|
||||||
interlacedHeightF(height / 2),
|
interlacedHeightF(height / 2),
|
||||||
near(0.1F),
|
near(0.1F),
|
||||||
far(8192.0F),
|
far(51200.0F),
|
||||||
projectionScale(4096.0F),
|
projectionScale(4096.0F),
|
||||||
aspectRatio(width / height),
|
aspectRatio(width / height),
|
||||||
interlacedHeightUI(static_cast<unsigned int>(interlacedHeightF)) {}
|
interlacedHeightUI(static_cast<unsigned int>(interlacedHeightF)) {}
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
# Copyright 2022, tyra - https://github.com/h4570/tyra
|
# Copyright 2022, tyra - https://github.com/h4570/tyra
|
||||||
# Licensed under Apache License 2.0
|
# Licensed under Apache License 2.0
|
||||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "audio/audio.hpp"
|
#include "audio/audio.hpp"
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
# Copyright 2022, tyra - https://github.com/h4570/tyra
|
# Copyright 2022, tyra - https://github.com/h4570/tyra
|
||||||
# Licensed under Apache License 2.0
|
# Licensed under Apache License 2.0
|
||||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "audio/audio_adpcm.hpp"
|
#include "audio/audio_adpcm.hpp"
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
# Copyright 2022, tyra - https://github.com/h4570/tyra
|
# Copyright 2022, tyra - https://github.com/h4570/tyra
|
||||||
# Licensed under Apache License 2.0
|
# Licensed under Apache License 2.0
|
||||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "audio/audio_song.hpp"
|
#include "audio/audio_song.hpp"
|
||||||
@@ -149,6 +148,7 @@ void AudioSong::work() {
|
|||||||
|
|
||||||
if (chunkReadStatus > 0) {
|
if (chunkReadStatus > 0) {
|
||||||
WaitSema(fillbufferSema); // wait until previous chunk wasn't finished
|
WaitSema(fillbufferSema); // wait until previous chunk wasn't finished
|
||||||
|
audsrv_wait_audio(chunkReadStatus);
|
||||||
audsrv_play_audio(chunk, chunkReadStatus);
|
audsrv_play_audio(chunk, chunkReadStatus);
|
||||||
for (u32 i = 0; i < getListenersCount(); i++)
|
for (u32 i = 0; i < getListenersCount(); i++)
|
||||||
songListeners[i]->listener->onAudioTick();
|
songListeners[i]->listener->onAudioTick();
|
||||||
|
|||||||
@@ -10,16 +10,11 @@
|
|||||||
|
|
||||||
#include "debug/debug.hpp"
|
#include "debug/debug.hpp"
|
||||||
|
|
||||||
std::unique_ptr<std::ofstream> TyraDebug::logFile;
|
void TyraDebug::writeInLogFile(std::stringstream* ss) {
|
||||||
|
std::ofstream logFile;
|
||||||
std::ofstream* TyraDebug::getLogFile() {
|
logFile.open(Tyra::FileUtils::fromCwd("log.txt"),
|
||||||
if (logFile) {
|
std::ofstream::out | std::ofstream::app);
|
||||||
return logFile.get();
|
logFile << ss->str();
|
||||||
} else {
|
logFile.flush();
|
||||||
logFile = std::make_unique<std::ofstream>();
|
// logFile.close();
|
||||||
logFile->open(Tyra::FileUtils::fromCwd("log.txt"),
|
}
|
||||||
std::ofstream::out | std::ofstream::app);
|
|
||||||
return logFile.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Tyra
|
|
||||||
|
|||||||
@@ -12,8 +12,7 @@
|
|||||||
#include <tamtypes.h>
|
#include <tamtypes.h>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <kernel.h>
|
#include <kernel.h>
|
||||||
#include <limits.h>
|
|
||||||
#include <syslimits.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include "file/file_utils.hpp"
|
#include "file/file_utils.hpp"
|
||||||
@@ -64,4 +63,32 @@ std::string FileUtils::fromCwd(const char* file) {
|
|||||||
auto cwd = getCwd();
|
auto cwd = getCwd();
|
||||||
return cwd + file;
|
return cwd + file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string FileUtils::getFilenameFromPath(const std::string& path) {
|
||||||
|
std::string filename = path.substr(path.find_last_of("/\\") + 1);
|
||||||
|
if (filename.size() == path.size()) {
|
||||||
|
filename = path.substr(path.find_last_of(":\\") + 1);
|
||||||
|
}
|
||||||
|
return filename;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string FileUtils::getPathFromFilename(const std::string& path) {
|
||||||
|
std::string basepath = path.substr(0, path.find_last_of("/\\"));
|
||||||
|
if (basepath.size() == path.size()) {
|
||||||
|
basepath = path.substr(0, path.find_last_of(":\\"));
|
||||||
|
}
|
||||||
|
return basepath;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string FileUtils::getFilenameWithoutExtension(
|
||||||
|
const std::string& filename) {
|
||||||
|
auto lastindex = filename.find_last_of(".");
|
||||||
|
return filename.substr(0, lastindex);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string FileUtils::getExtensionOfFilename(const std::string& filename) {
|
||||||
|
auto lastindex = filename.find_last_of(".");
|
||||||
|
return filename.substr(lastindex + 1);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Tyra
|
} // namespace Tyra
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
$PS2SDK/iop/irx/fileXio.irx
|
||||||
|
fileXio_irx
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
$PS2SDK/iop/irx/iomanX.irx
|
||||||
|
iomanX_irx
|
||||||
@@ -20,30 +20,20 @@
|
|||||||
#include "file/file_utils.hpp"
|
#include "file/file_utils.hpp"
|
||||||
|
|
||||||
// external IRX modules
|
// external IRX modules
|
||||||
|
#define EXTERN_IRX(_irx) \
|
||||||
|
extern u8 _irx[]; \
|
||||||
|
extern int size_##_irx
|
||||||
|
|
||||||
extern u8 sio2man_irx[];
|
EXTERN_IRX(sio2man_irx);
|
||||||
extern int size_sio2man_irx;
|
EXTERN_IRX(padman_irx);
|
||||||
|
EXTERN_IRX(audsrv_irx);
|
||||||
extern u8 padman_irx[];
|
EXTERN_IRX(libsd_irx);
|
||||||
extern int size_padman_irx;
|
EXTERN_IRX(fileXio_irx);
|
||||||
|
EXTERN_IRX(iomanX_irx);
|
||||||
extern u8 audsrv_irx[];
|
EXTERN_IRX(bdm_irx);
|
||||||
extern int size_audsrv_irx;
|
EXTERN_IRX(bdmfs_fatfs_irx);
|
||||||
|
EXTERN_IRX(usbd_irx);
|
||||||
extern u8 libsd_irx[];
|
EXTERN_IRX(usbmass_bd_irx);
|
||||||
extern int size_libsd_irx;
|
|
||||||
|
|
||||||
extern u8 bdm_irx[];
|
|
||||||
extern int size_bdm_irx;
|
|
||||||
|
|
||||||
extern u8 bdmfs_fatfs_irx[];
|
|
||||||
extern int size_bdmfs_fatfs_irx;
|
|
||||||
|
|
||||||
extern u8 usbd_irx[];
|
|
||||||
extern int size_usbd_irx;
|
|
||||||
|
|
||||||
extern u8 usbmass_bd_irx[];
|
|
||||||
extern int size_usbmass_bd_irx;
|
|
||||||
|
|
||||||
namespace Tyra {
|
namespace Tyra {
|
||||||
|
|
||||||
@@ -70,6 +60,7 @@ void IrxLoader::loadAll(const bool& withUsb, const bool& isLoggingToFile) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loadIO(!isLoggingToFile);
|
||||||
loadSio2man(!isLoggingToFile);
|
loadSio2man(!isLoggingToFile);
|
||||||
loadPadman(!isLoggingToFile);
|
loadPadman(!isLoggingToFile);
|
||||||
loadLibsd(!isLoggingToFile);
|
loadLibsd(!isLoggingToFile);
|
||||||
@@ -116,6 +107,24 @@ void IrxLoader::loadLibsd(const bool& verbose) {
|
|||||||
if (verbose) TYRA_LOG("IRX: Libsd loaded!");
|
if (verbose) TYRA_LOG("IRX: Libsd loaded!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void IrxLoader::loadIO(const bool& verbose) {
|
||||||
|
int ret;
|
||||||
|
if (verbose) TYRA_LOG("IRX: Loading iomanX...");
|
||||||
|
|
||||||
|
SifExecModuleBuffer(&iomanX_irx, size_iomanX_irx, 0, nullptr, &ret);
|
||||||
|
TYRA_ASSERT(ret >= 0, "Failed to load module: iomanX_irx");
|
||||||
|
|
||||||
|
if (verbose) TYRA_LOG("IRX: iomanX loaded!");
|
||||||
|
|
||||||
|
if (verbose) TYRA_LOG("IRX: Loading fileXio...");
|
||||||
|
|
||||||
|
SifExecModuleBuffer(&fileXio_irx, size_fileXio_irx, 0, nullptr, &ret);
|
||||||
|
TYRA_ASSERT(ret >= 0, "Failed to load module: fileXio_irx");
|
||||||
|
|
||||||
|
if (verbose) TYRA_LOG("IRX: fileXio_irx loaded!");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void IrxLoader::loadUsbModules(const bool& verbose) {
|
void IrxLoader::loadUsbModules(const bool& verbose) {
|
||||||
if (verbose) TYRA_LOG("IRX: Loading usb modules...");
|
if (verbose) TYRA_LOG("IRX: Loading usb modules...");
|
||||||
|
|
||||||
|
|||||||
@@ -14,9 +14,8 @@
|
|||||||
namespace Tyra {
|
namespace Tyra {
|
||||||
|
|
||||||
MeshBuilderData::MeshBuilderData() {
|
MeshBuilderData::MeshBuilderData() {
|
||||||
textureCoordsEnabled = false;
|
loadNormals = false;
|
||||||
normalsEnabled = false;
|
loadLightmap = false;
|
||||||
lightMapEnabled = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MeshBuilderData::~MeshBuilderData() {
|
MeshBuilderData::~MeshBuilderData() {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include "debug/debug.hpp"
|
#include "debug/debug.hpp"
|
||||||
#include "loaders/3d/md2_loader/anorms.hpp"
|
#include "loaders/3d/md2_loader/anorms.hpp"
|
||||||
#include "loaders/loader.hpp"
|
#include "file/file_utils.hpp"
|
||||||
|
|
||||||
namespace Tyra {
|
namespace Tyra {
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ std::unique_ptr<MeshBuilderData> MD2Loader::load(const char* fullpath,
|
|||||||
std::string path = fullpath;
|
std::string path = fullpath;
|
||||||
TYRA_ASSERT(!path.empty(), "Provided path is empty!");
|
TYRA_ASSERT(!path.empty(), "Provided path is empty!");
|
||||||
|
|
||||||
auto filename = getFilenameFromPath(path);
|
auto filename = FileUtils::getFilenameFromPath(path);
|
||||||
|
|
||||||
FILE* file = fopen(fullpath, "rb");
|
FILE* file = fopen(fullpath, "rb");
|
||||||
TYRA_ASSERT(file != nullptr, "Failed to load: ", filename);
|
TYRA_ASSERT(file != nullptr, "Failed to load: ", filename);
|
||||||
@@ -122,12 +122,13 @@ std::unique_ptr<MeshBuilderData> MD2Loader::load(const char* fullpath,
|
|||||||
auto result = std::make_unique<MeshBuilderData>();
|
auto result = std::make_unique<MeshBuilderData>();
|
||||||
|
|
||||||
auto* material = new MeshBuilderMaterialData();
|
auto* material = new MeshBuilderMaterialData();
|
||||||
material->name = getFilenameWithoutExtension(filename);
|
material->name = FileUtils::getFilenameWithoutExtension(filename);
|
||||||
|
material->texturePath = material->name;
|
||||||
|
material->texturePath.value().append(".png");
|
||||||
|
|
||||||
result->materials.push_back(material);
|
result->materials.push_back(material);
|
||||||
result->normalsEnabled = true;
|
result->loadNormals = true;
|
||||||
result->textureCoordsEnabled = true;
|
result->loadLightmap = false;
|
||||||
result->lightMapEnabled = false;
|
|
||||||
|
|
||||||
Vec4** tempVertices = new Vec4*[framesCount];
|
Vec4** tempVertices = new Vec4*[framesCount];
|
||||||
Vec4** tempNormals = new Vec4*[framesCount];
|
Vec4** tempNormals = new Vec4*[framesCount];
|
||||||
|
|||||||
@@ -10,13 +10,13 @@
|
|||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "math/vec2.hpp"
|
#include "math/vec2.hpp"
|
||||||
#include "math/vec4.hpp"
|
#include "math/vec4.hpp"
|
||||||
#include "renderer/models/color.hpp"
|
#include "renderer/models/color.hpp"
|
||||||
#include "debug/debug.hpp"
|
#include "debug/debug.hpp"
|
||||||
#include "loaders/3d/obj_loader/obj_loader.hpp"
|
#include "loaders/3d/obj_loader/obj_loader.hpp"
|
||||||
|
#include "file/file_utils.hpp"
|
||||||
|
|
||||||
#define TINYOBJLOADER_USE_MAPBOX_EARCUT
|
#define TINYOBJLOADER_USE_MAPBOX_EARCUT
|
||||||
#define TINYOBJLOADER_IMPLEMENTATION
|
#define TINYOBJLOADER_IMPLEMENTATION
|
||||||
@@ -40,12 +40,12 @@ std::unique_ptr<MeshBuilderData> ObjLoader::load(
|
|||||||
std::unique_ptr<MeshBuilderData> ObjLoader::load(
|
std::unique_ptr<MeshBuilderData> ObjLoader::load(
|
||||||
const char* fullpath, const ObjLoaderOptions& options) {
|
const char* fullpath, const ObjLoaderOptions& options) {
|
||||||
std::string path = fullpath;
|
std::string path = fullpath;
|
||||||
std::string basePath = getPathFromFilename(path);
|
std::string basePath = FileUtils::getPathFromFilename(path);
|
||||||
|
|
||||||
TYRA_ASSERT(!path.empty(), "Provided path is empty!");
|
TYRA_ASSERT(!path.empty(), "Provided path is empty!");
|
||||||
|
|
||||||
auto rawFilename = getFilenameWithoutExtension(path);
|
auto rawFilename = FileUtils::getFilenameWithoutExtension(path);
|
||||||
auto extension = getExtensionOfFilename(path);
|
auto extension = FileUtils::getExtensionOfFilename(path);
|
||||||
auto result = std::make_unique<MeshBuilderData>();
|
auto result = std::make_unique<MeshBuilderData>();
|
||||||
|
|
||||||
tinyobj::ObjReaderConfig readerConfig;
|
tinyobj::ObjReaderConfig readerConfig;
|
||||||
@@ -131,9 +131,7 @@ void ObjLoader::addOutputMaterialsAndFrames(
|
|||||||
const std::vector<tinyobj::shape_t>& shapes,
|
const std::vector<tinyobj::shape_t>& shapes,
|
||||||
const std::vector<tinyobj::material_t>& materials, const u16& framesCount,
|
const std::vector<tinyobj::material_t>& materials, const u16& framesCount,
|
||||||
std::vector<MaterialVertexCount>& materialVertexCounts) {
|
std::vector<MaterialVertexCount>& materialVertexCounts) {
|
||||||
if (attrib.texcoords.size()) output->textureCoordsEnabled = true;
|
if (attrib.normals.size()) output->loadNormals = true;
|
||||||
|
|
||||||
if (attrib.normals.size()) output->normalsEnabled = true;
|
|
||||||
|
|
||||||
TYRA_ASSERT(materials.size() > 0,
|
TYRA_ASSERT(materials.size() > 0,
|
||||||
"No material data found! Please add .mtl "
|
"No material data found! Please add .mtl "
|
||||||
@@ -145,6 +143,10 @@ void ObjLoader::addOutputMaterialsAndFrames(
|
|||||||
|
|
||||||
material->name = materials[i].name;
|
material->name = materials[i].name;
|
||||||
|
|
||||||
|
if (!materials[i].diffuse_texname.empty()) {
|
||||||
|
material->texturePath = materials[i].diffuse_texname;
|
||||||
|
}
|
||||||
|
|
||||||
material->ambient.set(materials[i].diffuse[0] * 128.0F,
|
material->ambient.set(materials[i].diffuse[0] * 128.0F,
|
||||||
materials[i].diffuse[1] * 128.0F,
|
materials[i].diffuse[1] * 128.0F,
|
||||||
materials[i].diffuse[2] * 128.0F, 128.0F);
|
materials[i].diffuse[2] * 128.0F, 128.0F);
|
||||||
@@ -157,10 +159,11 @@ void ObjLoader::addOutputMaterialsAndFrames(
|
|||||||
frame->count = counter.count;
|
frame->count = counter.count;
|
||||||
frame->vertices = new Vec4[counter.count];
|
frame->vertices = new Vec4[counter.count];
|
||||||
|
|
||||||
if (output->textureCoordsEnabled)
|
if (material->texturePath.has_value()) {
|
||||||
frame->textureCoords = new Vec4[counter.count];
|
frame->textureCoords = new Vec4[counter.count];
|
||||||
|
}
|
||||||
|
|
||||||
if (output->normalsEnabled) frame->normals = new Vec4[counter.count];
|
if (output->loadNormals) frame->normals = new Vec4[counter.count];
|
||||||
|
|
||||||
material->frames.push_back(frame);
|
material->frames.push_back(frame);
|
||||||
}
|
}
|
||||||
@@ -186,6 +189,8 @@ void ObjLoader::importFrame(MeshBuilderData* output,
|
|||||||
materialInsertControls.push_back(control);
|
materialInsertControls.push_back(control);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<u32> materialIdsWithTextureWarning;
|
||||||
|
|
||||||
// Loop over shapes
|
// Loop over shapes
|
||||||
for (size_t s = 0; s < shapes.size(); s++) {
|
for (size_t s = 0; s < shapes.size(); s++) {
|
||||||
const auto& mesh = shapes[s].mesh;
|
const auto& mesh = shapes[s].mesh;
|
||||||
@@ -197,7 +202,8 @@ void ObjLoader::importFrame(MeshBuilderData* output,
|
|||||||
auto& materialInsertControl = materialInsertControls[materialId];
|
auto& materialInsertControl = materialInsertControls[materialId];
|
||||||
size_t vertCountPerFace = size_t(mesh.num_face_vertices[f]);
|
size_t vertCountPerFace = size_t(mesh.num_face_vertices[f]);
|
||||||
|
|
||||||
auto* outFrame = output->materials[materialId]->frames[frameIndex];
|
auto* outMaterial = output->materials[materialId];
|
||||||
|
auto* outFrame = outMaterial->frames[frameIndex];
|
||||||
|
|
||||||
TYRA_ASSERT(count == 1 || vertCountPerFace == 3,
|
TYRA_ASSERT(count == 1 || vertCountPerFace == 3,
|
||||||
"Please triangulate obj files if you are animating!",
|
"Please triangulate obj files if you are animating!",
|
||||||
@@ -232,14 +238,32 @@ void ObjLoader::importFrame(MeshBuilderData* output,
|
|||||||
// Check if `texcoord_index` is zero or positive. negative =
|
// Check if `texcoord_index` is zero or positive. negative =
|
||||||
// notexcoord data
|
// notexcoord data
|
||||||
if (idx.texcoord_index >= 0) {
|
if (idx.texcoord_index >= 0) {
|
||||||
tinyobj::real_t tx =
|
if (outMaterial->texturePath.has_value()) {
|
||||||
attrib.texcoords[2 * size_t(idx.texcoord_index) + 0];
|
tinyobj::real_t tx =
|
||||||
tinyobj::real_t ty =
|
attrib.texcoords[2 * size_t(idx.texcoord_index) + 0];
|
||||||
attrib.texcoords[2 * size_t(idx.texcoord_index) + 1];
|
tinyobj::real_t ty =
|
||||||
|
attrib.texcoords[2 * size_t(idx.texcoord_index) + 1];
|
||||||
|
|
||||||
auto finalY = invertY ? 1.0F - ty : ty;
|
auto finalY = invertY ? 1.0F - ty : ty;
|
||||||
outFrame->textureCoords[materialInsertControl.inserted].set(
|
outFrame->textureCoords[materialInsertControl.inserted].set(
|
||||||
tx, finalY, 1.0F, 0.0F);
|
tx, finalY, 1.0F, 0.0F);
|
||||||
|
} else {
|
||||||
|
auto warningWasNotPrinted =
|
||||||
|
std::find(materialIdsWithTextureWarning.begin(),
|
||||||
|
materialIdsWithTextureWarning.end(),
|
||||||
|
materialId) == materialIdsWithTextureWarning.end();
|
||||||
|
|
||||||
|
if (frameIndex == 0 && warningWasNotPrinted) {
|
||||||
|
materialIdsWithTextureWarning.push_back(materialId);
|
||||||
|
|
||||||
|
TYRA_WARN(
|
||||||
|
"Material \"", outMaterial->name,
|
||||||
|
"\" has texture coordinates, but texture path was not found "
|
||||||
|
"in .mtl file! ",
|
||||||
|
"Please consider adding texture path to map_Kd field in .mtl "
|
||||||
|
"file!");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
materialInsertControl.inserted++;
|
materialInsertControl.inserted++;
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
|
|
||||||
/*
|
|
||||||
# _____ ____ ___
|
|
||||||
# | \/ ____| |___|
|
|
||||||
# | | | \ | |
|
|
||||||
#-----------------------------------------------------------------------
|
|
||||||
# Copyright 2022, tyra - https://github.com/h4570/tyra
|
|
||||||
# Licensed under Apache License 2.0
|
|
||||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "loaders/loader.hpp"
|
|
||||||
|
|
||||||
namespace Tyra {
|
|
||||||
|
|
||||||
std::string Loader::getFilenameFromPath(const std::string& path) {
|
|
||||||
std::string filename = path.substr(path.find_last_of("/\\") + 1);
|
|
||||||
if (filename.size() == path.size()) {
|
|
||||||
filename = path.substr(path.find_last_of(":\\") + 1);
|
|
||||||
}
|
|
||||||
return filename;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string Loader::getPathFromFilename(const std::string& path) {
|
|
||||||
std::string basepath = path.substr(0, path.find_last_of("/\\"));
|
|
||||||
if (basepath.size() == path.size()) {
|
|
||||||
basepath = path.substr(0, path.find_last_of(":\\"));
|
|
||||||
}
|
|
||||||
return basepath;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string Loader::getFilenameWithoutExtension(const std::string& filename) {
|
|
||||||
auto lastindex = filename.find_last_of(".");
|
|
||||||
return filename.substr(0, lastindex);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string Loader::getExtensionOfFilename(const std::string& filename) {
|
|
||||||
auto lastindex = filename.find_last_of(".");
|
|
||||||
return filename.substr(lastindex + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Tyra
|
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <draw_buffers.h>
|
#include <draw_buffers.h>
|
||||||
#include "loaders/texture/png_loader.hpp"
|
#include "loaders/texture/png_loader.hpp"
|
||||||
|
#include "file/file_utils.hpp"
|
||||||
|
|
||||||
namespace Tyra {
|
namespace Tyra {
|
||||||
|
|
||||||
@@ -32,7 +33,7 @@ TextureBuilderData* PngLoader::load(const char* fullPath) {
|
|||||||
std::string path = fullPath;
|
std::string path = fullPath;
|
||||||
TYRA_ASSERT(!path.empty(), "Provided path is empty!");
|
TYRA_ASSERT(!path.empty(), "Provided path is empty!");
|
||||||
|
|
||||||
auto filename = getFilenameFromPath(path);
|
auto filename = FileUtils::getFilenameFromPath(path);
|
||||||
|
|
||||||
FILE* file = fopen(fullPath, "rb");
|
FILE* file = fopen(fullPath, "rb");
|
||||||
TYRA_ASSERT(file != nullptr, "Failed to load ", fullPath);
|
TYRA_ASSERT(file != nullptr, "Failed to load ", fullPath);
|
||||||
@@ -210,10 +211,6 @@ void PngLoader::handle8bppPalletized(TextureBuilderData* result,
|
|||||||
auto* pixel = static_cast<unsigned char*>(result->data);
|
auto* pixel = static_cast<unsigned char*>(result->data);
|
||||||
struct PngClut* clut = (struct PngClut*)result->clut;
|
struct PngClut* clut = (struct PngClut*)result->clut;
|
||||||
|
|
||||||
for (int i = numPallete; i < 256; i++) {
|
|
||||||
memset(&clut[i], 0, sizeof(clut[i]));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < numPallete; i++) {
|
for (int i = 0; i < numPallete; i++) {
|
||||||
clut[i].r = palette[i].red;
|
clut[i].r = palette[i].red;
|
||||||
clut[i].g = palette[i].green;
|
clut[i].g = palette[i].green;
|
||||||
@@ -272,10 +269,6 @@ void PngLoader::handle4bppPalletized(TextureBuilderData* result,
|
|||||||
auto* pixel = static_cast<unsigned char*>(result->data);
|
auto* pixel = static_cast<unsigned char*>(result->data);
|
||||||
struct PngClut* clut = (struct PngClut*)result->clut;
|
struct PngClut* clut = (struct PngClut*)result->clut;
|
||||||
|
|
||||||
for (int i = numPallete; i < 16; i++) {
|
|
||||||
memset(&clut[i], 0, sizeof(clut[i]));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < numPallete; i++) {
|
for (int i = 0; i < numPallete; i++) {
|
||||||
clut[i].r = palette[i].red;
|
clut[i].r = palette[i].red;
|
||||||
clut[i].g = palette[i].green;
|
clut[i].g = palette[i].green;
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include "renderer/3d/mesh/mesh_material.hpp"
|
#include "renderer/3d/mesh/mesh_material.hpp"
|
||||||
|
#include "file/file_utils.hpp"
|
||||||
|
|
||||||
namespace Tyra {
|
namespace Tyra {
|
||||||
|
|
||||||
@@ -29,7 +30,7 @@ MeshMaterial::MeshMaterial(const MeshBuilderData& data,
|
|||||||
|
|
||||||
id = rand() % 1000000;
|
id = rand() % 1000000;
|
||||||
|
|
||||||
if (data.lightMapEnabled) {
|
if (data.loadLightmap) {
|
||||||
lightmapFlag = true;
|
lightmapFlag = true;
|
||||||
TYRA_ASSERT(material->frames[0]->colors != nullptr,
|
TYRA_ASSERT(material->frames[0]->colors != nullptr,
|
||||||
"Colors faces are required");
|
"Colors faces are required");
|
||||||
@@ -38,8 +39,15 @@ MeshMaterial::MeshMaterial(const MeshBuilderData& data,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ambient.set(material->ambient);
|
ambient.set(material->ambient);
|
||||||
|
|
||||||
name = material->name;
|
name = material->name;
|
||||||
|
|
||||||
|
if (material->texturePath.has_value()) {
|
||||||
|
auto textureFilename =
|
||||||
|
FileUtils::getFilenameFromPath(material->texturePath.value());
|
||||||
|
|
||||||
|
textureName = FileUtils::getFilenameWithoutExtension(textureFilename);
|
||||||
|
}
|
||||||
|
|
||||||
TYRA_ASSERT(name.length() > 0, "MeshMaterial name cannot be empty");
|
TYRA_ASSERT(name.length() > 0, "MeshMaterial name cannot be empty");
|
||||||
|
|
||||||
u32 lastVertexCount = 0;
|
u32 lastVertexCount = 0;
|
||||||
@@ -71,7 +79,7 @@ MeshMaterial::MeshMaterial(const MeshMaterial& mesh) {
|
|||||||
|
|
||||||
lightmapFlag = mesh.lightmapFlag;
|
lightmapFlag = mesh.lightmapFlag;
|
||||||
name = mesh.name;
|
name = mesh.name;
|
||||||
|
textureName = mesh.textureName;
|
||||||
ambient.set(128.0F, 128.0F, 128.0F, 128.0F);
|
ambient.set(128.0F, 128.0F, 128.0F, 128.0F);
|
||||||
|
|
||||||
for (u32 i = 0; i < mesh.frames.size(); i++) {
|
for (u32 i = 0; i < mesh.frames.size(); i++) {
|
||||||
@@ -112,9 +120,14 @@ std::string MeshMaterial::getPrint(const char* name) const {
|
|||||||
res << std::endl;
|
res << std::endl;
|
||||||
res << std::fixed << std::setprecision(2);
|
res << std::fixed << std::setprecision(2);
|
||||||
res << "Id: " << id << ", " << std::endl;
|
res << "Id: " << id << ", " << std::endl;
|
||||||
res << "Name: " << name << ", " << std::endl;
|
res << "Name: " << this->name << ", " << std::endl;
|
||||||
|
|
||||||
|
if (textureName.has_value()) {
|
||||||
|
res << "Texture path: " << textureName.value() << ", " << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
res << "Frames count: " << frames.size() << ", " << std::endl;
|
res << "Frames count: " << frames.size() << ", " << std::endl;
|
||||||
res << "Single color?: " << static_cast<u32>(lightmapFlag) << std::endl;
|
res << "Lightmap?: " << static_cast<u32>(lightmapFlag) << std::endl;
|
||||||
res << ")";
|
res << ")";
|
||||||
|
|
||||||
return res.str();
|
return res.str();
|
||||||
|
|||||||
@@ -36,11 +36,12 @@ MeshMaterialFrame::MeshMaterialFrame(const MeshBuilderData& data,
|
|||||||
TYRA_ASSERT(frame->count > 0, "Vertex count must be greater than 0",
|
TYRA_ASSERT(frame->count > 0, "Vertex count must be greater than 0",
|
||||||
"Material name: ", material->name);
|
"Material name: ", material->name);
|
||||||
TYRA_ASSERT(frame->vertices != nullptr, "Vertex array can't be null");
|
TYRA_ASSERT(frame->vertices != nullptr, "Vertex array can't be null");
|
||||||
TYRA_ASSERT(!data.normalsEnabled || frame->normals != nullptr,
|
TYRA_ASSERT(!data.loadNormals || frame->normals != nullptr,
|
||||||
"Normal array can't be null");
|
"Normal array can't be null");
|
||||||
TYRA_ASSERT(!data.textureCoordsEnabled || frame->textureCoords != nullptr,
|
TYRA_ASSERT(
|
||||||
"Texture coordinate array can't be null");
|
!material->texturePath.has_value() || frame->textureCoords != nullptr,
|
||||||
TYRA_ASSERT(!data.lightMapEnabled || frame->colors != nullptr,
|
"Texture coordinate array can't be null");
|
||||||
|
TYRA_ASSERT(!data.loadLightmap || frame->colors != nullptr,
|
||||||
"Color array can't be null");
|
"Color array can't be null");
|
||||||
|
|
||||||
bbox = new BBox(frame->vertices, frame->count);
|
bbox = new BBox(frame->vertices, frame->count);
|
||||||
@@ -48,7 +49,7 @@ MeshMaterialFrame::MeshMaterialFrame(const MeshBuilderData& data,
|
|||||||
count = frame->count;
|
count = frame->count;
|
||||||
vertices = frame->vertices;
|
vertices = frame->vertices;
|
||||||
|
|
||||||
if (data.normalsEnabled) {
|
if (data.loadNormals) {
|
||||||
normals = frame->normals;
|
normals = frame->normals;
|
||||||
} else {
|
} else {
|
||||||
if (frame->normals != nullptr) delete[] frame->normals;
|
if (frame->normals != nullptr) delete[] frame->normals;
|
||||||
@@ -56,7 +57,7 @@ MeshMaterialFrame::MeshMaterialFrame(const MeshBuilderData& data,
|
|||||||
normals = nullptr;
|
normals = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.textureCoordsEnabled) {
|
if (material->texturePath.has_value()) {
|
||||||
textureCoords = frame->textureCoords;
|
textureCoords = frame->textureCoords;
|
||||||
} else {
|
} else {
|
||||||
if (frame->textureCoords != nullptr) delete[] frame->textureCoords;
|
if (frame->textureCoords != nullptr) delete[] frame->textureCoords;
|
||||||
@@ -64,7 +65,7 @@ MeshMaterialFrame::MeshMaterialFrame(const MeshBuilderData& data,
|
|||||||
textureCoords = nullptr;
|
textureCoords = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.lightMapEnabled) {
|
if (data.loadLightmap) {
|
||||||
colors = frame->colors;
|
colors = frame->colors;
|
||||||
} else {
|
} else {
|
||||||
if (frame->colors != nullptr) delete[] frame->colors;
|
if (frame->colors != nullptr) delete[] frame->colors;
|
||||||
|
|||||||
@@ -160,19 +160,19 @@ void DynPipRenderer::sendObjectData(
|
|||||||
void DynPipRenderer::render(DynPipBag** bags, const u32& count) {
|
void DynPipRenderer::render(DynPipBag** bags, const u32& count) {
|
||||||
if (count <= 0) return;
|
if (count <= 0) return;
|
||||||
|
|
||||||
auto* program = programsRepo->getProgramByBag(bags[0]);
|
addBufferDataToPacket(bags, count);
|
||||||
addBufferDataToPacket(program, bags, count);
|
|
||||||
sendPacket();
|
sendPacket();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynPipRenderer::addBufferDataToPacket(DynPipVU1Program* program,
|
void DynPipRenderer::addBufferDataToPacket(DynPipBag** bags, const u32& count) {
|
||||||
DynPipBag** bags, const u32& count) {
|
|
||||||
currentPacket = packets[context];
|
currentPacket = packets[context];
|
||||||
packet2_reset(currentPacket, false);
|
packet2_reset(currentPacket, false);
|
||||||
|
|
||||||
for (u32 i = 0; i < count; i++) {
|
for (u32 i = 0; i < count; i++) {
|
||||||
if (bags[i]->count <= 0) continue;
|
if (bags[i]->count <= 0) continue;
|
||||||
|
|
||||||
|
auto* program = programsRepo->getProgramByBag(bags[i]);
|
||||||
|
|
||||||
program->addBufferDataToPacket(currentPacket, bags[i], prim);
|
program->addBufferDataToPacket(currentPacket, bags[i], prim);
|
||||||
|
|
||||||
if (lastProgramName != program->getName()) {
|
if (lastProgramName != program->getName()) {
|
||||||
@@ -189,6 +189,8 @@ void DynPipRenderer::addBufferDataToPacket(DynPipVU1Program* program,
|
|||||||
|
|
||||||
void DynPipRenderer::sendPacket() {
|
void DynPipRenderer::sendPacket() {
|
||||||
dma_channel_wait(DMA_CHANNEL_VIF1, 0);
|
dma_channel_wait(DMA_CHANNEL_VIF1, 0);
|
||||||
|
dma_channel_wait(DMA_CHANNEL_GIF, 0); // Wait for texture. Issue #182.
|
||||||
|
|
||||||
// dma_wait_fast(); // This have no impact on performance
|
// dma_wait_fast(); // This have no impact on performance
|
||||||
dma_channel_send_packet2(currentPacket, DMA_CHANNEL_VIF1, true);
|
dma_channel_send_packet2(currentPacket, DMA_CHANNEL_VIF1, true);
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,11 @@ void DynamicPipeline::onUse() {
|
|||||||
|
|
||||||
buffers = new DynPipBag[buffersCount];
|
buffers = new DynPipBag[buffersCount];
|
||||||
|
|
||||||
|
for (u32 i = 0; i < buffersCount; i++) {
|
||||||
|
buffers[i].texture = nullptr;
|
||||||
|
buffers[i].lighting = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
auto packetSize =
|
auto packetSize =
|
||||||
buffersCount * 5.1F; // 5.1 = packet2_get_qw_count / buffersCount
|
buffersCount * 5.1F; // 5.1 = packet2_get_qw_count / buffersCount
|
||||||
|
|
||||||
@@ -96,11 +101,12 @@ void DynamicPipeline::render(const DynamicMesh* mesh,
|
|||||||
|
|
||||||
for (u32 i = 0; i < mesh->materials.size(); i++) {
|
for (u32 i = 0; i < mesh->materials.size(); i++) {
|
||||||
auto* material = mesh->materials[i];
|
auto* material = mesh->materials[i];
|
||||||
|
|
||||||
auto* frameFrom = material->frames[mesh->animation.getState().currentFrame];
|
auto* frameFrom = material->frames[mesh->animation.getState().currentFrame];
|
||||||
auto* frameTo = material->frames[mesh->animation.getState().nextFrame];
|
auto* frameTo = material->frames[mesh->animation.getState().nextFrame];
|
||||||
|
|
||||||
auto partSize = core.getMaxVertCountByParams(
|
auto partSize = core.getMaxVertCountByParams(
|
||||||
options && options->lighting, material->frames[0]->textureCoords);
|
options && options->lighting, material->textureName.has_value());
|
||||||
|
|
||||||
u32 partsCount = ceil(frameFrom->count / static_cast<float>(partSize));
|
u32 partsCount = ceil(frameFrom->count / static_cast<float>(partSize));
|
||||||
|
|
||||||
@@ -109,13 +115,17 @@ void DynamicPipeline::render(const DynamicMesh* mesh,
|
|||||||
setBuffersColorBag(buffers, colorBag);
|
setBuffersColorBag(buffers, colorBag);
|
||||||
u8 isPartInitialized = false;
|
u8 isPartInitialized = false;
|
||||||
|
|
||||||
auto* texture =
|
Texture* texture = nullptr;
|
||||||
rendererCore->texture.repository.getByMeshMaterialId(material->id);
|
|
||||||
|
|
||||||
TYRA_ASSERT(texture, "Texture for material: ", material->name,
|
if (material->textureName.has_value()) {
|
||||||
"Id: ", material->id,
|
texture =
|
||||||
"Was not found in texture repository! Did you forget to add "
|
rendererCore->texture.repository.getByMeshMaterialId(material->id);
|
||||||
"texture or disable texture coords loading in mesh?");
|
|
||||||
|
TYRA_ASSERT(texture, "Texture for material: ", material->name,
|
||||||
|
"Id: ", material->id,
|
||||||
|
"Was not found in texture repository! Did you forget to add "
|
||||||
|
"texture or disable texture coords loading in mesh?");
|
||||||
|
}
|
||||||
|
|
||||||
for (u32 k = 0; k < partsCount; k++) {
|
for (u32 k = 0; k < partsCount; k++) {
|
||||||
auto& buffer = buffers[bufferIndex];
|
auto& buffer = buffers[bufferIndex];
|
||||||
@@ -127,6 +137,7 @@ void DynamicPipeline::render(const DynamicMesh* mesh,
|
|||||||
u32 startIndex = k * partSize;
|
u32 startIndex = k * partSize;
|
||||||
|
|
||||||
addVertices(frameFrom, frameTo, &buffer, startIndex);
|
addVertices(frameFrom, frameTo, &buffer, startIndex);
|
||||||
|
|
||||||
buffer.texture = getTextureBag(texture, frameFrom, frameTo, startIndex);
|
buffer.texture = getTextureBag(texture, frameFrom, frameTo, startIndex);
|
||||||
buffer.lighting = getLightingBag(frameFrom, frameTo, &model, options,
|
buffer.lighting = getLightingBag(frameFrom, frameTo, &model, options,
|
||||||
dirLights, startIndex);
|
dirLights, startIndex);
|
||||||
@@ -139,11 +150,13 @@ void DynamicPipeline::render(const DynamicMesh* mesh,
|
|||||||
setBuffer(buffers, &buffer, &bufferIndex);
|
setBuffer(buffers, &buffer, &bufferIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sendRestOfBuffers(buffers, bufferIndex);
|
||||||
|
bufferIndex = 0;
|
||||||
|
core.begin(infoBag);
|
||||||
|
|
||||||
delete colorBag;
|
delete colorBag;
|
||||||
}
|
}
|
||||||
|
|
||||||
sendRestOfBuffers(buffers, &bufferIndex);
|
|
||||||
|
|
||||||
if (dirLights) {
|
if (dirLights) {
|
||||||
delete dirLights;
|
delete dirLights;
|
||||||
}
|
}
|
||||||
@@ -177,11 +190,12 @@ void DynamicPipeline::setBuffer(DynPipBag* buffers, DynPipBag* buffer,
|
|||||||
*bufferIndex += 1;
|
*bufferIndex += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicPipeline::sendRestOfBuffers(DynPipBag* buffers, u16* bufferIndex) {
|
void DynamicPipeline::sendRestOfBuffers(DynPipBag* buffers,
|
||||||
auto isEndOf1stDBuffer = *bufferIndex <= halfBuffersCount - 1;
|
const u16& bufferIndex) {
|
||||||
|
auto isEndOf1stDBuffer = bufferIndex <= halfBuffersCount - 1;
|
||||||
|
|
||||||
u32 offset = isEndOf1stDBuffer ? 0 : halfBuffersCount;
|
u32 offset = isEndOf1stDBuffer ? 0 : halfBuffersCount;
|
||||||
u32 size = *bufferIndex - offset;
|
u32 size = bufferIndex - offset;
|
||||||
|
|
||||||
if (size <= 0) return;
|
if (size <= 0) return;
|
||||||
|
|
||||||
@@ -258,7 +272,7 @@ DynPipColorBag* DynamicPipeline::getColorBag(
|
|||||||
DynPipTextureBag* DynamicPipeline::getTextureBag(
|
DynPipTextureBag* DynamicPipeline::getTextureBag(
|
||||||
Texture* texture, const MeshMaterialFrame* materialFrameFrom,
|
Texture* texture, const MeshMaterialFrame* materialFrameFrom,
|
||||||
const MeshMaterialFrame* materialFrameTo, const u32& startIndex) {
|
const MeshMaterialFrame* materialFrameTo, const u32& startIndex) {
|
||||||
if (!materialFrameFrom->textureCoords) return nullptr;
|
if (!materialFrameFrom->textureCoords || texture == nullptr) return nullptr;
|
||||||
|
|
||||||
auto* result = new DynPipTextureBag();
|
auto* result = new DynPipTextureBag();
|
||||||
|
|
||||||
|
|||||||
@@ -168,6 +168,8 @@ void BlockizerProgramsManager::sendPacket(McpipProgram* program) {
|
|||||||
packet2_utils_vu_add_end_tag(currentPacket);
|
packet2_utils_vu_add_end_tag(currentPacket);
|
||||||
|
|
||||||
dma_channel_wait(DMA_CHANNEL_VIF1, 0);
|
dma_channel_wait(DMA_CHANNEL_VIF1, 0);
|
||||||
|
dma_channel_wait(DMA_CHANNEL_GIF, 0); // Wait for texture. Issue #182.
|
||||||
|
|
||||||
// dma_wait_fast(); // This have no impact on performance
|
// dma_wait_fast(); // This have no impact on performance
|
||||||
|
|
||||||
dma_channel_send_packet2(currentPacket, DMA_CHANNEL_VIF1, true);
|
dma_channel_send_packet2(currentPacket, DMA_CHANNEL_VIF1, true);
|
||||||
|
|||||||
@@ -365,6 +365,8 @@ void StaPipQBufferRenderer::sendPacket() {
|
|||||||
"Packet is too big. Internal error");
|
"Packet is too big. Internal error");
|
||||||
|
|
||||||
dma_channel_wait(DMA_CHANNEL_VIF1, 0);
|
dma_channel_wait(DMA_CHANNEL_VIF1, 0);
|
||||||
|
dma_channel_wait(DMA_CHANNEL_GIF, 0); // Wait for texture. Issue #182.
|
||||||
|
|
||||||
// dma_wait_fast(); // This have no impact on performance
|
// dma_wait_fast(); // This have no impact on performance
|
||||||
|
|
||||||
dma_channel_send_packet2(currentPacket, DMA_CHANNEL_VIF1, true);
|
dma_channel_send_packet2(currentPacket, DMA_CHANNEL_VIF1, true);
|
||||||
|
|||||||
@@ -65,6 +65,7 @@ void StaticPipeline::render(const StaticMesh* mesh,
|
|||||||
!(options->frustumCulling != PipelineFrustumCulling_Precise &&
|
!(options->frustumCulling != PipelineFrustumCulling_Precise &&
|
||||||
infoBag->fullClipChecks == true),
|
infoBag->fullClipChecks == true),
|
||||||
"Full clip checks are only supported with frustum culling == Precise!");
|
"Full clip checks are only supported with frustum culling == Precise!");
|
||||||
|
|
||||||
TYRA_ASSERT(options->transformationType == TyraMVP ||
|
TYRA_ASSERT(options->transformationType == TyraMVP ||
|
||||||
(!options->fullClipChecks &&
|
(!options->fullClipChecks &&
|
||||||
options->frustumCulling == PipelineFrustumCulling_None),
|
options->frustumCulling == PipelineFrustumCulling_None),
|
||||||
@@ -76,6 +77,10 @@ void StaticPipeline::render(const StaticMesh* mesh,
|
|||||||
if (frame->bbox->frustumCheck(
|
if (frame->bbox->frustumCheck(
|
||||||
rendererCore->renderer3D.frustumPlanes.getAll(), model) ==
|
rendererCore->renderer3D.frustumPlanes.getAll(), model) ==
|
||||||
CoreBBoxFrustum::OUTSIDE_FRUSTUM) {
|
CoreBBoxFrustum::OUTSIDE_FRUSTUM) {
|
||||||
|
if (options && optionsManuallyAllocated) {
|
||||||
|
delete options;
|
||||||
|
}
|
||||||
|
delete infoBag;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -146,7 +151,8 @@ StaPipColorBag* StaticPipeline::getColorBag(
|
|||||||
|
|
||||||
StaPipTextureBag* StaticPipeline::getTextureBag(
|
StaPipTextureBag* StaticPipeline::getTextureBag(
|
||||||
const MeshMaterial* material, const MeshMaterialFrame* materialFrame) {
|
const MeshMaterial* material, const MeshMaterialFrame* materialFrame) {
|
||||||
if (!materialFrame->textureCoords) return nullptr;
|
if (!materialFrame->textureCoords || !material->textureName.has_value())
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
auto* result = new StaPipTextureBag();
|
auto* result = new StaPipTextureBag();
|
||||||
|
|
||||||
|
|||||||
@@ -84,10 +84,12 @@ void RendererCore2D::render(const Sprite& sprite,
|
|||||||
else if (sizeY > sizeX)
|
else if (sizeY > sizeX)
|
||||||
texS = texMax / (sizeY / sizeX);
|
texS = texMax / (sizeY / sizeX);
|
||||||
|
|
||||||
rect->t0.s = sprite.flipHorizontal ? texS : 0.0F;
|
rect->t0.s =
|
||||||
rect->t0.t = sprite.flipVertical ? texT : 0.0F;
|
sprite.flipHorizontal ? (texS + sprite.offset.x) : sprite.offset.x;
|
||||||
rect->t1.s = sprite.flipHorizontal ? 0.0F : texS;
|
rect->t0.t = sprite.flipVertical ? (texT + sprite.offset.y) : sprite.offset.y;
|
||||||
rect->t1.t = sprite.flipVertical ? 0.0F : texT;
|
rect->t1.s =
|
||||||
|
sprite.flipHorizontal ? sprite.offset.x : (texS + sprite.offset.x);
|
||||||
|
rect->t1.t = sprite.flipVertical ? sprite.offset.y : (texT + sprite.offset.y);
|
||||||
|
|
||||||
rect->color.r = sprite.color.r;
|
rect->color.r = sprite.color.r;
|
||||||
rect->color.g = sprite.color.g;
|
rect->color.g = sprite.color.g;
|
||||||
@@ -131,4 +133,10 @@ void RendererCore2D::render(const Sprite& sprite,
|
|||||||
context = !context;
|
context = !context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RendererCore2D::setTextureMappingType(
|
||||||
|
const PipelineTextureMappingType textureMappingType) {
|
||||||
|
lod.mag_filter = textureMappingType;
|
||||||
|
lod.min_filter = textureMappingType;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Tyra
|
} // namespace Tyra
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ Sprite::Sprite() {
|
|||||||
flipVertical = false;
|
flipVertical = false;
|
||||||
size.set(32.0F, 32.0F);
|
size.set(32.0F, 32.0F);
|
||||||
position.set(100.0F, 100.0F);
|
position.set(100.0F, 100.0F);
|
||||||
|
offset.set(0.0F, 0.0F);
|
||||||
scale = 1.0F;
|
scale = 1.0F;
|
||||||
mode = MODE_REPEAT;
|
mode = MODE_REPEAT;
|
||||||
setDefaultColor();
|
setDefaultColor();
|
||||||
|
|||||||
@@ -65,20 +65,20 @@ void Path3::sendTexture(const Texture* texture,
|
|||||||
const RendererCoreTextureBuffers& texBuffers) {
|
const RendererCoreTextureBuffers& texBuffers) {
|
||||||
packet2_reset(texturePacket, false);
|
packet2_reset(texturePacket, false);
|
||||||
|
|
||||||
int coreWidth = texBuffers.core->width <= 64 ? 64 : texBuffers.core->width;
|
packet2_update(
|
||||||
packet2_update(texturePacket,
|
texturePacket,
|
||||||
draw_texture_transfer(texturePacket->base, texture->core->data,
|
draw_texture_transfer(texturePacket->base, texture->core->data,
|
||||||
texture->getWidth(),
|
texture->getWidth(), texture->getHeight(),
|
||||||
texture->getHeight(), texture->core->psm,
|
texture->core->psm, texBuffers.core->address,
|
||||||
texBuffers.core->address, coreWidth));
|
texBuffers.core->width));
|
||||||
|
|
||||||
if (texBuffers.clut != nullptr) {
|
if (texBuffers.clut != nullptr) {
|
||||||
auto* clut = texture->clut;
|
auto* clut = texture->clut;
|
||||||
int clutWidth = texBuffers.clut->width <= 64 ? 64 : texBuffers.clut->width;
|
packet2_update(
|
||||||
packet2_update(texturePacket,
|
texturePacket,
|
||||||
draw_texture_transfer(texturePacket->next, clut->data,
|
draw_texture_transfer(texturePacket->next, clut->data, clut->width,
|
||||||
clut->width, clut->height, clut->psm,
|
clut->height, clut->psm, texBuffers.clut->address,
|
||||||
texBuffers.clut->address, clutWidth));
|
texBuffers.clut->width));
|
||||||
}
|
}
|
||||||
|
|
||||||
packet2_chain_open_cnt(texturePacket, 0, 0, 0);
|
packet2_chain_open_cnt(texturePacket, 0, 0, 0);
|
||||||
|
|||||||
@@ -19,8 +19,18 @@
|
|||||||
|
|
||||||
namespace Tyra {
|
namespace Tyra {
|
||||||
|
|
||||||
|
namespace TyraTexture {
|
||||||
|
u32 textureCounter = 1;
|
||||||
|
std::vector<u32> deletedIDs;
|
||||||
|
} // namespace TyraTexture
|
||||||
|
|
||||||
Texture::Texture(TextureBuilderData* t_data) {
|
Texture::Texture(TextureBuilderData* t_data) {
|
||||||
id = rand() % 1000000;
|
if (TyraTexture::deletedIDs.empty() == false) {
|
||||||
|
id = TyraTexture::deletedIDs.front();
|
||||||
|
TyraTexture::deletedIDs.erase(TyraTexture::deletedIDs.begin());
|
||||||
|
} else {
|
||||||
|
id = TyraTexture::textureCounter++;
|
||||||
|
}
|
||||||
|
|
||||||
name = t_data->name;
|
name = t_data->name;
|
||||||
|
|
||||||
@@ -50,6 +60,7 @@ Texture::Texture(TextureBuilderData* t_data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Texture::~Texture() {
|
Texture::~Texture() {
|
||||||
|
TyraTexture::deletedIDs.push_back(id);
|
||||||
if (links.size() > 0) links.clear();
|
if (links.size() > 0) links.clear();
|
||||||
if (core) delete core;
|
if (core) delete core;
|
||||||
if (clut) delete clut;
|
if (clut) delete clut;
|
||||||
@@ -167,9 +178,14 @@ void Texture::setDefaultWrapSettings() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Texture::setWrapSettings(const TextureWrap t_horizontal,
|
void Texture::setWrapSettings(const TextureWrap t_horizontal,
|
||||||
const TextureWrap t_vertical) {
|
const TextureWrap t_vertical, int minu, int minv,
|
||||||
|
int maxu, int maxv) {
|
||||||
wrap.horizontal = t_horizontal;
|
wrap.horizontal = t_horizontal;
|
||||||
wrap.vertical = t_vertical;
|
wrap.vertical = t_vertical;
|
||||||
|
wrap.minu = minu;
|
||||||
|
wrap.minv = minv;
|
||||||
|
wrap.maxu = maxu;
|
||||||
|
wrap.maxv = maxv;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Texture::addLink(const u32& t_id) {
|
void Texture::addLink(const u32& t_id) {
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ RendererCoreTexture::~RendererCoreTexture() {}
|
|||||||
void RendererCoreTexture::init(RendererCoreGS* t_gs, Path3* t_path3) {
|
void RendererCoreTexture::init(RendererCoreGS* t_gs, Path3* t_path3) {
|
||||||
gs = t_gs;
|
gs = t_gs;
|
||||||
sender.init(t_path3, t_gs);
|
sender.init(t_path3, t_gs);
|
||||||
|
repository.init(¤tAllocations);
|
||||||
path3 = t_path3;
|
path3 = t_path3;
|
||||||
initClut();
|
initClut();
|
||||||
}
|
}
|
||||||
@@ -56,6 +57,17 @@ RendererCoreTextureBuffers RendererCoreTexture::useTexture(
|
|||||||
return newTexBuffer;
|
return newTexBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RendererCoreTextureBuffers RendererCoreTexture::updateTextureInfo(
|
||||||
|
const Texture* t_tex) {
|
||||||
|
TYRA_ASSERT(t_tex != nullptr, "Provided nullptr texture!");
|
||||||
|
|
||||||
|
auto allocated = getAllocatedBuffersByTextureId(t_tex->id);
|
||||||
|
TYRA_ASSERT(allocated.id != 0, "Can't update an unallocated texture!");
|
||||||
|
|
||||||
|
path3->sendTexture(t_tex, allocated);
|
||||||
|
return allocated;
|
||||||
|
}
|
||||||
|
|
||||||
RendererCoreTextureBuffers RendererCoreTexture::getAllocatedBuffersByTextureId(
|
RendererCoreTextureBuffers RendererCoreTexture::getAllocatedBuffersByTextureId(
|
||||||
const u32& t_id) {
|
const u32& t_id) {
|
||||||
for (u32 i = 0; i < currentAllocations.size(); i++)
|
for (u32 i = 0; i < currentAllocations.size(); i++)
|
||||||
|
|||||||
@@ -58,7 +58,19 @@ texbuffer_t* RendererCoreTextureSender::allocateTextureCore(
|
|||||||
auto* result = new texbuffer_t;
|
auto* result = new texbuffer_t;
|
||||||
const auto* core = t_texture->core;
|
const auto* core = t_texture->core;
|
||||||
|
|
||||||
result->width = t_texture->getWidth();
|
switch (core->psm) {
|
||||||
|
case GS_PSM_8:
|
||||||
|
case GS_PSM_4:
|
||||||
|
case GS_PSM_8H:
|
||||||
|
case GS_PSM_4HL:
|
||||||
|
case GS_PSM_4HH:
|
||||||
|
result->width = -128 & (core->width + 127);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
result->width = -64 & (core->width + 63);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
result->psm = core->psm;
|
result->psm = core->psm;
|
||||||
result->info.components = core->components;
|
result->info.components = core->components;
|
||||||
|
|
||||||
@@ -77,7 +89,9 @@ texbuffer_t* RendererCoreTextureSender::allocateTextureClut(
|
|||||||
auto* result = new texbuffer_t;
|
auto* result = new texbuffer_t;
|
||||||
const auto* clut = t_texture->clut;
|
const auto* clut = t_texture->clut;
|
||||||
|
|
||||||
result->width = clut->width;
|
int clutWidth = clut->width <= 64 ? 64 : clut->width;
|
||||||
|
|
||||||
|
result->width = clutWidth;
|
||||||
result->psm = clut->psm;
|
result->psm = clut->psm;
|
||||||
result->info.components = clut->components;
|
result->info.components = clut->components;
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,11 @@ TextureRepository::~TextureRepository() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TextureRepository::init(
|
||||||
|
std::vector<RendererCoreTextureBuffers>* t_textureBuffers) {
|
||||||
|
textureBuffers = t_textureBuffers;
|
||||||
|
}
|
||||||
|
|
||||||
Texture* TextureRepository::getBySpriteId(const u32& t_id) const {
|
Texture* TextureRepository::getBySpriteId(const u32& t_id) const {
|
||||||
for (u32 i = 0; i < textures.size(); i++) {
|
for (u32 i = 0; i < textures.size(); i++) {
|
||||||
if (textures[i]->isLinkedWith(t_id)) return textures[i];
|
if (textures[i]->isLinkedWith(t_id)) return textures[i];
|
||||||
@@ -57,10 +62,20 @@ void TextureRepository::removeByIndex(const u32& t_index) {
|
|||||||
textures.erase(textures.begin() + t_index);
|
textures.erase(textures.begin() + t_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int TextureRepository::removeBufferId(const u32& t_texId) {
|
||||||
|
for (u32 i = 0; i < textureBuffers->size(); i++)
|
||||||
|
if ((*textureBuffers)[i].id == t_texId) {
|
||||||
|
(*textureBuffers)[i].id = -1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
void TextureRepository::removeById(const u32& t_texId) {
|
void TextureRepository::removeById(const u32& t_texId) {
|
||||||
s32 index = getIndexOf(t_texId);
|
s32 index = getIndexOf(t_texId);
|
||||||
TYRA_ASSERT(index != -1, "Cant remove texture, because it was not found!");
|
TYRA_ASSERT(index != -1, "Cant remove texture, because it was not found!");
|
||||||
removeByIndex(index);
|
removeByIndex(index);
|
||||||
|
removeBufferId(t_texId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureRepository::freeByMesh(const Mesh& mesh) {
|
void TextureRepository::freeByMesh(const Mesh& mesh) {
|
||||||
@@ -93,6 +108,7 @@ void TextureRepository::free(const u32& t_texId) {
|
|||||||
|
|
||||||
TYRA_ASSERT(index != -1, "Cant remove texture, because it was not found!");
|
TYRA_ASSERT(index != -1, "Cant remove texture, because it was not found!");
|
||||||
removeByIndex(index);
|
removeByIndex(index);
|
||||||
|
removeBufferId(t_texId);
|
||||||
|
|
||||||
delete tex;
|
delete tex;
|
||||||
}
|
}
|
||||||
@@ -116,8 +132,12 @@ void TextureRepository::addByMesh(const Mesh* mesh, const char* directory,
|
|||||||
if (dirFixed.back() != '/' && dirFixed.back() != ':') dirFixed += "/";
|
if (dirFixed.back() != '/' && dirFixed.back() != ':') dirFixed += "/";
|
||||||
|
|
||||||
for (u32 i = 0; i < mesh->materials.size(); i++) {
|
for (u32 i = 0; i < mesh->materials.size(); i++) {
|
||||||
|
if (!mesh->materials[i]->textureName.has_value()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
std::string fullPath =
|
std::string fullPath =
|
||||||
dirFixed + mesh->materials[i]->name + "." + extension;
|
dirFixed + mesh->materials[i]->textureName.value() + "." + extension;
|
||||||
|
|
||||||
auto* data = loader.load(fullPath.c_str());
|
auto* data = loader.load(fullPath.c_str());
|
||||||
Texture* texture = new Texture(data);
|
Texture* texture = new Texture(data);
|
||||||
|
|||||||
Executable
+74
@@ -0,0 +1,74 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
get_target_elf_name() {
|
||||||
|
if [ -f "./Makefile" ]; then
|
||||||
|
grep -oP '\S+\.elf' Makefile | head -n 1
|
||||||
|
else
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
find_pcsx2() {
|
||||||
|
if [ -n "$CUSTOM_PCSX2_PATH" ]; then
|
||||||
|
echo "$CUSTOM_PCSX2_PATH"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check flatpak
|
||||||
|
if command -v flatpak >/dev/null 2>&1 && flatpak list | grep -q "net.pcsx2.PCSX2"; then
|
||||||
|
echo "flatpak run net.pcsx2.PCSX2"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if pcsx2-qt is in PATH
|
||||||
|
if command -v pcsx2-qt >/dev/null 2>&1; then
|
||||||
|
echo "pcsx2-qt"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check if pcsx2 is in PATH
|
||||||
|
if command -v pcsx2 >/dev/null 2>&1; then
|
||||||
|
echo "pcsx2"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Error: PCSX2 not found! Please install it, put it in PATH, or specify CUSTOM_PCSX2_PATH in this script." >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
run_pcsx2() {
|
||||||
|
local pcsx2_cmd
|
||||||
|
pcsx2_cmd=$(find_pcsx2)
|
||||||
|
|
||||||
|
local elf_name
|
||||||
|
elf_name=$(get_target_elf_name)
|
||||||
|
if [ -z "$elf_name" ]; then
|
||||||
|
echo "Error: Could not find target ELF name in Makefile!" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
local target_file
|
||||||
|
target_file="$(pwd)/bin/$elf_name"
|
||||||
|
|
||||||
|
if [ ! -f "$target_file" ]; then
|
||||||
|
echo "Error: ELF file not found at $target_file. Did you build the project?" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Kill existing PCSX2 instances
|
||||||
|
if [[ "$pcsx2_cmd" == *"flatpak"* ]]; then
|
||||||
|
pkill -f "net.pcsx2.PCSX2" >/dev/null 2>&1 || true
|
||||||
|
pkill -f "pcsx2-qt" >/dev/null 2>&1 || true
|
||||||
|
else
|
||||||
|
local bin_name
|
||||||
|
bin_name=$(basename "$pcsx2_cmd")
|
||||||
|
pkill "$bin_name" >/dev/null 2>&1 || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Running PCSX2: $pcsx2_cmd -elf $target_file"
|
||||||
|
|
||||||
|
# Run PCSX2 in the background
|
||||||
|
$pcsx2_cmd -elf "$target_file" &
|
||||||
|
}
|
||||||
|
|
||||||
|
run_pcsx2
|
||||||
Submodule
+1
Submodule template added at 401fce7918
@@ -1,40 +0,0 @@
|
|||||||
# Use the Google style in this project.
|
|
||||||
BasedOnStyle: Google
|
|
||||||
|
|
||||||
# Some folks prefer to write "int& foo" while others prefer "int &foo". The
|
|
||||||
# Google Style Guide only asks for consistency within a project, we chose
|
|
||||||
# "int& foo" for this project:
|
|
||||||
DerivePointerAlignment: false
|
|
||||||
PointerAlignment: Left
|
|
||||||
|
|
||||||
SortIncludes: false
|
|
||||||
|
|
||||||
IncludeBlocks: Merge
|
|
||||||
IncludeCategories:
|
|
||||||
# Matches common headers first, but sorts them after project includes
|
|
||||||
- Regex: '^\"google/cloud/internal/disable_deprecation_warnings.inc\"$'
|
|
||||||
Priority: -1
|
|
||||||
- Regex: '^\"google/cloud/(internal/|grpc_utils/|testing_util/|[^/]+\.h)'
|
|
||||||
Priority: 1000
|
|
||||||
- Regex: '^\"google/cloud/' # project includes should sort first
|
|
||||||
Priority: 500
|
|
||||||
- Regex: '^\"'
|
|
||||||
Priority: 1500
|
|
||||||
- Regex: '^<grpc/'
|
|
||||||
Priority: 2000
|
|
||||||
- Regex: '^<google/*'
|
|
||||||
Priority: 3000
|
|
||||||
- Regex: '^<.*/.*'
|
|
||||||
Priority: 4000
|
|
||||||
- Regex: '^<[^/]*>'
|
|
||||||
Priority: 5000
|
|
||||||
|
|
||||||
# Format raw string literals with a `pb` or `proto` tag as proto.
|
|
||||||
RawStringFormats:
|
|
||||||
- Language: TextProto
|
|
||||||
Delimiters:
|
|
||||||
- 'pb'
|
|
||||||
- 'proto'
|
|
||||||
BasedOnStyle: Google
|
|
||||||
|
|
||||||
CommentPragmas: '(@copydoc)'
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
*.elf
|
|
||||||
.git/
|
|
||||||
.vscode/
|
|
||||||
docs/
|
|
||||||
tools/
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
# Ignore all differences in line endings
|
|
||||||
* -crlf
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
# ---
|
|
||||||
|
|
||||||
# Prerequisites
|
|
||||||
*.d
|
|
||||||
|
|
||||||
# Compiled Object files
|
|
||||||
*.slo
|
|
||||||
*.lo
|
|
||||||
*.o
|
|
||||||
*.vsm
|
|
||||||
|
|
||||||
# Precompiled Headers
|
|
||||||
*.gch
|
|
||||||
*.pch
|
|
||||||
|
|
||||||
# Compiled Dynamic libraries
|
|
||||||
*.so
|
|
||||||
*.dylib
|
|
||||||
*.dll
|
|
||||||
|
|
||||||
# Compiled Static libraries
|
|
||||||
*.lai
|
|
||||||
*.la
|
|
||||||
*.a
|
|
||||||
*.lib
|
|
||||||
|
|
||||||
# Executables
|
|
||||||
*.exe
|
|
||||||
*.out
|
|
||||||
*.app
|
|
||||||
*.erl
|
|
||||||
*.elf
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
*.log
|
|
||||||
|
|
||||||
# Configuration files
|
|
||||||
/c_cpp_properties.json
|
|
||||||
/tasks.json
|
|
||||||
/settings.json
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
{
|
|
||||||
"configurations": [
|
|
||||||
{
|
|
||||||
"name": "Docker PS2SDK",
|
|
||||||
"includePath": [
|
|
||||||
"${workspaceFolder}/**",
|
|
||||||
"C:/Users/YOUR-INTELLISENSE-PATH/ps2dev-intellisense/tyra/inc/**",
|
|
||||||
"C:/Users/YOUR-INTELLISENSE-PATH/ps2dev-intellisense/ps2sdk/common/include/**",
|
|
||||||
"C:/Users/YOUR-INTELLISENSE-PATH/ps2dev-intellisense/ps2sdk/ee/include/**",
|
|
||||||
"C:/Users/YOUR-INTELLISENSE-PATH/ps2dev-intellisense/ps2sdk/iop/include/**",
|
|
||||||
"C:/Users/YOUR-INTELLISENSE-PATH/ps2dev-intellisense/ps2sdk/ports/include/**",
|
|
||||||
"C:/Users/YOUR-INTELLISENSE-PATH/ps2dev-intellisense/ee/include/**",
|
|
||||||
"C:/Users/YOUR-INTELLISENSE-PATH/ps2dev-intellisense/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/include/**",
|
|
||||||
"C:/Users/YOUR-INTELLISENSE-PATH/ps2dev-intellisense/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/include-fixed/**",
|
|
||||||
"C:/Users/YOUR-INTELLISENSE-PATH/ps2dev-intellisense/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/install-tools/include/**",
|
|
||||||
"C:/Users/YOUR-INTELLISENSE-PATH/ps2dev-intellisense/ee/lib/gcc/mips64r5900el-ps2-elf/11.3.0/plugin/include/**",
|
|
||||||
"C:/Users/YOUR-INTELLISENSE-PATH/ps2dev-intellisense/ee/mips64r5900el-ps2-elf/include/**",
|
|
||||||
"C:/Users/YOUR-INTELLISENSE-PATH/ps2dev-intellisense/ee/mips64r5900el-ps2-elf/sys-include/**",
|
|
||||||
"C:/Users/YOUR-INTELLISENSE-PATH/ps2dev-intellisense/gsKit/include/**",
|
|
||||||
"C:/Users/YOUR-INTELLISENSE-PATH/ps2dev-intellisense/iop/lib/gcc/mipsel-ps2-elf/11.3.0/include/**",
|
|
||||||
"C:/Users/YOUR-INTELLISENSE-PATH/ps2dev-intellisense/iop/lib/gcc/mipsel-ps2-elf/11.3.0/install-tools/include/**",
|
|
||||||
"C:/Users/YOUR-INTELLISENSE-PATH/ps2dev-intellisense/iop/lib/gcc/mipsel-ps2-elf/11.3.0/plugin/include/**",
|
|
||||||
"C:/Users/YOUR-INTELLISENSE-PATH/ps2dev-intellisense/iop/lib/gcc/mipsel-ps2-elf/11.3.0/include-fixed/**",
|
|
||||||
"C:/Users/YOUR-INTELLISENSE-PATH/ps2dev-intellisense/iop/lib/gcc/mipsel-ps2-irx/11.3.0/include/**",
|
|
||||||
"C:/Users/YOUR-INTELLISENSE-PATH/ps2dev-intellisense/iop/lib/gcc/mipsel-ps2-irx/11.3.0/install-tools/include/**",
|
|
||||||
"C:/Users/YOUR-INTELLISENSE-PATH/ps2dev-intellisense/iop/lib/gcc/mipsel-ps2-irx/11.3.0/plugin/include/**",
|
|
||||||
"C:/Users/YOUR-INTELLISENSE-PATH/ps2dev-intellisense/iop/lib/gcc/mipsel-ps2-irx/11.3.0/include-fixed/**"
|
|
||||||
],
|
|
||||||
"defines": [
|
|
||||||
"_EE",
|
|
||||||
"_IOP",
|
|
||||||
"__SPU__",
|
|
||||||
"INTELLISENSE"
|
|
||||||
],
|
|
||||||
"cppStandard": "c++20",
|
|
||||||
"compilerPath": "", // Should be empty
|
|
||||||
"intelliSenseMode": "linux-gcc-x86",
|
|
||||||
"configurationProvider": "ms-vscode.cpptools"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"version": 4
|
|
||||||
}
|
|
||||||
Vendored
-7
@@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
"recommendations": [
|
|
||||||
"ms-vscode.cpptools-extension-pack",
|
|
||||||
"ryzngard.vscode-header-source",
|
|
||||||
"maziac.asm-code-lens"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
# syntax=docker/dockerfile:1
|
|
||||||
FROM h4570/tyra
|
|
||||||
|
|
||||||
RUN apt-get update
|
|
||||||
RUN apt-get install git -y
|
|
||||||
|
|
||||||
WORKDIR /src
|
|
||||||
CMD ["/bin/bash"]
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
TARGET := racer.elf
|
|
||||||
ENGINEDIR := /tyra/engine
|
|
||||||
|
|
||||||
#The Directories, Source, Includes, Objects, Binary and Resources
|
|
||||||
SRCDIR := src
|
|
||||||
INCDIR := inc
|
|
||||||
BUILDDIR := obj
|
|
||||||
TARGETDIR := bin
|
|
||||||
RESDIR := res
|
|
||||||
SRCEXT := cpp
|
|
||||||
VSMEXT := vsm
|
|
||||||
VCLEXT := vcl
|
|
||||||
VCLPPEXT := vclpp
|
|
||||||
DEPEXT := d
|
|
||||||
OBJEXT := o
|
|
||||||
|
|
||||||
#Flags, Libraries and Includes
|
|
||||||
CFLAGS :=
|
|
||||||
LIB := -ltyra
|
|
||||||
LIBDIRS := -L$(ENGINEDIR)/bin
|
|
||||||
INC := -I$(INCDIR) -I$(ENGINEDIR)/inc
|
|
||||||
INCDEP := -I$(INCDIR) -I$(ENGINEDIR)/inc
|
|
||||||
|
|
||||||
include /tyra/Makefile.base
|
|
||||||
|
|
||||||
clean-engine:
|
|
||||||
cd $(ENGINEDIR) && $(MAKE) cleaner
|
|
||||||
|
|
||||||
build-engine:
|
|
||||||
cd $(ENGINEDIR) && $(MAKE)
|
|
||||||
|
|
||||||
build-release-engine:
|
|
||||||
cd $(ENGINEDIR) && $(MAKE) release
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
version: "3.9"
|
|
||||||
volumes:
|
|
||||||
tyra-game-volume:
|
|
||||||
services:
|
|
||||||
compiler:
|
|
||||||
environment:
|
|
||||||
TERM: xterm-256color
|
|
||||||
network_mode: host
|
|
||||||
build:
|
|
||||||
context: ./
|
|
||||||
dockerfile: Dockerfile
|
|
||||||
tty: true
|
|
||||||
container_name: tyra-game-compiler
|
|
||||||
volumes:
|
|
||||||
- tyra-game-volume:/src
|
|
||||||
- ./:/host
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include <engine.hpp>
|
|
||||||
#include <game.hpp>
|
|
||||||
|
|
||||||
namespace Racer {
|
|
||||||
|
|
||||||
class RacerGame : public Tyra::Game {
|
|
||||||
public:
|
|
||||||
RacerGame(Tyra::Engine* engine);
|
|
||||||
~RacerGame();
|
|
||||||
|
|
||||||
void init();
|
|
||||||
void loop();
|
|
||||||
|
|
||||||
private:
|
|
||||||
Tyra::Engine* engine;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Racer
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
$ConfigFile = Join-Path $PSScriptRoot './windows-pcsx2.ps1'
|
|
||||||
. $ConfigFile
|
|
||||||
|
|
||||||
RunPCSX2
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
#include "engine.hpp"
|
|
||||||
#include "racer_game.hpp"
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
Tyra::Engine engine;
|
|
||||||
Racer::RacerGame game(&engine);
|
|
||||||
engine.run(&game);
|
|
||||||
SleepThread();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
#include "racer_game.hpp"
|
|
||||||
|
|
||||||
namespace Racer {
|
|
||||||
|
|
||||||
using namespace Tyra;
|
|
||||||
|
|
||||||
RacerGame::RacerGame(Engine* t_engine) { engine = t_engine; }
|
|
||||||
RacerGame::~RacerGame() {}
|
|
||||||
|
|
||||||
void RacerGame::init() { TYRA_LOG("Hello!"); }
|
|
||||||
|
|
||||||
void RacerGame::loop() { TYRA_LOG("Loop!"); }
|
|
||||||
|
|
||||||
} // namespace Racer
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
$PCSX2_PATH = "${Env:ProgramFiles(x86)}/PCSX2"
|
|
||||||
$PCSX2_EXE = 'pcsx2.exe'
|
|
||||||
|
|
||||||
function GetTargetELFName {
|
|
||||||
return (Select-String -Path './Makefile' -Pattern "[^ ]*.elf").Matches.Value
|
|
||||||
}
|
|
||||||
|
|
||||||
function RunPCSX2 {
|
|
||||||
$PCSX2_EXE_WITHOUT_EXT = (Split-Path $PCSX2_EXE -Leaf).Split('.')[0]
|
|
||||||
Stop-Process -Name $PCSX2_EXE_WITHOUT_EXT -ErrorAction 'SilentlyContinue'
|
|
||||||
Start-Process -FilePath "$PCSX2_PATH/$PCSX2_EXE" -ArgumentList "--elf=$PWD/bin/$(GetTargetELFName)"
|
|
||||||
}
|
|
||||||
Executable
+4
@@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
SCRIPT_DIR=$(dirname "$(readlink -f "$0")")
|
||||||
|
cd "$SCRIPT_DIR" || exit 1
|
||||||
|
../../linux-pcsx2.sh
|
||||||
Executable
+4
@@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
SCRIPT_DIR=$(dirname "$(readlink -f "$0")")
|
||||||
|
cd "$SCRIPT_DIR" || exit 1
|
||||||
|
../../linux-pcsx2.sh
|
||||||
Executable
+4
@@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
SCRIPT_DIR=$(dirname "$(readlink -f "$0")")
|
||||||
|
cd "$SCRIPT_DIR" || exit 1
|
||||||
|
../../linux-pcsx2.sh
|
||||||
Executable
+4
@@ -0,0 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
SCRIPT_DIR=$(dirname "$(readlink -f "$0")")
|
||||||
|
cd "$SCRIPT_DIR" || exit 1
|
||||||
|
../../linux-pcsx2.sh
|
||||||
@@ -37,9 +37,8 @@ void Tutorial04::loop() {
|
|||||||
/**
|
/**
|
||||||
* Render de_dust2.
|
* Render de_dust2.
|
||||||
*
|
*
|
||||||
* As you see there are clipping issues (visual glitches).
|
* If you see clipping issues (visual glitches),
|
||||||
* If you want to know how to fix it, please
|
* You can check how to fix them in #02 YT tutorial.
|
||||||
* watch video tutorial.
|
|
||||||
*/
|
*/
|
||||||
stapip.render(mesh.get(), renderOptions);
|
stapip.render(mesh.get(), renderOptions);
|
||||||
}
|
}
|
||||||
@@ -52,7 +51,7 @@ void Tutorial04::loadMesh() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Load mesh data
|
* Load mesh data
|
||||||
* Texture names are the material names "usemtl <material name>"
|
* Texture file names are loaded from .mtl file (map_Kd field).
|
||||||
*/
|
*/
|
||||||
auto data =
|
auto data =
|
||||||
ObjLoader::load(FileUtils::fromCwd("de_dust2/de_dust2.obj"), options);
|
ObjLoader::load(FileUtils::fromCwd("de_dust2/de_dust2.obj"), options);
|
||||||
@@ -68,8 +67,9 @@ void Tutorial04::loadMesh() {
|
|||||||
renderOptions.frustumCulling = Tyra::PipelineFrustumCulling_None;
|
renderOptions.frustumCulling = Tyra::PipelineFrustumCulling_None;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function which load all textures into texture repository,
|
* Function which load all textures into texture repository.
|
||||||
* based on material names.
|
* It will automatically extract filename from path (map_Kd) and add
|
||||||
|
* proper extension.
|
||||||
*/
|
*/
|
||||||
engine->renderer.getTextureRepository().addByMesh(
|
engine->renderer.getTextureRepository().addByMesh(
|
||||||
mesh.get(), FileUtils::fromCwd("de_dust2/"), "png");
|
mesh.get(), FileUtils::fromCwd("de_dust2/"), "png");
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user