DEV Community

Lostybtw
Lostybtw

Posted on

Why OpenGL is better than a game engine?

OpenGL, the thing that it is. Its used to make games down to the basic levels of programming. It uses older languages mostly c++ for its code.

Why Learn OpenGL instead of a game engine?

  1. It is basic : Not easy but Basic, that means it gives you an understanding of the deep processes that go into rendering your favourite video games.

  2. Its well known & cross platform : Sure you can go use your win32 Api or DirectX, but OpenGL is the cross platform well known easier alternative.

  3. A game engine spoils you : Why I am glad I didn't use a game engine by DaFluffyPotato goes well over my point, A game engine does all those rendering processes for you. You don't get to learn a lot.

  4. More Code : Game Engines like Unity are pure GUI stuff.
    see this :-

Alt Text

Now this is OpenGL c++ :-

#include <glew.h>
#include <GLFW/glfw3.h>
#include <iostream>


int main(void)
{
    GLFWwindow* window;

    /* Initialize the library */
    if (!glfwInit())
        return -1;
    /* Create a windowed mode window and its OpenGL context */
    window = glfwCreateWindow(1920, 1080, "OpenGL", NULL, NULL);
    if (!window)
    {
        glfwTerminate();
        return -1;
    }

    /* Make the window's context current */
    glfwMakeContextCurrent(window);

    if (glewInit() != GLEW_OK)
        std::cout << "Error!" << std::endl;
    std::cout << glGetString(GL_VERSION) << std::endl;

    unsigned int buffer;
    float positions[6] = {
        -0.5f, -0.5f,
         0.0f, 0.5f,
         0.5f, -0.5f
    };

    glGenBuffers(1,&buffer);
    glBindBuffer(GL_ARRAY_BUFFER, buffer);
    glBufferData(GL_ARRAY_BUFFER, 6 * sizeof(float)  a=);
    /* Loop until the user closes the window */
    while (!glfwWindowShouldClose(window))
    {
        /* Render here */
        glClear(GL_COLOR_BUFFER_BIT);


        /* Swap front and back buffers */
        glfwSwapBuffers(window);

        /* Poll for and process events */
        glfwPollEvents();
    }

    glfwTerminate();
    return 0;
}
Enter fullscreen mode Exit fullscreen mode

I think you get the point now .

:)

PS.Comment pls(If I got anything wrong or just casually)

Top comments (3)

Collapse
 
thebonejarmer profile image
Ruben Labruyere • Edited

Someone I knew once rephrased my motivation for not using an existing engine very well: "Do not create a game engine, create the game instead from the ground up". And I stand true to those words as in my opinion, any engine will do as long if it fits your needs.

That said, in my case it is also a bit of control. I have had a not so pleasant experience with using existing engines. Some were abandoned, some were just right out buggy or lacking and feature requests were ignored by the devs. This created a big trust issue and even today when I can see that engines have become stable, I still cannot help but feel the lack of trust from the past.

For example, the video you posted mentions RayLib. While I managed to write my own 2D OpenGL framework in C#, I have a rough time doing the same in c++. RayLib seems perfect but one thing has been holding me back for using it. It seems to me (and please do correct me if I am wrong), that the whole project is done by Raysan only. And that troubles me. I am not so much just looking for a framework, I am looking for a framework for several years. Learning how to use an framework or engine is one thing, mastering it takes much longer.

And it happened a lot that because of above reasons I had to start from scratch, again and again, undoing all my mastered knowledge. This frustration eventually led me to the decision to write games from scratch. If you look at my github repos you will notice I have a framework for C# (Arqanore) and webgl (JarmerJS). Both are the result of many prototypes I created in the past. But both feel much and much more stable to me than other frameworks I found. And the best of all, they are mine. I get to say how they work and if something is not, I could fix it right away. And even the latter occurs rarely.

Mind you, both are 2D only. 3D has been my thing a long time ago but I like pixel art so I never needed a 3d framework. But depending on my requirements and my past experience, if I needed some low-poly 3d framework for example, that still is not terribly difficult to do. StackOverflow is your best friend and even the math you won't even need to learn or write yourself as their are tons of libraries out there for you. Especially for c++. I started using it not that long ago but jeez, the amount of single header libraries out there is impressive.

Collapse
 
cybeartron profile image
Cybear Tron

Wow... Never thought that Opengl will be better !

Collapse
 
lostancient profile image
Lostybtw

:)