SHARE
TWEET

Untitled

a guest Jun 18th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Std. Includes
  2. #include <iostream>
  3. #include <map>
  4. #include <string>
  5. // GLAD
  6. #include <glad/glad.h>
  7. // GLFW
  8. #include <GLFW/glfw3.h>
  9. // GLM
  10. #include <glm/glm.hpp>
  11. #include <glm/gtc/matrix_transform.hpp>
  12. #include <glm/gtc/type_ptr.hpp>
  13. // Font
  14. #include "font.h"
  15.  
  16. // Properties
  17. const GLuint WIDTH = 800, HEIGHT = 600;
  18.  
  19. // The MAIN function, from here we start our application and run the Game loop
  20. int main()
  21. {
  22.     // Init GLFW
  23.     glfwInit();
  24.     glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
  25.     glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
  26.     glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
  27.     //glfwWindowHint(GLFW_RESIZABLE, GL_FALSE);
  28.  
  29.     GLFWwindow* window = glfwCreateWindow(WIDTH, HEIGHT, "Font Packer", nullptr, nullptr); // Windowed
  30.     glfwMakeContextCurrent(window);
  31.  
  32.     if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
  33.     {
  34.         std::cout << "Failed to initialize GLAD" << std::endl;
  35.         return -1;
  36.     }
  37.  
  38.     // Define the viewport dimensions
  39.     glViewport(0, 0, WIDTH, HEIGHT);
  40.  
  41.     // Set OpenGL options
  42.     glEnable(GL_CULL_FACE);
  43.     glEnable(GL_BLEND);
  44.     glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  45.  
  46.     Shader shader("shaders/font.vert", "shaders/font.frag");
  47.     Font arial("fonts/arial.ttf", 96);
  48.     //std::cout << "Po font" << glGetError() << std::endl;
  49.     glm::mat4 projection = glm::ortho(0.0f, (float)WIDTH, 0.0f, (float)HEIGHT);
  50.     shader.use();
  51.     shader.setMat4("projection", projection);
  52.     shader.setVec3("textColor", glm::vec3(1.0f));
  53.     shader.setInt("text", 0);
  54.     //glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
  55.     // Game loop
  56.     //std::cout << "Przed petla: " << glGetError() << std::endl;
  57.     while (!glfwWindowShouldClose(window))
  58.     {
  59.         // Check and call events
  60.         glfwPollEvents();
  61.  
  62.         // Clear the colorbuffer
  63.         glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
  64.         glClear(GL_COLOR_BUFFER_BIT);
  65.         arial.renderBitmap(shader);
  66.         arial.renderText(shader, "qwertyuiopasdfghjklzxcmcvnQWERTYUIOPPASSDSALADJJHKMXZ,NBXC/.';[']31", 25.0, 25.0, 1.0, glm::vec3(1.0f, 1.0f, 1.0f));
  67.         // Swap the buffers
  68.         glfwSwapBuffers(window);
  69.     }
  70.     glfwTerminate();
  71.     return 0;
  72. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top