Skip to content
Snippets Groups Projects
main.cpp 1.12 KiB
Newer Older
Geo Ster's avatar
Geo Ster committed
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <common/manager.hpp>
Geo Ster's avatar
Geo Ster committed

int main()
{
    glfwInit();
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 6);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

    GLFWwindow* window = glfwCreateWindow(800, 600, "PS2 Emulator", NULL, NULL);
Geo Ster's avatar
Geo Ster committed
    if (window == NULL)
    {
        glfwTerminate();
        return -1;
    }

    glfwMakeContextCurrent(window);
    glfwSetFramebufferSizeCallback(window, [](GLFWwindow* window, int width, int height)
	{
		glViewport(0, 0, width, height);
	});

    if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
        return -1;

    ComponentManager manager;
Geo Ster's avatar
Geo Ster committed

    while (!glfwWindowShouldClose(window))
    {
		if(glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
        	glfwSetWindowShouldClose(window, true);
        
        /* Update all the components (CPU, GPU, DMA) */
Geo Ster's avatar
Geo Ster committed
        manager.tick();
Geo Ster's avatar
Geo Ster committed
        glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
        glClear(GL_COLOR_BUFFER_BIT);

        glfwSwapBuffers(window);
        glfwPollEvents();
    }

    glfwTerminate();
    return 0;
}