Ramaraunt1

OpenStellar Engine

May 4th, 2017
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. --------------------------------------------
  2. ENGINE.CPP
  3. --------------------------------------------
  4.  
  5. #include <iostream>
  6.  
  7. #include <GLFW/glfw3.h>
  8. #include <thread>
  9. #include "Engine.h"
  10.  
  11. Engine::Engine(int vm, int vn, GLuint prof, GLuint forcom, GLuint res, int width, int height, char* title, GLFWmonitor* fullscreen)
  12. {
  13.  
  14. //variable assigning
  15. std::cout << "Starting OpenStellar Engine! Please wait while it initializes! (it shouldn't take long!)" << std::endl;
  16. major = vm;
  17. minor = vn;
  18. profile = prof;
  19. forwardCompat = forcom;
  20. resizable = res;
  21. screenWidth = width;
  22. screenHeight = height;
  23. screenTitleBarText = title;
  24. screenFullscreen = fullscreen;
  25.  
  26. if (!GLFWinitialize())
  27. {
  28. std::cout << "ERROR::GLFW - GLFW failed to initialize!" << std::endl;
  29. }
  30. window = glfwCreateWindow(screenWidth, screenHeight, screenTitleBarText, screenFullscreen, nullptr);
  31. if (window == nullptr)
  32. {
  33. std::cout << "ERROR::GLFW - GLFW failed window creation!" << std::endl;
  34. }
  35.  
  36.  
  37. }
  38.  
  39. bool Engine::GLFWinitialize()
  40. {
  41. if (!glfwInit())
  42. {
  43. return false;
  44. }
  45. glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, major);
  46. glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, minor);
  47. glfwWindowHint(GLFW_OPENGL_PROFILE, profile);
  48. glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, forwardCompat);
  49. glfwWindowHint(GLFW_RESIZABLE, resizable);
  50. return true;
  51. }
  52.  
  53. void Engine::GameLoop()
  54. {
  55. while (!glfwWindowShouldClose(window))
  56. {
  57. glfwSwapBuffers(window);
  58. glfwPollEvents();
  59. }
  60. }
  61.  
  62. --------------------------------------------
  63. ENGINE.H
  64. --------------------------------------------
  65. #pragma once
  66. #include <iostream>
  67.  
  68. #include <GLFW/glfw3.h>
  69.  
  70. class Engine
  71. {
  72. public:
  73. Engine(int vm, int vn, GLuint pro, GLuint forcom, GLuint res, int widht, int height, char* title, GLFWmonitor* fullscreen);
  74. void GameLoop();
  75. private:
  76. int major;
  77. int minor;
  78. bool running;
  79. GLuint profile;
  80. GLuint forwardCompat;
  81. GLuint resizable;
  82. int screenWidth;
  83. int screenHeight;
  84. char* screenTitleBarText;
  85. GLFWmonitor* screenFullscreen;
  86. GLFWwindow* window;
  87. bool GLFWinitialize();
  88. protected:
  89.  
  90. };
  91. --------------------------------------------
  92. MAIN.CPP
  93. --------------------------------------------
  94. #include <iostream>
  95.  
  96. #include <GLFW/glfw3.h>
  97. #include <thread>
  98. #include "Engine.h"
  99.  
  100. int main()
  101. {
  102. Engine engine = Engine::Engine(3, 2, GLFW_OPENGL_CORE_PROFILE, GL_TRUE, GL_FALSE, 800, 600, "OpenGL Test", nullptr);
  103. engine.GameLoop();
  104. return EXIT_SUCCESS;
  105. }
Advertisement
Add Comment
Please, Sign In to add comment