Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
1f4913ae7d | ||
|
1adaff6362 | ||
f1017eb1da | |||
|
b334095aaa | ||
|
8ec95df86c | ||
f746d395b3 | |||
6dbe1c4616 | |||
30ff52a3f8 |
22
.gitea/workflows/buildtest.yml
Normal file
22
.gitea/workflows/buildtest.yml
Normal file
@@ -0,0 +1,22 @@
|
||||
name: Run ReCI Build Test
|
||||
run-name: Run ReCI Build Test For ${{ gitea.repository }}.
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
Explore-Gitea-Actions:
|
||||
runs-on: ubuntu-22.04
|
||||
env:
|
||||
RECI_GIT: https://git.redacted.cc/maxine/ReCI
|
||||
RECI: /RECI
|
||||
steps:
|
||||
- run: echo "The job was automatically triggered by a ${{ gitea.event_name }} event."
|
||||
- run: echo "This job is now running on a ${{ runner.os }} server hosted by Gitea!"
|
||||
- run: echo "The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
|
||||
- name: Check out repository code
|
||||
uses: actions/checkout@v3
|
||||
- run: echo "The ${{ gitea.repository }} repository has been cloned to the runner."
|
||||
- run: echo "The workflow is now ready to run your tests on the runner."
|
||||
- run: echo "Install toolchain and run ReCI build test"
|
||||
- run: apt-get update && apt-get install -y lua5.3 git libxrandr-dev && git clone $RECI_GIT $RECI
|
||||
- run: lua $RECI/reci.lua -f $RECI/scripts/buildtools.reci -f reci/scripts/builddeps.reci -f $RECI/scripts/buildtest.reci
|
||||
- run: echo "This job's status is ${{ job.status }}."
|
@@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.18)
|
||||
cmake_minimum_required(VERSION 3.18..3.27)
|
||||
project(Re3D
|
||||
VERSION 1.0
|
||||
LANGUAGES CXX C
|
||||
@@ -29,7 +29,7 @@ SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
|
||||
|
||||
CPMAddPackage(
|
||||
NAME ReWindow
|
||||
URL https://git.redacted.cc/Redacted/ReWindow/archive/Prerelease-12.zip
|
||||
URL https://git.redacted.cc/Redacted/ReWindow/archive/Prerelease-3.zip
|
||||
)
|
||||
|
||||
CPMAddPackage(
|
||||
@@ -44,17 +44,17 @@ CPMAddPackage(
|
||||
|
||||
CPMAddPackage(
|
||||
NAME J3ML
|
||||
URL https://git.redacted.cc/josh/j3ml/archive/Release-3.0.zip
|
||||
URL https://git.redacted.cc/josh/j3ml/archive/Release-2.2.zip
|
||||
)
|
||||
|
||||
CPMAddPackage(
|
||||
NAME JGL
|
||||
URL https://git.redacted.cc/josh/JGL/archive/Prerelease-31.zip
|
||||
URL https://git.redacted.cc/josh/JGL/archive/Prerelease-20.zip
|
||||
)
|
||||
|
||||
CPMAddPackage(
|
||||
NAME ReTexture
|
||||
URL https://git.redacted.cc/Redacted/ReTexture/archive/Release-1.2.zip
|
||||
URL https://git.redacted.cc/Redacted/ReTexture/archive/Prerelease-2.zip
|
||||
)
|
||||
|
||||
CPMAddPackage(
|
||||
@@ -74,7 +74,7 @@ CPMAddPackage(
|
||||
|
||||
CPMAddPackage(
|
||||
NAME Collage
|
||||
URL https://git.redacted.cc/Redacted/Collage/archive/v0.6.zip
|
||||
URL https://git.redacted.cc/Redacted/Collage/archive/v0.5.zip
|
||||
)
|
||||
|
||||
CPMAddPackage(
|
||||
@@ -97,6 +97,7 @@ target_include_directories(Re3D PUBLIC
|
||||
${ReWindow_SOURCE_DIR}/include
|
||||
#${ReHardwareID_SOURCE_DIR}/include
|
||||
${J3ML_SOURCE_DIR}/include
|
||||
${ReTexture_SOURCE_DIR}/include
|
||||
${glad_SOURCE_DIR}/include
|
||||
${UUID_SOURCE_DIR}/include
|
||||
#${archive_SOURCE_DIR}/include
|
||||
@@ -109,11 +110,11 @@ set_target_properties(Re3D PROPERTIES LINKER_LANGUAGE CXX)
|
||||
|
||||
if (UNIX AND NOT APPLE)
|
||||
find_package(OpenGL REQUIRED)
|
||||
target_link_libraries(Re3D PUBLIC Event ReWindowLibrary J3ML GL glad Collage JGL jlog)
|
||||
target_link_libraries(Re3D PUBLIC Event ReWindowLibrary ReTexture J3ML GL glad Collage JGL jlog)
|
||||
endif()
|
||||
|
||||
if (WIN32)
|
||||
target_link_libraries(Re3D PUBLIC Event ReWindowLibrary J3ML glad Collage JGL jlog)
|
||||
target_link_libraries(Re3D PUBLIC Event ReWindowLibrary ReTexture J3ML glad Collage JGL jlog)
|
||||
endif()
|
||||
|
||||
include(src/demo/RuntimeTest/CMakeLists.txt)
|
||||
|
18
README.md
18
README.md
@@ -7,7 +7,7 @@ A classic 3D game-engine for Linux & Windows.
|
||||
### Installing Dependencies
|
||||
- Fedora ```sudo dnf install git cmake make gcc-g++ mesa-libGL-devel systemd-devel```
|
||||
<br><br>
|
||||
- Ubuntu ```sudo apt install git cmake make gcc g++ pkg-config libgl-dev libudev-dev```
|
||||
- Ubuntu ```sudo apt install git cmake make gcc g++ pkg-config libgl-dev libudev-dev libfreetype6-dev```
|
||||
<br><br>
|
||||
- Archᵇᵗʷ ```sudo pacman -S git cmake make gcc libgl```
|
||||
|
||||
@@ -15,6 +15,22 @@ A classic 3D game-engine for Linux & Windows.
|
||||
```bash
|
||||
git clone https://git.redacted.cc/Redacted/Re3D.git && cd Re3D && mkdir build && cd build && cmake .. && make -j8
|
||||
```
|
||||
|
||||
### What's The Goal?
|
||||
The game development industry has lost sight of what made games fun. A massive amount of the development time will be focused on graphics instead, The result being a pretty game that's not fun to play. Or worse, A game that's released unfinished.
|
||||
|
||||
Open Source game engines or engine components are commonly under copyleft licenses. If you were to make use of it then the entire game would also have to be under the same license. In terms of making a game to sell they're useless.
|
||||
|
||||
So then, A simple game-engine with the goal of **all** of the code being public domain.
|
||||
|
||||
### Additional Notes
|
||||
It is possible to run Re3D on ARM. Re3D is known to run on the X13s using Ubuntu 24.04 at a reported 500 FPS (Software Renderer) as of writing. Thank you to Richard Neale for this discovery!
|
||||
|
||||
It is also possible to run Re3D on the VisionFive2 (RISC-V). We've tested this not long ago and have made appropriate fixes since. If I remember correctly we were running Debian on the board. (FPS not documented, but we remember it being quite low - Maxine)
|
||||
|
||||
Richard Neale has also discovered Re3D can run on a Banana Pi F3 (RISC-V) running Armbian 24.5 at a reported 5 FPS. For armbian the Ubuntu instructions should apply and the package name for libfreetype is libfreetype-dev.
|
||||
|
||||
Testing of Re3D on a variety of CPU architectures is encouraged and greatly appreciated. Although we may not support every architecture at this current time we definitely appreciate any work put toward testing and porting to various architectures.
|
||||
<div style="text-align: left; line-height: 0">
|
||||
<h5>Donation</h5>
|
||||
<h76><a href="monero:89P8iW1Ly6wbypAYegceveUKe36nGYSsAfQhwCu3JJDHGso3XdXwuYpEGRM14QhXo63idEyWu5xYRMRoiJYekGE34z8SDtu">Monero</a></h76>
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
#include <Redacted3D/types/vertex.h>
|
||||
#include <J3ML/Geometry.hpp>
|
||||
#include <J3ML/Geometry.h>
|
||||
|
||||
using J3ML::Geometry::AABB;
|
||||
using J3ML::Geometry::OBB;
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#include <Redacted3D/types/entity/3D/camera.h>
|
||||
#include <Redacted3D/types/entity/camera.h>
|
||||
|
||||
namespace Occlusion {
|
||||
//TODO
|
||||
|
@@ -3,8 +3,8 @@
|
||||
#include <Redacted3D/types/vertex.h>
|
||||
#include <Redacted3D/types/texture.h>
|
||||
#include <Redacted3D/types/shader.h>
|
||||
#include <Redacted3D/types/entity/baseEntity.h>
|
||||
#include <J3ML/LinearAlgebra/Vector3.hpp>
|
||||
#include <Redacted3D/types/entity/entity.h>
|
||||
#include <J3ML/LinearAlgebra/Vector3.h>
|
||||
|
||||
using J3ML::LinearAlgebra::Vector3;
|
||||
using J3ML::LinearAlgebra::Vector2;
|
||||
@@ -24,22 +24,21 @@ class Serializable {
|
||||
|
||||
|
||||
// A wrapper around a Tree Hierarchy Data Model.
|
||||
class DataModel : public BaseEntity {
|
||||
class DataModel : public Entity {
|
||||
public:
|
||||
[[nodiscard]] BaseEntity* GetParent() const override {return nullptr;}
|
||||
Entity * GetParent() const override {return nullptr;}
|
||||
std::vector<Entity> GetFlatEntityList();
|
||||
|
||||
template <class T>
|
||||
void Serialize(T& archive) {
|
||||
BaseEntity::SerializeMemberData(archive);
|
||||
Entity::SerializeMemberData(archive);
|
||||
archive & GetFlatEntityList();
|
||||
}
|
||||
|
||||
void SetParent(BaseEntity *parent) override {
|
||||
void SetParent(Entity *parent) override {
|
||||
throw std::runtime_error("Cannot set parent of Hierarchy Root!");
|
||||
}
|
||||
|
||||
DataModel() : BaseEntity() {}
|
||||
DataModel() : Entity() {}
|
||||
[[nodiscard]] int getEntityCount() const;
|
||||
[[nodiscard]] int getMobyCount() const;
|
||||
};
|
||||
|
@@ -1,8 +0,0 @@
|
||||
///A moby with skeletal animations.
|
||||
//TODO
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <Redacted3D/types/entity/3D/moby.h>
|
||||
|
||||
class Actor : public Moby {};
|
@@ -1,67 +0,0 @@
|
||||
#pragma once
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <J3ML/J3ML.hpp>
|
||||
|
||||
class BaseEntity {
|
||||
protected:
|
||||
///If the entity has a parent entity, It's here.
|
||||
BaseEntity* parent;
|
||||
///Entity list of child entities.
|
||||
std::vector<BaseEntity*> children;
|
||||
public:
|
||||
u32 ticksAlive;
|
||||
bool draw = true;
|
||||
std::string uuid;
|
||||
std::string name;
|
||||
bool alive;
|
||||
virtual std::vector<std::string> GetEntityUUIDList() const { return std::vector<std::string> { "" }; }
|
||||
|
||||
BaseEntity() = default;
|
||||
std::vector<BaseEntity*> GetChildren();
|
||||
///Sets a given entity as this entities parent.
|
||||
virtual void SetParent(BaseEntity* parent);
|
||||
bool IsDescendantOf(BaseEntity* ancestor);
|
||||
bool IsAncestorOf(BaseEntity* descendant);
|
||||
std::vector<BaseEntity*> GetDescendants();
|
||||
std::vector<BaseEntity*> GetAncestors();
|
||||
[[nodiscard]] virtual BaseEntity* GetParent() const { return parent;}
|
||||
BaseEntity* FindFirstChild(std::string search_name);
|
||||
[[nodiscard]] BaseEntity* GetFamilyTreeRoot() const;
|
||||
BaseEntity* Add(BaseEntity* newChild);
|
||||
|
||||
void DescendantAdded(BaseEntity* ent) {}
|
||||
void DescendantRemoved(BaseEntity* ent) {}
|
||||
void AncestorAdded(BaseEntity* ent) {}
|
||||
void AncestorRemoved(BaseEntity* ent) {}
|
||||
|
||||
template <class T>
|
||||
void SerializeMemberData(T& archive){ archive & uuid.c_str() & name.c_str() & alive; }
|
||||
|
||||
template <class T>
|
||||
void Serialize(T& archive) {
|
||||
SerializeMemberData(archive);
|
||||
archive & GetEntityUUIDList();
|
||||
}
|
||||
|
||||
// TODO: Constrain to DerivedEntityType
|
||||
template <typename T>
|
||||
T* FindFirstChildOfType() const
|
||||
{
|
||||
for (auto& child : children) {
|
||||
T* p = dynamic_cast<T>(child);
|
||||
|
||||
if (p != nullptr)
|
||||
return p;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
virtual void pre_render() {}
|
||||
virtual void post_render() {}
|
||||
virtual void jglRenderPass() {}
|
||||
///The default rendering routine. Works for 99% of cases.
|
||||
virtual void render() {}
|
||||
virtual void update(float elapsed) {}
|
||||
virtual void ticc(int tics) { ticksAlive++; }
|
||||
};
|
@@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
#include <Redacted3D/types/entity/3D/moby.h>
|
||||
#include <Redacted3D/types/entity/moby.h>
|
||||
#include <Redacted3D/engine/engine.h>
|
||||
#include <glad/glad.h>
|
||||
#include <J3ML/Geometry.hpp>
|
||||
#include <J3ML/Geometry.h>
|
||||
|
||||
using J3ML::LinearAlgebra::Matrix4x4;
|
||||
using J3ML::Geometry::Frustum;
|
@@ -1,10 +1,9 @@
|
||||
#pragma once
|
||||
#include <cstdint>
|
||||
#include <Redacted3D/types/entity/baseEntity.h>
|
||||
#include <Redacted3D/types/vertex.h>
|
||||
#include <Redacted3D/types/texture.h>
|
||||
#include <J3ML/LinearAlgebra/Matrix4x4.hpp>
|
||||
#include <J3ML/LinearAlgebra/Vector3.hpp>
|
||||
#include <J3ML/LinearAlgebra/Matrix4x4.h>
|
||||
#include <J3ML/LinearAlgebra/Vector3.h>
|
||||
#include <Redacted3D/engine/collision.h>
|
||||
//#include <archive.h>
|
||||
|
||||
@@ -14,7 +13,7 @@ using J3ML::LinearAlgebra::Vector3;
|
||||
typedef Vector3 Direction;
|
||||
|
||||
///Base entity type.
|
||||
class Entity : public BaseEntity {
|
||||
class Entity {
|
||||
private:
|
||||
///Pitch Yaw Roll, The orientation of the entity in the world,
|
||||
Vector3 angle = {0,0,0};
|
||||
@@ -23,6 +22,11 @@ private:
|
||||
///The scale it should be rendered at.
|
||||
Vector3 scale = {1.0f, 1.0f, 1.0f};
|
||||
protected:
|
||||
///If the entity has a parent entity, It's here.
|
||||
Entity* parent;
|
||||
///Entity list of child entities.
|
||||
std::vector<Entity*> children;
|
||||
|
||||
///Loads the geometry for it.
|
||||
void loadGeometry(const std::string& file);
|
||||
void loadTexture(const std::string& file);
|
||||
@@ -30,6 +34,23 @@ void loadMultiTexture(const std::vector<std::string>& files);
|
||||
void loadMotionTexture(const std::vector<std::string>& files, u16 frameDelta, bool doAnim = true);
|
||||
|
||||
public:
|
||||
std::string name; //Entity name. TODO remove this.
|
||||
bool alive;
|
||||
|
||||
virtual std::vector<std::string> GetEntityUUIDList() const { return std::vector<std::string> { "" }; }
|
||||
|
||||
template <class T>
|
||||
void SerializeMemberData(T& archive)
|
||||
{
|
||||
archive & uuid.c_str() & name.c_str() & alive;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void Serialize(T& archive)
|
||||
{
|
||||
SerializeMemberData(archive);
|
||||
archive & GetEntityUUIDList();
|
||||
}
|
||||
///Whether an entity is solid. Entities are solid by default.
|
||||
bool collidable = true;
|
||||
|
||||
@@ -43,13 +64,45 @@ public:
|
||||
Sphere getSphere();
|
||||
///Returns the OBB of the entity.
|
||||
OBB getOBB();
|
||||
///Returns the entity list of the entities children.
|
||||
std::vector<Entity*> GetChildren();
|
||||
///Sets a given entity as this entities parent.
|
||||
virtual void SetParent(Entity* parent);
|
||||
bool IsDescendantOf(Entity* ancestor);
|
||||
bool IsAncestorOf(Entity* descendant);
|
||||
std::vector<Entity*> GetDescendants();
|
||||
std::vector<Entity*> GetAncestors();
|
||||
virtual Entity* GetParent() const { return parent;}
|
||||
Entity* FindFirstChild(std::string search_name);
|
||||
[[nodiscard]] Entity* GetFamilyTreeRoot() const;
|
||||
Entity *Add(Entity *newChild);
|
||||
void setScale(const float& multiplier);
|
||||
[[nodiscard]] Vector3 getScale() const;
|
||||
|
||||
// TODO: Constrain to DerivedEntityType
|
||||
template <typename T>
|
||||
T* FindFirstChildOfType() const
|
||||
{
|
||||
for (auto& child : children) {
|
||||
T* p = dynamic_cast<T>(child);
|
||||
|
||||
if (p != nullptr)
|
||||
return p;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void DescendantAdded(Entity* ent) {}
|
||||
void DescendantRemoved(Entity* ent) {}
|
||||
void AncestorAdded(Entity* ent) {}
|
||||
void AncestorRemoved(Entity* ent) {}
|
||||
|
||||
|
||||
protected:
|
||||
Matrix4x4 coordinates;
|
||||
J3ML::LinearAlgebra::Position position; /// X Y Z
|
||||
public:
|
||||
std::string uuid;
|
||||
u32 ticksAlive; //At 64tps it'd take 776 days to overflow.
|
||||
[[nodiscard]] Position GetPos() const;
|
||||
void SetPos(const Position& rhs);
|
||||
@@ -61,11 +114,19 @@ public:
|
||||
void setAngle(float pitch, float yaw, float roll);
|
||||
///Removes an entity from the list, Checks if the assets are being used by any other entity. Removes them from their lists & deletes. Then deletes the entity.
|
||||
void erase();
|
||||
bool draw = true;
|
||||
bool occluded();
|
||||
bool isCollidingWith(Entity* entity);
|
||||
|
||||
///Default rendering routine. Works in 99% of cases.
|
||||
void render() override;
|
||||
virtual void pre_render() {}
|
||||
virtual void post_render() {}
|
||||
virtual void jglRenderPass() {}
|
||||
///The default rendering routine. Works for 99% of cases.
|
||||
virtual void render();
|
||||
virtual void update(float elapsed) {}
|
||||
virtual void ticc(int tics)
|
||||
{
|
||||
ticksAlive++;
|
||||
}
|
||||
|
||||
Entity();
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <Redacted3D/types/entity/3D/entity.h>
|
||||
#include <Redacted3D/types/entity/entity.h>
|
||||
|
||||
///A "Movable Object". Things that will move often are derived from this.
|
||||
class Moby : public Entity {
|
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <Redacted3D/types/vertex.h>
|
||||
#include <Redacted3D/types/entity/3D/moby.h>
|
||||
#include <Redacted3D/types/entity/moby.h>
|
||||
|
||||
///Simple skybox, A sphere with a texture on it where the center of the sphere is always the camera.
|
||||
class Skybox : public Moby {
|
@@ -3,18 +3,19 @@
|
||||
#include <glad/glad.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <J3ML/LinearAlgebra.hpp>
|
||||
#include <JGL/Texture.h>
|
||||
#include <J3ML/LinearAlgebra.h>
|
||||
#include <chrono>
|
||||
|
||||
//Forward declaration of entity.
|
||||
class Entity;
|
||||
|
||||
//Base texture. One texture.
|
||||
class Texture : public JGL::Texture {
|
||||
class Texture {
|
||||
public:
|
||||
///Reference counter.
|
||||
std::vector<Entity*> usedBy;
|
||||
///The id OpenGL uses to keep track of where the texture is in vram.
|
||||
GLuint id = 0;
|
||||
///Loads a texture for a given entity type from a file you specify.
|
||||
void load(Entity* entity, const std::string& file, bool storeOnTextureList);
|
||||
///removes texture from texture list and deletes it.
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <J3ML/LinearAlgebra.hpp>
|
||||
#include <J3ML/LinearAlgebra.h>
|
||||
|
||||
class Moby;
|
||||
|
||||
|
@@ -3,9 +3,9 @@
|
||||
#include <vector>
|
||||
#include <Collage/types/animation.h>
|
||||
#include <Collage/types/model.h>
|
||||
#include <J3ML/LinearAlgebra/Vector3.hpp>
|
||||
#include <J3ML/LinearAlgebra/Vector2.hpp>
|
||||
#include <J3ML/Geometry/OBB.hpp>
|
||||
#include <J3ML/LinearAlgebra/Vector3.h>
|
||||
#include <J3ML/LinearAlgebra/Vector2.h>
|
||||
#include <J3ML/Geometry/OBB.h>
|
||||
#include <glad/glad.h>
|
||||
|
||||
///Forward declaration of entity.
|
||||
|
1
reci/scripts/builddeps.reci
Normal file
1
reci/scripts/builddeps.reci
Normal file
@@ -0,0 +1 @@
|
||||
Main:new("Install build dependencies", "apt-get install -yq pkg-config libgl-dev libudev-dev libfreetype6-dev")
|
@@ -3,7 +3,7 @@
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <Redacted3D/types/entity/3D/moby.h>
|
||||
#include <Redacted3D/types/entity/moby.h>
|
||||
|
||||
class Ball : public Moby {
|
||||
public:
|
||||
|
@@ -3,7 +3,7 @@
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <Redacted3D/types/entity/3D/moby.h>
|
||||
#include <Redacted3D/types/entity/moby.h>
|
||||
|
||||
class Cube : public Moby {
|
||||
public:
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#include <Redacted3D/types/entity/3D/skybox.h>
|
||||
#include <Redacted3D/types/entity/skybox.h>
|
||||
#pragma once
|
||||
|
||||
class DemoSkybox : public Skybox {
|
||||
|
@@ -1,12 +1,13 @@
|
||||
#pragma once
|
||||
#include <JGL/JGL.h>
|
||||
#include <JGL/Colors.h>
|
||||
|
||||
namespace Fonts {
|
||||
inline JGL::Font Jupiteroid;
|
||||
inline JGL::Font ModeSeven;
|
||||
inline int Jupiteroid = -1;
|
||||
inline int ModeSeven = -1;
|
||||
|
||||
inline void initFonts() {
|
||||
Jupiteroid = JGL::Font("assets/fonts/Jupiteroid/JupiteroidRegular.ttf");
|
||||
ModeSeven = JGL::Font("assets/fonts/modeseven.ttf");
|
||||
Jupiteroid = JGL::LoadFont("assets/fonts/Jupiteroid/JupiteroidRegular.ttf");
|
||||
ModeSeven = JGL::LoadFont("assets/fonts/modeseven.ttf");
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
#include <Redacted3D/types/entity/3D/camera.h>
|
||||
#include <Redacted3D/types/entity/camera.h>
|
||||
#include <fonts.h>
|
||||
|
||||
class FreeCam : public Camera {
|
||||
|
@@ -10,7 +10,6 @@ int main()
|
||||
engine->window = new ReWindow::RWindow("Re3D Test Application", 1152, 864, RenderingAPI::OPENGL);
|
||||
engine->world = new(World);
|
||||
Engine::init();
|
||||
JGL::InitTextEngine();
|
||||
JGL::Update(engine->window->getSize());
|
||||
Fonts::initFonts();
|
||||
engine->window->setVsyncEnabled(false);
|
||||
@@ -38,7 +37,6 @@ int main()
|
||||
skybox->setAngle(0,0,0);
|
||||
skybox->SetParent(engine->world);
|
||||
|
||||
JGL::J3D::Init(engine->window->getSize(), engine->fov, engine->farPlane);
|
||||
engine->renderLoop();
|
||||
}
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#include <freeCam.h>
|
||||
#include <mcolor.h>
|
||||
#include <JGL/Colors.h>
|
||||
|
||||
void FreeCam::pre_render() {
|
||||
if (engine->window->isKeyDown(Keys::W))
|
||||
@@ -43,19 +43,17 @@ Vector3 textAngle = {0,0,0};
|
||||
void FreeCam::jglRenderPass() {
|
||||
textAngle.x = textAngle.x - (96.f * engine->frameDelta);
|
||||
using namespace JGL;
|
||||
|
||||
J3D::Begin();
|
||||
glDisable(GL_CULL_FACE);
|
||||
J3D::DrawString(Colors::Red, "Text", {0, -2, 0}, textAngle, 4.f, 32, Fonts::Jupiteroid);
|
||||
glEnable(GL_CULL_FACE);
|
||||
J3D::DrawString(JGL::Colors::Red, "Text", {0, -2, 0}, textAngle, 4.f, 32, Fonts::Jupiteroid);
|
||||
J3D::End();
|
||||
|
||||
J2D::Begin();
|
||||
J2D::FillRect({255,0,0,128}, {0, 72}, {100, 100});
|
||||
J2D::FillCircle(Colors::White, {16, 128}, 12, 16);
|
||||
J2D::FillCircle(JGL::Colors::White, {16, 128}, 12, 16);
|
||||
|
||||
J2D::DrawString(Colors::White, "Framerate: " + std::to_string((int) engine->framerate()), 0, 0, 1, 16, Fonts::Jupiteroid);
|
||||
J2D::DrawString(Colors::White, "Framecount: " + std::to_string(engine->frameCount), 0, 17, 1,16, Fonts::Jupiteroid);
|
||||
J2D::DrawString(Colors::White, "Position: " + std::to_string(position.x) + " " + std::to_string(position.y) + " " + std::to_string(position.z), 0, 33, 1,16, Fonts::Jupiteroid);
|
||||
J2D::DrawString(Colors::White, "ViewAngle: " + std::to_string(getAngle().x) + " " + std::to_string(getAngle().y) + " " + std::to_string(getAngle().z), 0, 50, 1,16, Fonts::Jupiteroid);
|
||||
J2D::DrawString(JGL::Colors::White, "Framerate: " + std::to_string((int) engine->framerate()), 0, -16, 1, 16, Fonts::Jupiteroid);
|
||||
J2D::DrawString(JGL::Colors::White, "Framecount: " + std::to_string(engine->frameCount), 0, -33, 1,16, Fonts::Jupiteroid);
|
||||
J2D::DrawString(JGL::Colors::White, "Position: " + std::to_string(position.x) + " " + std::to_string(position.y) + " " + std::to_string(position.z), 0, -50, 1,16, Fonts::Jupiteroid);
|
||||
J2D::DrawString(JGL::Colors::White, "ViewAngle: " + std::to_string(getAngle().x) + " " + std::to_string(getAngle().y) + " " + std::to_string(getAngle().z), 0, -67, 1,16, Fonts::Jupiteroid);
|
||||
J2D::End();
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@
|
||||
#include <thread>
|
||||
#include <JGL/JGL.h>
|
||||
#include <Redacted3D/engine/engine.h>
|
||||
#include <Redacted3D/types/entity/3D/camera.h>
|
||||
#include <Redacted3D/types/entity/camera.h>
|
||||
#include <jlog/jlog.hpp>
|
||||
|
||||
using namespace J3ML;
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#include <Redacted3D/engine/occlusion.h>
|
||||
#include <Redacted3D/types/entity/3D/entity.h>
|
||||
#include <Redacted3D/types/entity/entity.h>
|
||||
|
||||
|
||||
bool Occlusion::frustumCull(Camera* camera, Entity* entity) { return false; }
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#include <Redacted3D/engine/world.h>
|
||||
#include <Redacted3D/types/entity/3D/moby.h>
|
||||
#include <Redacted3D/types/entity/moby.h>
|
||||
|
||||
|
||||
int DataModel::getEntityCount() const {
|
||||
@@ -14,6 +14,108 @@ int DataModel::getMobyCount() const {
|
||||
return count;
|
||||
}
|
||||
|
||||
void Entity::SetParent(Entity *parent) {
|
||||
// hold a reference to this so it doesn't get collected as we're working with it
|
||||
Entity *oldParent = this->parent;
|
||||
if (parent == oldParent)
|
||||
return;
|
||||
// Don't allow for an instance to be parented to itself
|
||||
if (this == parent)
|
||||
throw std::runtime_error("Cannot parent a widget to itself");
|
||||
if (this->IsAncestorOf(parent))
|
||||
throw std::runtime_error("Cannot create circular object reference");
|
||||
|
||||
for (Entity *ancestor: this->GetAncestors()) {
|
||||
if (oldParent && !ancestor->IsAncestorOf(parent) && parent != ancestor) {
|
||||
ancestor->DescendantRemoved(this);
|
||||
for (Entity *descendant: this->GetDescendants()) {
|
||||
ancestor->DescendantRemoved(descendant);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Remove ourselves from our parent (if we have one)
|
||||
if (this->parent) {
|
||||
parent->children.erase(std::remove(parent->children.begin(), parent->children.end(), this),
|
||||
parent->children.end());
|
||||
}
|
||||
// Update our old parent to the new one
|
||||
this->parent = parent;
|
||||
// If our parent is set to nullptr, we can't update it's vector of children
|
||||
if (!parent) { return; }
|
||||
parent->children.emplace_back(this);
|
||||
for (Entity* ancestor: this->GetAncestors()) {
|
||||
if (!oldParent || !(oldParent->IsDescendantOf(parent) && oldParent != ancestor)) {
|
||||
ancestor->DescendantAdded(this);
|
||||
for (auto* descendant : this->GetDescendants()) {
|
||||
ancestor->DescendantAdded(descendant);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Entity::IsDescendantOf(Entity *ancestor) {
|
||||
if (ancestor == nullptr)
|
||||
return false;
|
||||
Entity *instance = this;
|
||||
while (instance->GetParent()) {
|
||||
instance = instance->GetParent();
|
||||
if (instance == ancestor)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Entity::IsAncestorOf(Entity *descendant) {
|
||||
if (descendant == nullptr)
|
||||
return false;
|
||||
Entity *instance = descendant;
|
||||
while (instance->GetParent()) {
|
||||
instance = instance->GetParent();
|
||||
if (instance == this)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<Entity *> Entity::GetChildren() {
|
||||
return this->children;
|
||||
}
|
||||
|
||||
std::vector<Entity *> Entity::GetAncestors() {
|
||||
std::vector<Entity *> ancestors;
|
||||
for (Entity *ancestor = this->parent; ancestor; ancestor = ancestor->parent) {
|
||||
ancestors.push_back(ancestor);
|
||||
}
|
||||
return ancestors;
|
||||
}
|
||||
|
||||
std::vector<Entity *> Entity::GetDescendants() {
|
||||
std::vector<Entity *> descendants;
|
||||
for (auto& child: this->children) {
|
||||
descendants.push_back(child);
|
||||
std::vector<Entity *> recursiveDescendants = child->GetDescendants();
|
||||
descendants.insert(descendants.end(), recursiveDescendants.begin(), recursiveDescendants.end());
|
||||
}
|
||||
return descendants;
|
||||
}
|
||||
|
||||
Entity *Entity::Add(Entity *newChild) {
|
||||
newChild->SetParent(this);
|
||||
return newChild;
|
||||
}
|
||||
|
||||
Entity *Entity::GetFamilyTreeRoot() const {
|
||||
|
||||
//if (JUI::Scene* scene = dynamic_cast<JUI::Scene*>(parent); scene != nullptr)
|
||||
|
||||
// This is retarded, Fix ASAP!
|
||||
auto parent = this->GetParent();
|
||||
if (parent->GetParent() == nullptr)
|
||||
return parent;
|
||||
return parent->GetFamilyTreeRoot();
|
||||
}
|
||||
|
||||
void World::setAmbientLightColor(GLfloat red, GLfloat green, GLfloat blue) {
|
||||
GLfloat ambient[4] = {red, green, blue, 0.0f};
|
||||
globalLightColor.x = red; globalLightColor.y = green; globalLightColor.z = blue;
|
||||
|
@@ -1,108 +0,0 @@
|
||||
#include <Redacted3D/types/entity/baseEntity.h>
|
||||
#include <stdexcept>
|
||||
|
||||
void BaseEntity::SetParent(BaseEntity* parent) {
|
||||
// hold a reference to this so it doesn't get collected as we're working with it
|
||||
BaseEntity* oldParent = this->parent;
|
||||
if (parent == oldParent)
|
||||
return;
|
||||
// Don't allow for an instance to be parented to itself
|
||||
if (this == parent)
|
||||
throw std::runtime_error("Cannot parent a widget to itself");
|
||||
if (this->IsAncestorOf(parent))
|
||||
throw std::runtime_error("Cannot create circular object reference");
|
||||
|
||||
for (BaseEntity* ancestor: this->GetAncestors()) {
|
||||
if (oldParent && !ancestor->IsAncestorOf(parent) && parent != ancestor) {
|
||||
ancestor->DescendantRemoved(this);
|
||||
for (BaseEntity* descendant: this->GetDescendants()) {
|
||||
ancestor->DescendantRemoved(descendant);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Remove ourselves from our parent (if we have one)
|
||||
if (this->parent) {
|
||||
for (auto it = parent->children.begin(); it != parent->children.end(); ++it) {
|
||||
if (*it == this) {
|
||||
parent->children.erase(it);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Update our old parent to the new one
|
||||
this->parent = parent;
|
||||
// If our parent is set to nullptr, we can't update it's vector of children
|
||||
if (!parent) { return; }
|
||||
parent->children.emplace_back(this);
|
||||
for (BaseEntity* ancestor: this->GetAncestors()) {
|
||||
if (!oldParent || !(oldParent->IsDescendantOf(parent) && oldParent != ancestor)) {
|
||||
ancestor->DescendantAdded(this);
|
||||
for (auto* descendant : this->GetDescendants()) {
|
||||
ancestor->DescendantAdded(descendant);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool BaseEntity::IsDescendantOf(BaseEntity* ancestor) {
|
||||
if (ancestor == nullptr)
|
||||
return false;
|
||||
BaseEntity* instance = this;
|
||||
while (instance->GetParent()) {
|
||||
instance = instance->GetParent();
|
||||
if (instance == ancestor)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool BaseEntity::IsAncestorOf(BaseEntity* descendant) {
|
||||
if (descendant == nullptr)
|
||||
return false;
|
||||
BaseEntity* instance = descendant;
|
||||
while (instance->GetParent()) {
|
||||
instance = instance->GetParent();
|
||||
if (instance == this)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<BaseEntity* > BaseEntity::GetChildren() {
|
||||
return this->children;
|
||||
}
|
||||
|
||||
std::vector<BaseEntity* > BaseEntity::GetAncestors() {
|
||||
std::vector<BaseEntity* > ancestors;
|
||||
for (BaseEntity* ancestor = this->parent; ancestor; ancestor = ancestor->parent) {
|
||||
ancestors.push_back(ancestor);
|
||||
}
|
||||
return ancestors;
|
||||
}
|
||||
|
||||
std::vector<BaseEntity* > BaseEntity::GetDescendants() {
|
||||
std::vector<BaseEntity* > descendants;
|
||||
for (auto& child: this->children) {
|
||||
descendants.push_back(child);
|
||||
std::vector<BaseEntity* > recursiveDescendants = child->GetDescendants();
|
||||
descendants.insert(descendants.end(), recursiveDescendants.begin(), recursiveDescendants.end());
|
||||
}
|
||||
return descendants;
|
||||
}
|
||||
|
||||
BaseEntity* BaseEntity::Add(BaseEntity* newChild) {
|
||||
newChild->SetParent(this);
|
||||
return newChild;
|
||||
}
|
||||
|
||||
BaseEntity* BaseEntity::GetFamilyTreeRoot() const {
|
||||
|
||||
//if (JUI::Scene* scene = dynamic_cast<JUI::Scene*>(parent); scene != nullptr)
|
||||
|
||||
// This is retarded, Fix ASAP!
|
||||
auto parent = this->GetParent();
|
||||
if (parent->GetParent() == nullptr)
|
||||
return parent;
|
||||
return parent->GetFamilyTreeRoot();
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
#include <array>
|
||||
#include <Redacted3D/types/entity/3D/camera.h>
|
||||
#include <Redacted3D/types/entity/camera.h>
|
||||
|
||||
std::array<GLfloat, 16> lookAt(const Vector3& eye, const Vector3& center, const Vector3& up) {
|
||||
Vector3 f = Vector3::Normalized((center - eye));
|
@@ -1,6 +1,6 @@
|
||||
#include <Redacted3D/types/entity/3D/entity.h>
|
||||
#include <Redacted3D/types/entity/entity.h>
|
||||
#include <Redacted3D/engine/occlusion.h>
|
||||
#include <Redacted3D/types/entity/3D/camera.h>
|
||||
#include <Redacted3D/types/entity/camera.h>
|
||||
#include <Redacted3D/engine/engine.h>
|
||||
#include <Redacted3D/engine/utils/instanceOf.h>
|
||||
#include <jlog/jlog.hpp>
|
||||
@@ -40,7 +40,7 @@ void Entity::SetPos(const Vector3 &rhs) {
|
||||
Entity::Entity() {
|
||||
position = {0,0,0};
|
||||
ticksAlive = 0;
|
||||
children = std::vector<BaseEntity*> ();
|
||||
children = std::vector<Entity*> ();
|
||||
parent = nullptr;
|
||||
scale = {1.0f, 1.0f, 1.0f};
|
||||
|
||||
@@ -61,14 +61,14 @@ void Entity::loadTexture(const std::string& file) {
|
||||
for (const auto* e : engine->world->GetChildren())
|
||||
if (instanceOf(this, e))
|
||||
return;
|
||||
Texture(this, file.c_str(), true);
|
||||
Texture texture(this, file.c_str(), true);
|
||||
}
|
||||
|
||||
void Entity::loadMultiTexture(const std::vector<std::string>& files) {
|
||||
for (const auto* e : engine->world->GetChildren())
|
||||
if (instanceOf(this, e))
|
||||
return;
|
||||
MultiTexture(this, files, true);
|
||||
MultiTexture texture(this, files, true);
|
||||
}
|
||||
|
||||
void Entity::loadMotionTexture(const std::vector<std::string>& files, u16 frameDelta, bool doAnim) {
|
||||
@@ -76,13 +76,13 @@ void Entity::loadMotionTexture(const std::vector<std::string>& files, u16 frameD
|
||||
if (instanceOf(this, e))
|
||||
return;
|
||||
MotionTexture(this, files, frameDelta, true, doAnim);
|
||||
|
||||
}
|
||||
|
||||
void Entity::loadGeometry(const std::string& file) {
|
||||
for (const auto& e : engine->world->GetChildren())
|
||||
if (instanceOf(this, e))
|
||||
return;
|
||||
for (const auto& vA : engine->world->geometryList)
|
||||
for (const auto& reference : vA->usedBy)
|
||||
if (instanceOf(this, reference))
|
||||
return;
|
||||
VertexArray vArray(this, file, true);
|
||||
}
|
||||
|
||||
@@ -108,26 +108,26 @@ Texture* Entity::getTexture() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
inline Texture* baseTexture = new Texture();
|
||||
inline Texture* baseTexture = new Texture;
|
||||
void Entity::render() {
|
||||
if (!baseTexture) {
|
||||
GLuint handle;
|
||||
glGenTextures(1, &handle);
|
||||
glBindTexture(GL_TEXTURE_2D, handle);
|
||||
Texture t;
|
||||
glGenTextures(1, &t.id);
|
||||
glBindTexture(GL_TEXTURE_2D, t.id);
|
||||
|
||||
Color4 whitePixel = {255, 255, 255, 255};
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, &whitePixel);
|
||||
unsigned char whitePixel[4] = { 255, 255, 255, 255};
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, whitePixel);
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glActiveTexture(0);
|
||||
baseTexture->SetTextureHandle(handle);
|
||||
baseTexture = new Texture(t);
|
||||
}
|
||||
|
||||
MultiTexture texture;
|
||||
texture.SetTextureHandle(baseTexture->GetGLTextureHandle());
|
||||
texture.id = baseTexture->id;
|
||||
|
||||
if (auto* t = dynamic_cast<MultiTexture*>(getTexture())) {
|
||||
texture.multi.emplace_back(*t);
|
||||
@@ -155,7 +155,7 @@ void Entity::render() {
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glBindTexture(GL_TEXTURE_2D, texture.GetGLTextureHandle());
|
||||
glBindTexture(GL_TEXTURE_2D, texture.id);
|
||||
//Texture unit mode.
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||
|
||||
@@ -186,7 +186,7 @@ void Entity::render() {
|
||||
|
||||
//Texture unit mode.
|
||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND);
|
||||
glBindTexture(GL_TEXTURE_2D, t.GetGLTextureHandle());
|
||||
glBindTexture(GL_TEXTURE_2D, t.id);
|
||||
i++;
|
||||
}
|
||||
getGeometry()->draw();
|
@@ -1,4 +1,4 @@
|
||||
#include <Redacted3D/types/entity/3D/moby.h>
|
||||
#include <Redacted3D/types/entity/moby.h>
|
||||
#include <Redacted3D/engine/engine.h>
|
||||
using namespace J3ML;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#include <Redacted3D/types/entity/3D/skybox.h>
|
||||
#include <Redacted3D/types/entity/skybox.h>
|
||||
#include <Redacted3D/engine/engine.h>
|
||||
#include <Redacted3D/types/entity/3D/camera.h>
|
||||
#include <Redacted3D/types/entity/camera.h>
|
||||
|
||||
void Skybox::pre_render() {
|
||||
if (engine->world->getActiveCamera() != nullptr)
|
||||
@@ -10,7 +10,7 @@ void Skybox::pre_render() {
|
||||
void Skybox::render() {
|
||||
glPushMatrix();
|
||||
glTranslatef(position.x ,position.y, position.z);
|
||||
glBindTexture(GL_TEXTURE_2D, getTexture()->GetGLTextureHandle());
|
||||
glBindTexture(GL_TEXTURE_2D, getTexture()->id);
|
||||
glCullFace(GL_FRONT);
|
||||
glScalef(getScale().x, getScale().y, getScale().z);
|
||||
getGeometry()->draw();
|
@@ -1,18 +1,16 @@
|
||||
#include <ReTexture/Texture.h>
|
||||
#include <ReTexture/rTexture.h>
|
||||
#include <Redacted3D/types/texture.h>
|
||||
#include <Redacted3D/engine/engine.h>
|
||||
|
||||
//TODO use JGL implementation of texture.
|
||||
|
||||
void Texture::load(Entity* entity, const std::string& file, bool storeOnTextureList) {
|
||||
auto* texture = new ReTexture::SoftwareTexture(file, {ReTexture::TextureFlag::INVERT_Y});
|
||||
auto* texture = new RTexture(file, {RTextureFlag::INVERT_Y});
|
||||
|
||||
glGenTextures(1, &texture_handle);
|
||||
glBindTexture(GL_TEXTURE_2D, texture_handle);
|
||||
if (texture->getTextureFormat() == ReTexture::TextureFormat::RGBA)
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture->getWidth(), texture->getHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, texture->pixelData.data());
|
||||
if (texture->getTextureFormat() == ReTexture::TextureFormat::RGB)
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, texture->getWidth(), texture->getHeight(), 0, GL_RGB, GL_UNSIGNED_BYTE, texture->pixelData.data());
|
||||
glGenTextures(1, &id);
|
||||
glBindTexture(GL_TEXTURE_2D, id);
|
||||
if (texture->format == RTextureFormat::RGBA)
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture->width, texture->height, 0, GL_RGBA, GL_UNSIGNED_BYTE, texture->pixelData.data());
|
||||
if (texture->format == RTextureFormat::RGB)
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, texture->width, texture->height, 0, GL_RGB, GL_UNSIGNED_BYTE, texture->pixelData.data());
|
||||
delete texture;
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
@@ -22,10 +20,10 @@ void Texture::load(Entity* entity, const std::string& file, bool storeOnTextureL
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
|
||||
//If we can't load the missing texture
|
||||
if (file == "assets/textures/missing.png" && texture_handle == 0)
|
||||
if (file == "assets/textures/missing.png" && id == 0)
|
||||
engine->setError(ENGINE_ERROR_CODE::TEXTURE_NOT_FOUND, true);
|
||||
|
||||
if (texture_handle == 0)
|
||||
if (id == 0)
|
||||
engine->setError(ENGINE_ERROR_CODE::TEXTURE_NOT_FOUND, false),
|
||||
load(entity, "assets/textures/missing.png", false);
|
||||
|
||||
@@ -38,12 +36,12 @@ void Texture::erase() {
|
||||
Texture::erase(this);
|
||||
}
|
||||
|
||||
Texture::Texture(Entity* entity, const char* filePath, bool storeOnTextureList) {
|
||||
Texture::Texture(Entity* entity, const char *filePath, bool storeOnTextureList) {
|
||||
load(entity, filePath, storeOnTextureList);
|
||||
}
|
||||
|
||||
void Texture::erase(Texture* texture) const {
|
||||
glDeleteTextures(1, &texture->texture_handle);
|
||||
glDeleteTextures(1, &texture->id);
|
||||
|
||||
//If texture is being deleted while in use.
|
||||
//It won't crash the program. But it'll cause the texture to be reloaded from disk unnecessarily.
|
||||
@@ -52,7 +50,7 @@ void Texture::erase(Texture* texture) const {
|
||||
|
||||
if (auto* t = dynamic_cast<MultiTexture*>(texture))
|
||||
for (auto &m : t->multi)
|
||||
glDeleteTextures(1, &m.texture_handle);
|
||||
glDeleteTextures(1, &m.id);
|
||||
|
||||
for (int i = 0; i < engine->world->textureList.size(); i++)
|
||||
if (engine->world->textureList[i] == texture)
|
||||
@@ -62,11 +60,11 @@ void Texture::erase(Texture* texture) const {
|
||||
MultiTexture::MultiTexture(Entity* entity, const std::vector<std::string>& textures, bool storeOnTextureList) {
|
||||
Texture base;
|
||||
for (const auto& t : textures) {
|
||||
if (texture_handle != 0)
|
||||
if (id != 0)
|
||||
multi.emplace_back(entity, t.c_str(), false);
|
||||
else
|
||||
base = Texture(entity, t.c_str(), false),
|
||||
texture_handle = base.GetGLTextureHandle(),
|
||||
id = base.id,
|
||||
usedBy = base.usedBy;
|
||||
}
|
||||
|
||||
@@ -91,7 +89,7 @@ MotionTexture::MotionTexture(Entity* entity, const std::vector<std::string>& tex
|
||||
for (auto& t : extra)
|
||||
motion.emplace_back(entity, t.c_str(), false);
|
||||
|
||||
texture_handle = base.GetGLTextureHandle();
|
||||
id = base.id;
|
||||
usedBy = base.usedBy;
|
||||
if (storeOnTextureList)
|
||||
engine->world->textureList.push_back(new MotionTexture(*this));
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#include <fstream>
|
||||
#include <Redacted3D/types/track.h>
|
||||
#include <Redacted3D/engine/engine.h>
|
||||
#include <Redacted3D/types/entity/3D/moby.h>
|
||||
#include <Redacted3D/types/entity/moby.h>
|
||||
#include <jlog/jlog.hpp>
|
||||
|
||||
Track::Track(const std::string &file, Moby* moby) {
|
||||
|
Reference in New Issue
Block a user