Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Std. Includes
- #include <iostream>
- #include <map>
- #include <string>
- // GLAD
- #include <glad/glad.h>
- // GLFW
- #include <GLFW/glfw3.h>
- // GLM
- #include <glm/glm.hpp>
- #include <glm/gtc/matrix_transform.hpp>
- #include <glm/gtc/type_ptr.hpp>
- // Font
- #include "font.h"
- // Properties
- const GLuint WIDTH = 800, HEIGHT = 600;
- // The MAIN function, from here we start our application and run the Game loop
- int main()
- {
- // Init GLFW
- glfwInit();
- glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
- glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
- glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
- //glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
- GLFWwindow* window = glfwCreateWindow(WIDTH, HEIGHT, "Font Packer", nullptr, nullptr); // Windowed
- glfwMakeContextCurrent(window);
- if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
- {
- std::cout << "Failed to initialize GLAD" << std::endl;
- return -1;
- }
- // Define the viewport dimensions
- glViewport(0, 0, WIDTH, HEIGHT);
- // Set OpenGL options
- glEnable(GL_CULL_FACE);
- glEnable(GL_BLEND);
- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
- Shader shader("shaders/font.vert", "shaders/font.frag");
- Font arial("fonts/arial.ttf", 96);
- //std::cout << "Po font" << glGetError() << std::endl;
- glm::mat4 projection = glm::ortho(0.0f, (float)WIDTH, 0.0f, (float)HEIGHT);
- shader.use();
- shader.setMat4("projection", projection);
- shader.setVec3("textColor", glm::vec3(1.0f));
- shader.setInt("text", 0);
- //glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
- // Game loop
- //std::cout << "Przed petla: " << glGetError() << std::endl;
- while (!glfwWindowShouldClose(window))
- {
- // Check and call events
- glfwPollEvents();
- // Clear the colorbuffer
- glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
- glClear(GL_COLOR_BUFFER_BIT);
- arial.renderBitmap(shader);
- arial.renderText(shader, "qwertyuiopasdfghjklzxcmcvnQWERTYUIOPPASSDSALADJJHKMXZ,NBXC/.';[']31", 25.0, 25.0, 1.0, glm::vec3(1.0f, 1.0f, 1.0f));
- // Swap the buffers
- glfwSwapBuffers(window);
- }
- glfwTerminate();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement