Compare commits
10 Commits
e56ff20e2d
...
editor
| Author | SHA1 | Date | |
|---|---|---|---|
| 888918face | |||
| 0885da8d44 | |||
| 8af961c6d3 | |||
| ef5febdde3 | |||
| 6d7fbd3926 | |||
| 2680d373d8 | |||
| 2b2ddb3cf2 | |||
| 85ff95296b | |||
| 314a2de41a | |||
| 26fafab47a |
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@@ -106,7 +106,7 @@ jobs:
|
|||||||
- name: Copy output files.
|
- name: Copy output files.
|
||||||
run: |
|
run: |
|
||||||
mkdir -p ./git-artifcats/Dusk/apps/Dusk
|
mkdir -p ./git-artifcats/Dusk/apps/Dusk
|
||||||
cp build-wii/Dusk.dol ./git-artifcats/Dusk/apps/Dusk/Dusk.dol
|
cp build-wii/Dusk.dol ./git-artifcats/Dusk/apps/Dusk/boot.dol
|
||||||
cp build-wii/dusk.dsk ./git-artifcats/Dusk/apps/Dusk/dusk.dsk
|
cp build-wii/dusk.dsk ./git-artifcats/Dusk/apps/Dusk/dusk.dsk
|
||||||
cp docker/dolphin/meta.xml ./git-artifcats/Dusk/apps/Dusk/meta.xml
|
cp docker/dolphin/meta.xml ./git-artifcats/Dusk/apps/Dusk/meta.xml
|
||||||
- name: Upload Wii binary
|
- name: Upload Wii binary
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ elseif LINUX then
|
|||||||
inputBind("mouse_x", INPUT_ACTION_POINTERX)
|
inputBind("mouse_x", INPUT_ACTION_POINTERX)
|
||||||
inputBind("mouse_y", INPUT_ACTION_POINTERY)
|
inputBind("mouse_y", INPUT_ACTION_POINTERY)
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
print("Unknown platform, no default input bindings set.")
|
print("Unknown platform, no default input bindings set.")
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ end
|
|||||||
|
|
||||||
function sceneUpdate()
|
function sceneUpdate()
|
||||||
x = x + inputAxis(INPUT_ACTION_LEFT, INPUT_ACTION_RIGHT)
|
x = x + inputAxis(INPUT_ACTION_LEFT, INPUT_ACTION_RIGHT)
|
||||||
y = y - inputAxis(INPUT_ACTION_UP, INPUT_ACTION_DOWN)
|
y = y + inputAxis(INPUT_ACTION_UP, INPUT_ACTION_DOWN)
|
||||||
end
|
end
|
||||||
|
|
||||||
function sceneRender()
|
function sceneRender()
|
||||||
@@ -195,13 +195,16 @@ function sceneRender()
|
|||||||
view = cameraGetViewMatrix(camera)
|
view = cameraGetViewMatrix(camera)
|
||||||
shaderSetMatrix(SHADER_UNLIT, SHADER_UNLIT_VIEW, view)
|
shaderSetMatrix(SHADER_UNLIT, SHADER_UNLIT_VIEW, view)
|
||||||
|
|
||||||
textDraw(10, 10, "Hello World\nHow are you?")
|
shaderSetTexture(SHADER_UNLIT, SHADER_UNLIT_TEXTURE, nil)
|
||||||
|
spriteBatchPush(
|
||||||
|
x, y,
|
||||||
|
x + 32, y + 32,
|
||||||
|
colorWhite()
|
||||||
|
)
|
||||||
|
spriteBatchFlush()
|
||||||
|
|
||||||
-- spriteBatchPush(
|
textDraw(10, 10, "Hello World\nHow are you?", colorRed())
|
||||||
-- x, y,
|
spriteBatchFlush()
|
||||||
-- x + 32, y + 32,
|
|
||||||
-- colorWhite()
|
|
||||||
-- )
|
|
||||||
|
|
||||||
-- Update mouse position
|
-- Update mouse position
|
||||||
-- if INPUT_POINTER then
|
-- if INPUT_POINTER then
|
||||||
@@ -258,5 +261,4 @@ function sceneRender()
|
|||||||
-- )
|
-- )
|
||||||
-- end
|
-- end
|
||||||
-- end
|
-- end
|
||||||
spriteBatchFlush()
|
|
||||||
end
|
end
|
||||||
41
editor/.gitignore
vendored
Normal file
41
editor/.gitignore
vendored
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||||
|
|
||||||
|
# dependencies
|
||||||
|
/node_modules
|
||||||
|
/.pnp
|
||||||
|
.pnp.*
|
||||||
|
.yarn/*
|
||||||
|
!.yarn/patches
|
||||||
|
!.yarn/plugins
|
||||||
|
!.yarn/releases
|
||||||
|
!.yarn/versions
|
||||||
|
|
||||||
|
# testing
|
||||||
|
/coverage
|
||||||
|
|
||||||
|
# next.js
|
||||||
|
/.next/
|
||||||
|
/out/
|
||||||
|
|
||||||
|
# production
|
||||||
|
/build
|
||||||
|
|
||||||
|
# misc
|
||||||
|
.DS_Store
|
||||||
|
*.pem
|
||||||
|
|
||||||
|
# debug
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
.pnpm-debug.log*
|
||||||
|
|
||||||
|
# env files (can opt-in for committing if needed)
|
||||||
|
.env*
|
||||||
|
|
||||||
|
# vercel
|
||||||
|
.vercel
|
||||||
|
|
||||||
|
# typescript
|
||||||
|
*.tsbuildinfo
|
||||||
|
next-env.d.ts
|
||||||
8
editor/next.config.ts
Normal file
8
editor/next.config.ts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import type { NextConfig } from "next";
|
||||||
|
|
||||||
|
const nextConfig: NextConfig = {
|
||||||
|
/* config options here */
|
||||||
|
reactCompiler: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default nextConfig;
|
||||||
23
editor/package.json
Normal file
23
editor/package.json
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"name": "dusk-editor",
|
||||||
|
"version": "0.1.0",
|
||||||
|
"private": true,
|
||||||
|
"scripts": {
|
||||||
|
"start:dev": "next dev",
|
||||||
|
"build:prod": "next build",
|
||||||
|
"start:prod": "next start"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"next": "16.2.1",
|
||||||
|
"react": "19.2.4",
|
||||||
|
"react-dom": "19.2.4",
|
||||||
|
"sass": "^1.98.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/node": "^20",
|
||||||
|
"@types/react": "^19",
|
||||||
|
"@types/react-dom": "^19",
|
||||||
|
"babel-plugin-react-compiler": "1.0.0",
|
||||||
|
"typescript": "^5"
|
||||||
|
}
|
||||||
|
}
|
||||||
23
editor/src/app/layout.tsx
Normal file
23
editor/src/app/layout.tsx
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import type { Metadata } from "next";
|
||||||
|
import "@/styles/styles.scss";
|
||||||
|
import Navbar from "@/components/Navbar/Navbar";
|
||||||
|
|
||||||
|
export const metadata: Metadata = {
|
||||||
|
title: "Dusk Editor",
|
||||||
|
description: "Editor for the Dusk Game Engine",
|
||||||
|
};
|
||||||
|
|
||||||
|
export default function RootLayout({
|
||||||
|
children,
|
||||||
|
}: Readonly<{
|
||||||
|
children: React.ReactNode;
|
||||||
|
}>) {
|
||||||
|
return (
|
||||||
|
<html lang="en">
|
||||||
|
<body>
|
||||||
|
<Navbar />
|
||||||
|
{children}
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
);
|
||||||
|
}
|
||||||
9
editor/src/app/page.tsx
Normal file
9
editor/src/app/page.tsx
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import Link from "next/link";
|
||||||
|
|
||||||
|
export default function Home() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Link href="/texture-creator">Go to Texture Creator</Link>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
17
editor/src/app/texture-creator/page.tsx
Normal file
17
editor/src/app/texture-creator/page.tsx
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
'use client';
|
||||||
|
import React, { createContext, useContext, useState } from "react";
|
||||||
|
|
||||||
|
type TexturePageContextType = {
|
||||||
|
};
|
||||||
|
|
||||||
|
const TexturePageContext = createContext<TexturePageContextType | undefined>(undefined);
|
||||||
|
|
||||||
|
const TextureCreatorPage: React.FC<{ children: React.ReactNode }> = (props) => {
|
||||||
|
return (
|
||||||
|
<TexturePageContext.Provider value={{ }}>
|
||||||
|
<Typography</Typography>
|
||||||
|
</TexturePageContext.Provider>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default TextureCreatorPage;
|
||||||
12
editor/src/components/Navbar/Navbar.tsx
Normal file
12
editor/src/components/Navbar/Navbar.tsx
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import * as styles from './Navbar.module.scss';
|
||||||
|
|
||||||
|
const Navbar:React.FC<{}> = (props) => {
|
||||||
|
return (
|
||||||
|
<nav className={styles.navbar}>
|
||||||
|
navbar
|
||||||
|
</nav>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Navbar;
|
||||||
14
editor/src/objects/Typography/Typography.tsx
Normal file
14
editor/src/objects/Typography/Typography.tsx
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
|
||||||
|
const Typography:React.FC<{
|
||||||
|
element?:string|React.JSXElementConstructor<any>;
|
||||||
|
}> = (props) => {
|
||||||
|
const Element = props.element || 'p';
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Element>
|
||||||
|
{props.children}
|
||||||
|
</Element>
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Typography;
|
||||||
17
editor/src/pages/TextureCreator/TextureCreator.tsx
Normal file
17
editor/src/pages/TextureCreator/TextureCreator.tsx
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
|
||||||
|
import React, { createContext, useContext, useState } from "react";
|
||||||
|
|
||||||
|
type TextureContextType = {
|
||||||
|
};
|
||||||
|
|
||||||
|
const TextureContext = createContext<TextureContextType | undefined>(undefined);
|
||||||
|
|
||||||
|
const TextureCreator: React.FC<{ children: React.ReactNode }> = (props) => {
|
||||||
|
return (
|
||||||
|
<TextureContext.Provider value={{ }}>
|
||||||
|
{props.children}
|
||||||
|
</TextureContext.Provider>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default TextureCreator;
|
||||||
4
editor/src/styles/elements/a.scss
Normal file
4
editor/src/styles/elements/a.scss
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
a {
|
||||||
|
color: inherit;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
3
editor/src/styles/elements/all.scss
Normal file
3
editor/src/styles/elements/all.scss
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
* {
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
8
editor/src/styles/elements/body.scss
Normal file
8
editor/src/styles/elements/body.scss
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
max-width: 100vw;
|
||||||
|
overflow-x: hidden;
|
||||||
|
font-size: 16px;
|
||||||
|
font-family: Arial, Helvetica, sans-serif;
|
||||||
|
}
|
||||||
6
editor/src/styles/elements/html.scss
Normal file
6
editor/src/styles/elements/html.scss
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
html {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
max-width: 100vw;
|
||||||
|
overflow-x: hidden;
|
||||||
|
}
|
||||||
3
editor/src/styles/elements/root.scss
Normal file
3
editor/src/styles/elements/root.scss
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
:root {
|
||||||
|
|
||||||
|
}
|
||||||
12
editor/src/styles/styles.scss
Normal file
12
editor/src/styles/styles.scss
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
// Elements
|
||||||
|
@use './elements/root.scss';
|
||||||
|
@use './elements/all.scss';
|
||||||
|
@use './elements/a.scss';
|
||||||
|
@use './elements/html.scss';
|
||||||
|
@use './elements/body.scss';
|
||||||
|
|
||||||
|
// Objects
|
||||||
|
|
||||||
|
// Components
|
||||||
|
|
||||||
|
// Utilities
|
||||||
34
editor/tsconfig.json
Normal file
34
editor/tsconfig.json
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "ES2017",
|
||||||
|
"lib": ["dom", "dom.iterable", "esnext"],
|
||||||
|
"allowJs": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"strict": true,
|
||||||
|
"noEmit": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"module": "esnext",
|
||||||
|
"moduleResolution": "bundler",
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"isolatedModules": true,
|
||||||
|
"jsx": "react-jsx",
|
||||||
|
"incremental": true,
|
||||||
|
"plugins": [
|
||||||
|
{
|
||||||
|
"name": "next"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"paths": {
|
||||||
|
"@/*": ["./src/*"]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
"next-env.d.ts",
|
||||||
|
"**/*.ts",
|
||||||
|
"**/*.tsx",
|
||||||
|
".next/types/**/*.ts",
|
||||||
|
".next/dev/types/**/*.ts",
|
||||||
|
"**/*.mts"
|
||||||
|
],
|
||||||
|
"exclude": ["node_modules"]
|
||||||
|
}
|
||||||
@@ -40,9 +40,6 @@ target_sources(${DUSK_BINARY_TARGET_NAME}
|
|||||||
main.c
|
main.c
|
||||||
)
|
)
|
||||||
|
|
||||||
# Defs
|
|
||||||
dusk_env_to_h(duskdefs.env duskdefs.h)
|
|
||||||
|
|
||||||
# Subdirs
|
# Subdirs
|
||||||
add_subdirectory(assert)
|
add_subdirectory(assert)
|
||||||
add_subdirectory(asset)
|
add_subdirectory(asset)
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ void cameraInitOrthographic(camera_t *camera) {
|
|||||||
camera->orthographic.right = SCREEN.width;
|
camera->orthographic.right = SCREEN.width;
|
||||||
camera->orthographic.top = 0.0f;
|
camera->orthographic.top = 0.0f;
|
||||||
camera->orthographic.bottom = SCREEN.height;
|
camera->orthographic.bottom = SCREEN.height;
|
||||||
camera->nearClip = -1.0f;
|
camera->nearClip = 0.1f;
|
||||||
camera->farClip = 1.0f;
|
camera->farClip = 1.0f;
|
||||||
|
|
||||||
camera->viewType = CAMERA_VIEW_TYPE_2D;
|
camera->viewType = CAMERA_VIEW_TYPE_2D;
|
||||||
@@ -84,7 +84,7 @@ void cameraGetViewMatrix(camera_t *camera, mat4 dest) {
|
|||||||
assertNotNull(dest, "Destination matrix must not be null");
|
assertNotNull(dest, "Destination matrix must not be null");
|
||||||
|
|
||||||
if(camera->viewType == CAMERA_VIEW_TYPE_MATRIX) {
|
if(camera->viewType == CAMERA_VIEW_TYPE_MATRIX) {
|
||||||
glm_mat4_copy(camera->view, dest);
|
glm_mat4_ucopy(camera->view, dest);
|
||||||
} else if(camera->viewType == CAMERA_VIEW_TYPE_LOOKAT) {
|
} else if(camera->viewType == CAMERA_VIEW_TYPE_LOOKAT) {
|
||||||
glm_mat4_identity(dest);
|
glm_mat4_identity(dest);
|
||||||
glm_lookat(
|
glm_lookat(
|
||||||
|
|||||||
@@ -23,6 +23,24 @@
|
|||||||
#include "script/module/display/moduleshader.h"
|
#include "script/module/display/moduleshader.h"
|
||||||
|
|
||||||
display_t DISPLAY = { 0 };
|
display_t DISPLAY = { 0 };
|
||||||
|
mesh_t mesh;
|
||||||
|
meshvertex_t vertices[3] = {
|
||||||
|
{
|
||||||
|
.color = { 255, 0, 0, 255 },
|
||||||
|
.uv = { 0.0f, 0.0f },
|
||||||
|
.pos = { 0.0f, 0.5f, 0.0f }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.color = { 0, 255, 0, 255 },
|
||||||
|
.uv = { 0.5f, 1.0f },
|
||||||
|
.pos = { -0.5f, -0.5f, 0.0f }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.color = { 0, 0, 255, 255 },
|
||||||
|
.uv = { 1.0f, 0.0f },
|
||||||
|
.pos = { 0.5f, -0.5f, 0.0f }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
errorret_t displayInit(void) {
|
errorret_t displayInit(void) {
|
||||||
memoryZero(&DISPLAY, sizeof(DISPLAY));
|
memoryZero(&DISPLAY, sizeof(DISPLAY));
|
||||||
@@ -50,6 +68,7 @@ errorret_t displayInit(void) {
|
|||||||
errorChain(shaderSetMatrix(&SHADER_UNLIT, SHADER_UNLIT_MODEL, mat));
|
errorChain(shaderSetMatrix(&SHADER_UNLIT, SHADER_UNLIT_MODEL, mat));
|
||||||
errorChain(shaderSetTexture(&SHADER_UNLIT, SHADER_UNLIT_TEXTURE, NULL));
|
errorChain(shaderSetTexture(&SHADER_UNLIT, SHADER_UNLIT_TEXTURE, NULL));
|
||||||
|
|
||||||
|
errorChain(meshInit(&mesh, MESH_PRIMITIVE_TYPE_TRIANGLES, 3, vertices));
|
||||||
|
|
||||||
errorOk();
|
errorOk();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,14 +35,13 @@ errorret_t spriteBatchPush(
|
|||||||
const float_t u1,
|
const float_t u1,
|
||||||
const float_t v1
|
const float_t v1
|
||||||
) {
|
) {
|
||||||
errorChain(spriteBatchPush3D(
|
return spriteBatchPush3D(
|
||||||
(vec3){ minX, minY, 0 },
|
(vec3){ minX, minY, 0 },
|
||||||
(vec3){ maxX, maxY, 0 },
|
(vec3){ maxX, maxY, 0 },
|
||||||
color,
|
color,
|
||||||
(vec2){ u0, v0 },
|
(vec2){ u0, v0 },
|
||||||
(vec2){ u1, v1 }
|
(vec2){ u1, v1 }
|
||||||
));
|
);
|
||||||
errorOk();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
errorret_t spriteBatchPush3D(
|
errorret_t spriteBatchPush3D(
|
||||||
@@ -53,11 +52,14 @@ errorret_t spriteBatchPush3D(
|
|||||||
const vec2 uv1
|
const vec2 uv1
|
||||||
) {
|
) {
|
||||||
// Need to flush?
|
// Need to flush?
|
||||||
if(SPRITEBATCH.spriteCount >= SPRITEBATCH_SPRITES_MAX) {
|
if(SPRITEBATCH.spriteCount >= SPRITEBATCH_SPRITES_MAX_PER_FLUSH) {
|
||||||
errorChain(spriteBatchFlush());
|
errorChain(spriteBatchFlush());
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t vertexOffset = SPRITEBATCH.spriteCount * QUAD_VERTEX_COUNT;
|
size_t vertexOffset = (
|
||||||
|
SPRITEBATCH.spriteCount +
|
||||||
|
(SPRITEBATCH.spriteFlush * SPRITEBATCH_SPRITES_MAX_PER_FLUSH)
|
||||||
|
) * QUAD_VERTEX_COUNT;
|
||||||
quadBuffer3D(
|
quadBuffer3D(
|
||||||
&SPRITEBATCH_VERTICES[vertexOffset],
|
&SPRITEBATCH_VERTICES[vertexOffset],
|
||||||
min, max, color, uv0, uv1
|
min, max, color, uv0, uv1
|
||||||
@@ -68,6 +70,7 @@ errorret_t spriteBatchPush3D(
|
|||||||
|
|
||||||
void spriteBatchClear() {
|
void spriteBatchClear() {
|
||||||
SPRITEBATCH.spriteCount = 0;
|
SPRITEBATCH.spriteCount = 0;
|
||||||
|
SPRITEBATCH.spriteFlush = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
errorret_t spriteBatchFlush() {
|
errorret_t spriteBatchFlush() {
|
||||||
@@ -76,9 +79,19 @@ errorret_t spriteBatchFlush() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
size_t vertexCount = QUAD_VERTEX_COUNT * SPRITEBATCH.spriteCount;
|
size_t vertexCount = QUAD_VERTEX_COUNT * SPRITEBATCH.spriteCount;
|
||||||
errorChain(meshFlush(&SPRITEBATCH.mesh, 0, vertexCount));
|
size_t vertexOffset = (
|
||||||
errorChain(meshDraw(&SPRITEBATCH.mesh, 0, vertexCount));
|
SPRITEBATCH.spriteFlush * SPRITEBATCH_SPRITES_MAX_PER_FLUSH *
|
||||||
spriteBatchClear();
|
QUAD_VERTEX_COUNT
|
||||||
|
);
|
||||||
|
errorChain(meshFlush(&SPRITEBATCH.mesh, vertexOffset, vertexCount));
|
||||||
|
errorChain(meshDraw(&SPRITEBATCH.mesh, vertexOffset, vertexCount));
|
||||||
|
|
||||||
|
SPRITEBATCH.spriteFlush++;
|
||||||
|
if(SPRITEBATCH.spriteFlush >= SPRITEBATCH_FLUSH_COUNT) {
|
||||||
|
SPRITEBATCH.spriteFlush = 0;
|
||||||
|
}
|
||||||
|
SPRITEBATCH.spriteCount = 0;
|
||||||
|
|
||||||
errorOk();
|
errorOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,12 +8,17 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "display/mesh/quad.h"
|
#include "display/mesh/quad.h"
|
||||||
|
|
||||||
#define SPRITEBATCH_SPRITES_MAX 16
|
#define SPRITEBATCH_SPRITES_MAX 32
|
||||||
#define SPRITEBATCH_VERTEX_COUNT (SPRITEBATCH_SPRITES_MAX * QUAD_VERTEX_COUNT)
|
#define SPRITEBATCH_VERTEX_COUNT (SPRITEBATCH_SPRITES_MAX * QUAD_VERTEX_COUNT)
|
||||||
|
#define SPRITEBATCH_FLUSH_COUNT 4
|
||||||
|
#define SPRITEBATCH_SPRITES_MAX_PER_FLUSH (\
|
||||||
|
SPRITEBATCH_SPRITES_MAX / SPRITEBATCH_FLUSH_COUNT \
|
||||||
|
)
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
mesh_t mesh;
|
mesh_t mesh;
|
||||||
int32_t spriteCount;
|
int32_t spriteCount;
|
||||||
|
int32_t spriteFlush;
|
||||||
} spritebatch_t;
|
} spritebatch_t;
|
||||||
|
|
||||||
// Have to define these seperately because of alignment in certain platforms.
|
// Have to define these seperately because of alignment in certain platforms.
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ errorret_t textDraw(
|
|||||||
float_t posX = x;
|
float_t posX = x;
|
||||||
float_t posY = y;
|
float_t posY = y;
|
||||||
|
|
||||||
// errorChain(shaderSetTexture(&SHADER_UNLIT, SHADER_UNLIT_TEXTURE, texture));
|
errorChain(shaderSetTexture(&SHADER_UNLIT, SHADER_UNLIT_TEXTURE, texture));
|
||||||
|
|
||||||
char_t c;
|
char_t c;
|
||||||
int32_t i = 0;
|
int32_t i = 0;
|
||||||
|
|||||||
@@ -1,45 +0,0 @@
|
|||||||
# Copyright (c) 2025 Dominic Masters
|
|
||||||
#
|
|
||||||
# This software is released under the MIT License.
|
|
||||||
# https://opensource.org/licenses/MIT
|
|
||||||
|
|
||||||
ENTITY_DIR_SOUTH = 0
|
|
||||||
ENTITY_DIR_WEST = 1
|
|
||||||
ENTITY_DIR_EAST = 2
|
|
||||||
ENTITY_DIR_NORTH = 3
|
|
||||||
|
|
||||||
ENTITY_COUNT = 128
|
|
||||||
|
|
||||||
ENTITY_TYPE_NULL = 0
|
|
||||||
ENTITY_TYPE_PLAYER = 1
|
|
||||||
ENTITY_TYPE_NPC = 2
|
|
||||||
ENTITY_TYPE_COUNT = 3
|
|
||||||
|
|
||||||
CHUNK_WIDTH = 16
|
|
||||||
CHUNK_HEIGHT = 16
|
|
||||||
CHUNK_DEPTH = 4
|
|
||||||
# CHUNK_VERTEX_COUNT_MAX = QUAD_VERTEXES * CHUNK_WIDTH * CHUNK_HEIGHT * 4
|
|
||||||
CHUNK_VERTEX_COUNT_MAX=6144
|
|
||||||
CHUNK_MESH_COUNT_MAX = 14
|
|
||||||
CHUNK_ENTITY_COUNT_MAX = 8
|
|
||||||
|
|
||||||
TILE_WIDTH = 16.0
|
|
||||||
TILE_HEIGHT = 16.0
|
|
||||||
TILE_DEPTH = 16.0
|
|
||||||
|
|
||||||
TILE_SHAPE_NULL = 0
|
|
||||||
TILE_SHAPE_FLOOR = 1
|
|
||||||
TILE_SHAPE_RAMP_SOUTH = 2
|
|
||||||
TILE_SHAPE_RAMP_WEST = 3
|
|
||||||
TILE_SHAPE_RAMP_EAST = 4
|
|
||||||
TILE_SHAPE_RAMP_NORTH = 5
|
|
||||||
TILE_SHAPE_RAMP_SOUTHWEST = 6
|
|
||||||
TILE_SHAPE_RAMP_SOUTHEAST = 7
|
|
||||||
TILE_SHAPE_RAMP_NORTHWEST = 8
|
|
||||||
TILE_SHAPE_RAMP_NORTHEAST = 9
|
|
||||||
|
|
||||||
RPG_CAMERA_FOV = 70
|
|
||||||
RPG_CAMERA_PIXELS_PER_UNIT = 1.0
|
|
||||||
RPG_CAMERA_Z_OFFSET = 24.0
|
|
||||||
|
|
||||||
ASSET_LANG_CHUNK_CHAR_COUNT = 6144
|
|
||||||
@@ -22,7 +22,7 @@ errorret_t sceneInit(void) {
|
|||||||
|
|
||||||
errorret_t sceneUpdate(void) {
|
errorret_t sceneUpdate(void) {
|
||||||
#ifdef DUSK_TIME_DYNAMIC
|
#ifdef DUSK_TIME_DYNAMIC
|
||||||
if(!TIME.dynamicUpdate) {
|
if(TIME.dynamicUpdate) {
|
||||||
errorOk();
|
errorOk();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -90,5 +90,31 @@ int moduleShaderSetMatrix(lua_State *l) {
|
|||||||
|
|
||||||
int moduleShaderSetTexture(lua_State *l) {
|
int moduleShaderSetTexture(lua_State *l) {
|
||||||
assertNotNull(l, "Lua state cannot be NULL.");
|
assertNotNull(l, "Lua state cannot be NULL.");
|
||||||
|
|
||||||
|
shader_t *shader = (shader_t *)lua_touserdata(l, 1);
|
||||||
|
assertNotNull(shader, "Shader pointer cannot be NULL.");
|
||||||
|
|
||||||
|
const char_t *uniformName = luaL_checkstring(l, 2);
|
||||||
|
assertStrLenMin(uniformName, 1, "Uniform name cannot be empty.");
|
||||||
|
|
||||||
|
texture_t *texture;
|
||||||
|
// Texture can be Nil or a pointer, if not nil it must be a texture pointer.
|
||||||
|
if(lua_isnil(l, 3)) {
|
||||||
|
texture = NULL;
|
||||||
|
} else if(lua_isuserdata(l, 3)) {
|
||||||
|
texture = (texture_t *)lua_touserdata(l, 3);
|
||||||
|
assertNotNull(texture, "Texture pointer cannot be NULL.");
|
||||||
|
} else {
|
||||||
|
luaL_error(l, "Third argument must be a texture_mt userdata or nil.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
errorret_t ret = shaderSetTexture(shader, uniformName, texture);
|
||||||
|
if(ret.code != ERROR_OK) {
|
||||||
|
luaL_error(l, "Failed to set shader texture: %s", ret.state->message);
|
||||||
|
errorCatch(errorPrint(ret));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -11,6 +11,10 @@
|
|||||||
|
|
||||||
void cameraPushMatrixDolphin(camera_t *camera) {
|
void cameraPushMatrixDolphin(camera_t *camera) {
|
||||||
assertNotNull(camera, "Camera cannot be null");
|
assertNotNull(camera, "Camera cannot be null");
|
||||||
|
assertTrue(
|
||||||
|
camera->nearClip > 0.0f,
|
||||||
|
"Camera near clip must be greater than 0 for Dolphin"
|
||||||
|
);
|
||||||
|
|
||||||
Mtx44 guProjection;
|
Mtx44 guProjection;
|
||||||
Mtx guView;
|
Mtx guView;
|
||||||
|
|||||||
@@ -77,7 +77,8 @@ errorret_t displayInitDolphin(void) {
|
|||||||
|
|
||||||
// Setup cull modes
|
// Setup cull modes
|
||||||
GX_SetCullMode(GX_CULL_NONE);
|
GX_SetCullMode(GX_CULL_NONE);
|
||||||
GX_SetZMode(GX_FALSE, GX_ALWAYS, GX_FALSE);
|
GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR);
|
||||||
|
GX_SetZMode(GX_TRUE, GX_ALWAYS, GX_FALSE);
|
||||||
GX_SetDispCopyGamma(GX_GM_1_0);
|
GX_SetDispCopyGamma(GX_GM_1_0);
|
||||||
GX_SetColorUpdate(GX_TRUE);
|
GX_SetColorUpdate(GX_TRUE);
|
||||||
|
|
||||||
|
|||||||
@@ -60,6 +60,8 @@ errorret_t meshDrawDolphin(
|
|||||||
GX_SetArray(GX_VA_CLR0, (void*)&mesh->vertices[vertexOffset].color.r, stride);
|
GX_SetArray(GX_VA_CLR0, (void*)&mesh->vertices[vertexOffset].color.r, stride);
|
||||||
GX_SetArray(GX_VA_TEX0, (void*)&mesh->vertices[vertexOffset].uv[0], stride);
|
GX_SetArray(GX_VA_TEX0, (void*)&mesh->vertices[vertexOffset].uv[0], stride);
|
||||||
|
|
||||||
|
GX_InvVtxCache();
|
||||||
|
|
||||||
GX_Begin(mesh->primitiveType, GX_VTXFMT0, (uint16_t)vertexCount);
|
GX_Begin(mesh->primitiveType, GX_VTXFMT0, (uint16_t)vertexCount);
|
||||||
for(uint16_t i = 0; i < (uint16_t)vertexCount; ++i) {
|
for(uint16_t i = 0; i < (uint16_t)vertexCount; ++i) {
|
||||||
GX_Position1x16(i);
|
GX_Position1x16(i);
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ void cameraPushMatrixGL(camera_t *camera) {
|
|||||||
|
|
||||||
switch(camera->viewType) {
|
switch(camera->viewType) {
|
||||||
case CAMERA_VIEW_TYPE_MATRIX:
|
case CAMERA_VIEW_TYPE_MATRIX:
|
||||||
glm_mat4_copy(camera->view, view);
|
glm_mat4_ucopy(camera->view, view);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CAMERA_VIEW_TYPE_LOOKAT:
|
case CAMERA_VIEW_TYPE_LOOKAT:
|
||||||
|
|||||||
@@ -11,13 +11,6 @@ errorret_t displayOpenGLInit(void) {
|
|||||||
glDisable(GL_CULL_FACE);
|
glDisable(GL_CULL_FACE);
|
||||||
errorChain(errorGLCheck());
|
errorChain(errorGLCheck());
|
||||||
|
|
||||||
#if DUSK_OPENGL_LEGACY
|
|
||||||
glDisable(GL_LIGHTING);// PSP defaults this on?
|
|
||||||
errorChain(errorGLCheck());
|
|
||||||
glShadeModel(GL_SMOOTH); // Fixes color on PSP?
|
|
||||||
errorChain(errorGLCheck());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
errorChain(errorGLCheck());
|
errorChain(errorGLCheck());
|
||||||
glDepthFunc(GL_LEQUAL);
|
glDepthFunc(GL_LEQUAL);
|
||||||
@@ -32,5 +25,12 @@ errorret_t displayOpenGLInit(void) {
|
|||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||||
errorChain(errorGLCheck());
|
errorChain(errorGLCheck());
|
||||||
|
|
||||||
|
#if DUSK_OPENGL_LEGACY
|
||||||
|
glDisable(GL_LIGHTING);// PSP defaults this on?
|
||||||
|
errorChain(errorGLCheck());
|
||||||
|
glShadeModel(GL_SMOOTH); // Fixes color on PSP?
|
||||||
|
errorChain(errorGLCheck());
|
||||||
|
#endif
|
||||||
|
|
||||||
errorOk();
|
errorOk();
|
||||||
}
|
}
|
||||||
@@ -113,8 +113,10 @@ errorret_t meshFlushGL(
|
|||||||
errorChain(errorGLCheck());
|
errorChain(errorGLCheck());
|
||||||
glBufferData(
|
glBufferData(
|
||||||
GL_ARRAY_BUFFER,
|
GL_ARRAY_BUFFER,
|
||||||
vertCount * sizeof(meshvertex_t),
|
mesh->vertexCount * sizeof(meshvertex_t),
|
||||||
&mesh->vertices[vertOffset],
|
mesh->vertices,
|
||||||
|
// vertCount * sizeof(meshvertex_t),
|
||||||
|
// &mesh->vertices[vertOffset],
|
||||||
GL_DYNAMIC_DRAW
|
GL_DYNAMIC_DRAW
|
||||||
);
|
);
|
||||||
errorChain(errorGLCheck());
|
errorChain(errorGLCheck());
|
||||||
|
|||||||
@@ -181,17 +181,18 @@ errorret_t shaderSetMatrixGL(
|
|||||||
SHADER_LEGACY.boundShader == shader,
|
SHADER_LEGACY.boundShader == shader,
|
||||||
"Shader must be bound to set legacy matrices."
|
"Shader must be bound to set legacy matrices."
|
||||||
);
|
);
|
||||||
|
// Use unaligned copy to safely handle possibly unaligned input matrices
|
||||||
if(stringCompare(name, SHADER_UNLIT_PROJECTION) == 0) {
|
if(stringCompare(name, SHADER_UNLIT_PROJECTION) == 0) {
|
||||||
SHADER_LEGACY.dirty |= SHADER_LEGACY_DIRTY_PROJ;
|
SHADER_LEGACY.dirty |= SHADER_LEGACY_DIRTY_PROJ;
|
||||||
glm_mat4_copy(mat, shader->proj);
|
glm_mat4_ucopy(mat, shader->proj);
|
||||||
|
|
||||||
} else if(stringCompare(name, SHADER_UNLIT_VIEW) == 0) {
|
} else if(stringCompare(name, SHADER_UNLIT_VIEW) == 0) {
|
||||||
SHADER_LEGACY.dirty |= SHADER_LEGACY_DIRTY_VIEW;
|
SHADER_LEGACY.dirty |= SHADER_LEGACY_DIRTY_VIEW;
|
||||||
glm_mat4_copy(mat, shader->view);
|
glm_mat4_ucopy(mat, shader->view);
|
||||||
|
|
||||||
} else if(stringCompare(name, SHADER_UNLIT_MODEL) == 0) {
|
} else if(stringCompare(name, SHADER_UNLIT_MODEL) == 0) {
|
||||||
SHADER_LEGACY.dirty |= SHADER_LEGACY_DIRTY_MODEL;
|
SHADER_LEGACY.dirty |= SHADER_LEGACY_DIRTY_MODEL;
|
||||||
glm_mat4_copy(mat, shader->model);
|
glm_mat4_ucopy(mat, shader->model);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
assertUnreachable("Cannot use a custom matrix on legacy opengl.");
|
assertUnreachable("Cannot use a custom matrix on legacy opengl.");
|
||||||
|
|||||||
@@ -122,7 +122,7 @@
|
|||||||
// Uniforms
|
// Uniforms
|
||||||
"uniform sampler2D u_Texture;\n"
|
"uniform sampler2D u_Texture;\n"
|
||||||
"uniform int u_TextureType;\n"
|
"uniform int u_TextureType;\n"
|
||||||
"uniform vec4 u_Colors[256];\n"// For paletted textures.
|
"uniform uint u_Colors[256];\n"// For paletted textures.
|
||||||
"uniform int u_ColorCount;\n"
|
"uniform int u_ColorCount;\n"
|
||||||
// Fragment shader inputs
|
// Fragment shader inputs
|
||||||
"in vec4 v_Color;\n"
|
"in vec4 v_Color;\n"
|
||||||
@@ -140,8 +140,13 @@
|
|||||||
" }\n"
|
" }\n"
|
||||||
" if(u_TextureType == 2) {\n"// Paletted texture
|
" if(u_TextureType == 2) {\n"// Paletted texture
|
||||||
" vec4 texColor = texture(u_Texture, v_TexCoord);\n"
|
" vec4 texColor = texture(u_Texture, v_TexCoord);\n"
|
||||||
" int index = int(floor(texColor.r * 255.0));\n"
|
" uint index = uint(floor(texColor.r * 255.0));\n"
|
||||||
" vec4 paletteColor = u_Colors[index];\n"
|
" uint palColor = u_Colors[index];\n"
|
||||||
|
" float r = float((palColor >> 24) & 0xFFu) / 255.0;\n"
|
||||||
|
" float g = float((palColor >> 16) & 0xFFu) / 255.0;\n"
|
||||||
|
" float b = float((palColor >> 8) & 0xFFu) / 255.0;\n"
|
||||||
|
" float a = float((palColor >> 0) & 0xFFu) / 255.0;\n"
|
||||||
|
" vec4 paletteColor = vec4(r, g, b, a);\n"
|
||||||
" FragColor = paletteColor;\n"
|
" FragColor = paletteColor;\n"
|
||||||
" return;\n"
|
" return;\n"
|
||||||
" }\n"
|
" }\n"
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ errorret_t textureInitGL(
|
|||||||
switch(format) {
|
switch(format) {
|
||||||
case TEXTURE_FORMAT_RGBA:
|
case TEXTURE_FORMAT_RGBA:
|
||||||
glTexImage2D(
|
glTexImage2D(
|
||||||
GL_TEXTURE_2D, 0, format, width, height, 0,
|
GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0,
|
||||||
format, GL_UNSIGNED_BYTE, (void*)data.rgbaColors
|
GL_RGBA, GL_UNSIGNED_BYTE, (void*)data.rgbaColors
|
||||||
);
|
);
|
||||||
errorChain(errorGLCheck());
|
errorChain(errorGLCheck());
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -3,5 +3,4 @@
|
|||||||
# This software is released under the MIT License.
|
# This software is released under the MIT License.
|
||||||
# https://opensource.org/licenses/MIT
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
add_subdirectory(run_python)
|
add_subdirectory(run_python)
|
||||||
add_subdirectory(env_to_h)
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
# Copyright (c) 2026 Dominic Masters
|
|
||||||
#
|
|
||||||
# This software is released under the MIT License.
|
|
||||||
# https://opensource.org/licenses/MIT
|
|
||||||
|
|
||||||
function(dusk_env_to_h INPUT_PATH OUTPUT_NAME_RELATIVE)
|
|
||||||
set(DUSK_DEFS_TARGET_NAME "DUSK_DEFS_${OUTPUT_NAME_RELATIVE}")
|
|
||||||
dusk_run_python(
|
|
||||||
${DUSK_DEFS_TARGET_NAME}
|
|
||||||
tools.env_to_h
|
|
||||||
--env "${CMAKE_CURRENT_LIST_DIR}/${INPUT_PATH}"
|
|
||||||
--output ${DUSK_GENERATED_HEADERS_DIR}/${OUTPUT_NAME_RELATIVE}
|
|
||||||
)
|
|
||||||
add_dependencies(${DUSK_LIBRARY_TARGET_NAME} ${DUSK_DEFS_TARGET_NAME})
|
|
||||||
endfunction()
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
import argparse
|
|
||||||
import os
|
|
||||||
from dotenv import load_dotenv, dotenv_values
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description="Convert .env to .h defines")
|
|
||||||
parser.add_argument("--env", required=True, help="Path to .env file")
|
|
||||||
parser.add_argument("--output", required=True, help="Path to output .h file")
|
|
||||||
args = parser.parse_args()
|
|
||||||
|
|
||||||
# Load .env file
|
|
||||||
load_dotenv(dotenv_path=args.env)
|
|
||||||
fileDefs = dotenv_values(dotenv_path=args.env)
|
|
||||||
|
|
||||||
outHeader = ""
|
|
||||||
outHeader += "#include \"dusk.h\"\n\n"
|
|
||||||
for key, value in fileDefs.items():
|
|
||||||
# Determine type and print out appropriate C type define.
|
|
||||||
|
|
||||||
# Integer
|
|
||||||
try:
|
|
||||||
asInt = int(value)
|
|
||||||
outHeader += f"#define {key} {asInt}\n"
|
|
||||||
continue
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# Float
|
|
||||||
try:
|
|
||||||
asFloat = float(value)
|
|
||||||
outHeader += f"#define {key} {asFloat}f\n"
|
|
||||||
continue
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# Boolean
|
|
||||||
if value.lower() in ['true', 'false']:
|
|
||||||
asBool = '1' if value.lower() == 'true' else '0'
|
|
||||||
outHeader += f"#define {key} {asBool}\n"
|
|
||||||
continue
|
|
||||||
|
|
||||||
# String
|
|
||||||
outHeader += f'#define {key} "{value}"\n'
|
|
||||||
|
|
||||||
# Write to output file
|
|
||||||
with open(args.output, 'w') as outFile:
|
|
||||||
outFile.write(outHeader)
|
|
||||||
Reference in New Issue
Block a user