removed useless stuff
This commit is contained in:
File diff suppressed because it is too large
Load Diff
2
rust/.gitignore
vendored
2
rust/.gitignore
vendored
@@ -1,2 +0,0 @@
|
||||
/target
|
||||
**/*.rs.bk
|
||||
95
rust/Cargo.lock
generated
95
rust/Cargo.lock
generated
@@ -1,95 +0,0 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "c2-chacha"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"ppv-lite86 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.1.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"wasi 0.9.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "global_illumination_2d_render"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.66"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "ppv-lite86"
|
||||
version = "0.2.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.7.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_chacha"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"c2-chacha 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_hc"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.9.0+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[metadata]
|
||||
"checksum c2-chacha 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "214238caa1bf3a496ec3392968969cab8549f96ff30652c9e56885329315f6bb"
|
||||
"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
||||
"checksum getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb"
|
||||
"checksum libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)" = "d515b1f41455adea1313a4a2ac8a8a477634fbae63cc6100e3aebb207ce61558"
|
||||
"checksum ppv-lite86 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b"
|
||||
"checksum rand 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3ae1b169243eaf61759b8475a998f0a385e42042370f3a7dbaf35246eacc8412"
|
||||
"checksum rand_chacha 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "03a2a90da8c7523f554344f921aa97283eadf6ac484a6d2a7d0212fa7f8d6853"
|
||||
"checksum rand_core 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
|
||||
"checksum rand_hc 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"
|
||||
"checksum wasi 0.9.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)" = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
|
||||
@@ -1,8 +0,0 @@
|
||||
[package]
|
||||
name = "global_illumination_2d_render"
|
||||
version = "0.1.0"
|
||||
authors = ["Ben <benjaminkyd@gmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
rand = "0.7.2"
|
||||
@@ -1,28 +0,0 @@
|
||||
use rand::Rng;
|
||||
|
||||
fn main() {
|
||||
let set: [i32; 6] = [1, 2, 3, 4, 5, 6];
|
||||
|
||||
for num in set.iter() {
|
||||
print(num.to_string());
|
||||
}
|
||||
linebreak();
|
||||
|
||||
let x = rand::thread_rng().gen_range(1, 101);
|
||||
|
||||
if x < 50 {
|
||||
print("Less than 50".to_string());
|
||||
}
|
||||
|
||||
let string: String = x.to_string();
|
||||
|
||||
print(string);
|
||||
}
|
||||
|
||||
fn print(ln: String) {
|
||||
println!("{}", ln);
|
||||
}
|
||||
|
||||
fn linebreak() {
|
||||
println!("");
|
||||
}
|
||||
112
src/display.cpp
112
src/display.cpp
@@ -1,112 +0,0 @@
|
||||
#include "display.hpp"
|
||||
|
||||
#include <memory>
|
||||
|
||||
Aeon::DisplayBuff::DisplayBuff( int wit, int hei )
|
||||
: data(nullptr)
|
||||
, w( wit ), h( hei )
|
||||
{
|
||||
data = (glm::vec3*)malloc( sizeof(glm::vec3) * (w * h) );
|
||||
}
|
||||
|
||||
void Aeon::DisplayBuff::Set( int x, int y, glm::vec3 v )
|
||||
{
|
||||
data[y * w + x] = v;
|
||||
}
|
||||
|
||||
glm::vec3 Aeon::DisplayBuff::At( int x, int y )
|
||||
{
|
||||
return data[y * w + x];
|
||||
}
|
||||
|
||||
Aeon::DisplayBuff::~DisplayBuff()
|
||||
{
|
||||
free( data );
|
||||
}
|
||||
|
||||
|
||||
Aeon::Display::Display()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Aeon::Display::Init( int x, int y )
|
||||
{
|
||||
this->Construct( x, y, 1, 1 );
|
||||
mW = x; mH = y;
|
||||
}
|
||||
|
||||
void Aeon::Display::Init( int x, int y, std::string title )
|
||||
{
|
||||
sAppName = title;
|
||||
this->Construct( x, y, 1, 1 );
|
||||
mW = x; mH = y;
|
||||
}
|
||||
|
||||
void Aeon::Display::SetTitle( std::string title )
|
||||
{
|
||||
sAppName = title;
|
||||
}
|
||||
|
||||
void Aeon::Display::NewFrame( DisplayBuff* buf )
|
||||
{
|
||||
if ( buf->w != mW || buf->h != mH )
|
||||
return;
|
||||
mNextFrame = buf;
|
||||
mNewFrame = true;
|
||||
}
|
||||
|
||||
bool Aeon::Display::OnUserCreate()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Aeon::Display::OnUserUpdate( float fElapsedTime )
|
||||
{
|
||||
// Check if theres a more recent framebuffer
|
||||
// then apply it
|
||||
|
||||
if ( mNewFrame )
|
||||
{
|
||||
|
||||
if ( mNextFrame == nullptr )
|
||||
{
|
||||
mNewFrame = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
for ( int x = 0; x < mNextFrame->w; x++ )
|
||||
for ( int y = 0; y < mNextFrame->w; y++ )
|
||||
{
|
||||
// tonemap, gamma correct and write
|
||||
// colours are assumed to input as HDR
|
||||
|
||||
auto Clamp = []( glm::vec3 p, float max, float min ) -> glm::vec3
|
||||
{
|
||||
glm::vec3 ret;
|
||||
ret.r = std::max( min, std::min( p.r, max ) );
|
||||
ret.g = std::max( min, std::min( p.g, max ) );
|
||||
ret.b = std::max( min, std::min( p.b, max ) );
|
||||
return ret;
|
||||
};
|
||||
|
||||
// Just clamping now
|
||||
glm::vec3 p = Clamp( mNextFrame->At( x, y ), 1.0f, 0.0f );
|
||||
|
||||
// Gamma correction
|
||||
static const float Gamma = 1.0f / 2.2f;
|
||||
|
||||
olc::Pixel pix(
|
||||
(uint8_t)( pow( p.r, Gamma ) * 255.0f ),
|
||||
(uint8_t)( pow( p.g, Gamma ) * 255.0f ),
|
||||
(uint8_t)( pow( p.b, Gamma ) * 255.0f ) );
|
||||
|
||||
DrawRect( x, y, 1, 1, pix );
|
||||
}
|
||||
|
||||
mNextFrame = nullptr;
|
||||
mNewFrame = false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <olcPixelGameEngine.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <mutex>
|
||||
|
||||
#include <glm/vec3.hpp>
|
||||
|
||||
namespace Aeon
|
||||
{
|
||||
|
||||
struct DisplayBuff
|
||||
{
|
||||
DisplayBuff( int w, int h );
|
||||
glm::vec3* data;
|
||||
int w, h;
|
||||
void Set( int x, int y, glm::vec3 v );
|
||||
glm::vec3 At( int x, int y );
|
||||
~DisplayBuff();
|
||||
};
|
||||
|
||||
// Can be replaced with literally anything
|
||||
// for the time being NEEDS to run on main thread
|
||||
class Display : public olc::PixelGameEngine
|
||||
{
|
||||
public:
|
||||
Display();
|
||||
void Init( int x, int y );
|
||||
void Init( int x, int y, std::string title );
|
||||
|
||||
void SetTitle( std::string title );
|
||||
|
||||
void NewFrame( DisplayBuff* buf );
|
||||
|
||||
private:
|
||||
// Cleared every swap
|
||||
std::mutex mFrameMutex;
|
||||
DisplayBuff* mNextFrame = nullptr;
|
||||
bool mNewFrame = false;
|
||||
|
||||
|
||||
int mW, mH;
|
||||
|
||||
protected:
|
||||
bool OnUserCreate() override;
|
||||
bool OnUserUpdate( float fElapsedTime ) override;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
39
src/main.cpp
39
src/main.cpp
@@ -1,39 +0,0 @@
|
||||
#define OLC_PGE_APPLICATION
|
||||
|
||||
#include "display.hpp"
|
||||
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
|
||||
void EngineThread( Aeon::Display* disp )
|
||||
{
|
||||
Aeon::DisplayBuff buf( 500, 500 );
|
||||
while ( true )
|
||||
{
|
||||
|
||||
for ( int x = 0; x < 500; x++ )
|
||||
for ( int y = 0; y < 500; y++ )
|
||||
buf.Set( x, y, { (float)( rand() % 255 ) / 255.0f,
|
||||
(float)( rand() % 255 ) / 255.0f,
|
||||
(float)( rand() % 255 ) / 255.0f } );
|
||||
|
||||
disp->NewFrame( &buf );
|
||||
|
||||
static std::chrono::milliseconds dura( 10 );
|
||||
std::this_thread::sleep_for( dura );
|
||||
}
|
||||
}
|
||||
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
Aeon::Display display;
|
||||
|
||||
display.Init( 500, 500 );
|
||||
display.SetTitle( "BRuh" );
|
||||
|
||||
std::thread thread( EngineThread, &display );
|
||||
|
||||
display.Start();
|
||||
|
||||
thread.detach();
|
||||
}
|
||||
31
src/poly.cpp
31
src/poly.cpp
@@ -1,31 +0,0 @@
|
||||
#include "poly.hpp"
|
||||
|
||||
using namespace Aeon::Renderer;
|
||||
|
||||
Polygon::Polygon()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Polygon::Polygon( std::vector<Segment> segments )
|
||||
{
|
||||
for ( const auto& segment : segments )
|
||||
AddSide( segment );
|
||||
}
|
||||
|
||||
int Polygon::NumSides()
|
||||
{
|
||||
return mSides.size();
|
||||
}
|
||||
|
||||
int Polygon::AddSide( Segment segment )
|
||||
{
|
||||
mIterator++;
|
||||
mSides[mIterator] = segment;
|
||||
return mIterator;
|
||||
}
|
||||
|
||||
void Polygon::RemoveSide( int segment )
|
||||
{
|
||||
mSides.erase( segment );
|
||||
}
|
||||
38
src/poly.hpp
38
src/poly.hpp
@@ -1,38 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
#include <glm/vec2.hpp>
|
||||
|
||||
namespace Aeon::Renderer
|
||||
{
|
||||
|
||||
struct Segment
|
||||
{
|
||||
glm::vec2 P1;
|
||||
glm::vec2 P2;
|
||||
// Perhaps material / surface properties?
|
||||
};
|
||||
|
||||
// Does no checks to see if sides are touching / connecting
|
||||
class Polygon
|
||||
{
|
||||
public:
|
||||
|
||||
Polygon();
|
||||
Polygon(std::vector<Segment> segments);
|
||||
|
||||
int NumSides();
|
||||
|
||||
// Returns local ID for the segment
|
||||
int AddSide( Segment segment );
|
||||
// Remove by ID
|
||||
void RemoveSide( int segment );
|
||||
|
||||
private:
|
||||
std::unordered_map<int, Segment> mSides;
|
||||
|
||||
int mIterator = 0;
|
||||
};
|
||||
|
||||
};
|
||||
@@ -1,23 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
// The renderer will need to render to some sort of buffer
|
||||
// which the display, in this case, temporarily the pixel
|
||||
// game engine, will display.
|
||||
|
||||
// The primary feature of the engine's rendere will be
|
||||
// global illumination, which i will later offload to the
|
||||
// GPU
|
||||
|
||||
// The engine will need to be able to render polygons as well
|
||||
// as sprites eventually, for now though i will focus on
|
||||
// polygons, as they work with global illumination best.
|
||||
|
||||
namespace Aeon::Renderer
|
||||
{
|
||||
|
||||
class Renderer
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user