Legend Terrain

A dive into the feasability of procedural worlds.

Back Go to Github

Legend Terrain 0.1

This step of the project was really what set everything into motion, good and bad. It was at this point that I began learning OpenGL.

It took weeks of tutorials to get me to a point where I was mildly confident. I kept the "SFML Style" game header because it was what I was comfortable with...

Below is a little snippet of the "Format", this partially was responsible for the failure. I shouldn't have just stucl with what I knew.


#ifndef GAME_H
#define GAME_H

#include "Engine.h"

class Game
{
public:
    Game();
    void run();

private:
    void processInput();
    void update(float dt);
    void render();

    GLFWwindow* window = nullptr;

    Engine* engine = nullptr;

    std::vector<Object*> terrain;
    //Object* testMesh = nullptr;

    bool left = false;
    bool right = false;
    bool forward = false;
    bool backward = false;
    bool up = false;
    bool down = false;
};

#endif
            

Inheritance and Polymorphism

I feel like adding these design choices from the get-go was a good idea.

However, I thought that it was simple enough and that I didn't need to spend that much time on it.

Below is some naive code, that I thought would work in the long run...


#ifndef OBJECT_H
#define OBJECT_H

class Object {
public:
    Object() {}
    virtual void draw() = 0;
    virtual void move(float x = 0.f, float y = 0.f, float z = 0.f) = 0;
    virtual void rotate(float x = 0.f, float y = 0.f, float z = 0.f) = 0;
};
    
#endif

Why is it bad?

Well I'm glad you asked, the reason is to do with the fact that it doesn't properly handle itself.

In an ideal world it would manage its own existence in the current scope with smart pointers.

In an ideal world it would also emmit a signal at specific events that could be overridden.

Finally, I will leave you with a snippet of the function definition for setting up the 3d mesh.

Inside the function was about 200 lines of nonsense, but it worked! But just because it worked doesn't mean it's good.


void generate(GLuint& _VAO,
			GLuint& _VBO,
			GLuint& _EBO,
			GLuint& _VBO_Tex,
			size_t _verticiesSize,
			float* _verticies,
			size_t _tec_coordsSize,
			float* _tec_coords,
			size_t _indicesSize,
			unsigned int* _indices,
			int amountOfIndicies,
			int numOfVert);
        
LegendTerrain 0.1 Screenshot
Next