unendlicherPing / cbEngine

A small, experimental 64x64 pixel based game engine.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cbEngine

A small, experimental 64x64 pixel based game engine made using C++ and OpenGL.

Info

cbEngine was inspired when I thought about creating a custom engine for LowRezJam, I wanted it to be very simple and low level, in this case - literally just providing a graphics window and drawing a custom pixel array to the screen, along with a few other functions to improve usability.

cbEngine is not architectured very well - it was made over the course of a few days as I learnt OpenGL and more about C++. I intended to turn it into a C++ static library but have not gotten round to it - doing that would improve the workflow significantly.

To learn about OpenGL I used LearnOpenGL, a really useful tool for understanding the library. It also has instructions on how to install the required libraries - although I used MinGW for this project so some steps are slightly different.

Getting Started

To get the engine working correctly, there are some additional libraries that need to be installed.

Requirements:

Put the main glad.c file in the /src folder.

Place the library files in a folder called /lib - they should be called libglad.a, libglfw3.a and libglfw3dll.a.

Then place the header files in folders in the include directory. Place the GLAD header in /include/glad/, then the GLFW one in GLFW include/GLFW/, then KHR in /include/KHR/.

Place the glfw3.dll file in the main folder, where the output .exe file will be located.

From there, to build the sample code simply run build.bat or the makefile on default.

Sample Code

#include "engine.h"

//Called before the first update
void Start()
{
    std::cout << "Start" << std::endl;

    SetVsync(false);

    SetPixel(1, 1, 255, 255, 255);
    SetPixel(64, 64, 255, 255, 255);
      

    Pixel  pixel  =  GetPixel(1,  1);
    std::cout  <<  pixel.r  <<  std::endl; //255
    
}

//Called every frame
void Update(float deltaTime)
{
    std::cout << 1 / deltaTime << std::endl;

    if (IsKeyPressed(KEY_SPACE))
    {
        std::cout << "Pressed" << std::endl;
    }
}

//Called once the window has closed
void Finish()
{
    std::cout << "Finish" << std::endl;
}

//Init the engine here
int main()
{
    InitWindow(Start, Update, Finish);
   
    return 0;
}

About

A small, experimental 64x64 pixel based game engine.

License:MIT License


Languages

Language:C++ 73.3%Language:C 23.5%Language:Makefile 2.9%Language:Batchfile 0.3%