Giter Club home page Giter Club logo

kerosene's Introduction

kerosene

  • gameengine
  • c++
  • cross-platform (linux/windows)(x86/x64)
  • opengl 3.3+

1. introduction

building

windows
  • microsoft visual studio 2015 use the provided solution engine.sln.
linux
  • todo

contribution

3rd party software used

  • zlib 1.2.8
  • libpng 1.6.23

2. code

2.1 contract

make visible what the function requires and ensures after its execution.

Requires( <bool> ); // Required by the function to work properly
Assert( <bool> );   // Some in-function check of sanity 
Ensures( <bool> );  // What the function can ensure after its execution

2.2 guard

make guard-checks visible.

Guard( <bool> ) return;

2.3 pointers

raw pointers are strictly forbidden! use either owner<T>/weak<T> for single ownership or shared_ptr<T>/weak_ptr<T> for shared ownership. Every object, unless a 3rd library promises to manage the life time of a raw pointer, has it's lifetime to be managed by a smart pointer.

3. design

3.1 utils

stackbuffer

makes sure that active data is always continously aligned to the front of the buffer.

todo: improve description

3.2 render-engine

vertex

it's common to use different vertex types for different shaders. for example in one shader we only need the position (vec3) and the color (vec4), but for another shader we might add texture coordiantes (vec2). we can easiely declare new vertex types in the render-engine by creating a new class that derives from Vertex. all we have to do now is to implement the three virtual methods like for example we did for Vertex_pc that contains a position (vec3) and a color (vec4).

first we declare the layout of the vertex in the shader. this enables us to access the attributes of the vertex class later via this attribute names in the shader. the order of this layout is important for the next method to implement Vertex::data().

VertexLayout Vertex_pc::layout() const
{
    return{ { {"vec3", "position", 1}, 
              {"vec4", "color",    2} } };
}

next we write the vertexs data into a vector so that the renderengine can submit it to the gpu. it is important that the order of attributes are corresponding to the vertex layout we defined above.

vector<float> Vertex_pc::data() const
{
    vector<float> data;
    data.reserve(7);
    data.push_back(position.x);
    data.push_back(position.y);
    data.push_back(position.z);
    data.push_back(color.x);
    data.push_back(color.y);
    data.push_back(color.z);
    data.push_back(color.w);
    return std::move(data);
}

this method has to simply returns the size of the vertex in bytes.

uint32 Vertex_pc::bytesize() const 
{ 
    return 3 * FLOAT_BYTES + 4 * FLOAT_BYTES; 
}

kerosene's People

Contributors

n4n0lix avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

mitghi

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.