SHOW:
|
|
- or go back to the newest paste.
| 1 | #include <iostream> | |
| 2 | #define GLEW_STATIC | |
| 3 | #include <GL/glew.h> | |
| 4 | #include <GLFW/glfw3.h> | |
| 5 | #include <gl/wglew.h> | |
| 6 | ||
| 7 | ||
| 8 | #include "freeimage/freeimage.h" | |
| 9 | //#include "opengl_framework.h" | |
| 10 | #include <fstream> | |
| 11 | ||
| 12 | ||
| 13 | #include <vector> | |
| 14 | ||
| 15 | ||
| 16 | using namespace std; | |
| 17 | ||
| 18 | ||
| 19 | ||
| 20 | bool makelog(char *message) | |
| 21 | {
| |
| 22 | ofstream fout("log.txt");
| |
| 23 | fout << message << endl; | |
| 24 | fout.close(); | |
| 25 | return true; | |
| 26 | } | |
| 27 | ||
| 28 | bool writelog(char *message) | |
| 29 | {
| |
| 30 | ofstream fout("log.txt", ios_base::app);
| |
| 31 | fout << message << endl; | |
| 32 | //fout.close(); | |
| 33 | return true; | |
| 34 | } | |
| 35 | ||
| 36 | ||
| 37 | ||
| 38 | ||
| 39 | // *************************************************************************************************************************** | |
| 40 | // *************************************************************************************************************************** | |
| 41 | ||
| 42 | void error_callback(int, const char* description) | |
| 43 | {
| |
| 44 | std::cerr << description << std::endl; | |
| 45 | } | |
| 46 | ||
| 47 | int main(int, char const* []) | |
| 48 | {
| |
| 49 | makelog(">");
| |
| 50 | ||
| 51 | ||
| 52 | std::cerr << "Initializing OpenGL." << std::endl; | |
| 53 | ||
| 54 | writelog("Initializing OpenGL.");
| |
| 55 | ||
| 56 | glfwInit(); | |
| 57 | glfwSetErrorCallback(error_callback); | |
| 58 | ||
| 59 | glfwWindowHint(GLFW_DECORATED, GL_TRUE); | |
| 60 | glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); | |
| 61 | glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); | |
| 62 | glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); | |
| 63 | glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); | |
| 64 | ||
| 65 | auto window = glfwCreateWindow(640, 480, "MaSzyna Client", nullptr, nullptr); | |
| 66 | glfwMakeContextCurrent(window); | |
| 67 | ||
| 68 | glewExperimental = true; | |
| 69 | ||
| 70 | if(GLenum err = glewInit() != GLEW_OK) | |
| 71 | {
| |
| 72 | writelog("glewInit Failed!");
| |
| 73 | std::cerr << glewGetErrorString(err) << std::endl; | |
| 74 | return EXIT_FAILURE; | |
| 75 | } | |
| 76 | ||
| 77 | if (!GLEW_VERSION_3_2) | |
| 78 | {
| |
| 79 | writelog("OpenGL 3.2 not supported!");
| |
| 80 | return false; | |
| 81 | } | |
| 82 | ||
| 83 | // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| 84 | - | if (GLEW_ARB_texture_non_power_of_two == NULL) |
| 84 | + | if (glewIsSupported("GL_ARB_texture_non_power_of_two"))
|
| 85 | {
| |
| 86 | - | writelog("GLEW_ARB_texture_non_power_of_two not supported!");
|
| 86 | + | writelog("GL_ARB_texture_non_power_of_two not supported!");
|
| 87 | } | |
| 88 | else | |
| 89 | {
| |
| 90 | - | writelog("GLEW_ARB_texture_non_power_of_twoy OK");
|
| 90 | + | writelog("GL_ARB_texture_non_power_of_two OK");
|
| 91 | } | |
| 92 | ||
| 93 | ||
| 94 | // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
| 95 | - | if (glMultiDrawIndirect == nullptr) |
| 95 | + | if (glMultiDrawElementsIndirect != nullptr) |
| 96 | {
| |
| 97 | - | writelog("glMultiDrawIndirect not supported!");
|
| 97 | + | writelog("glMultiDrawElementsIndirect not supported!");
|
| 98 | } | |
| 99 | else | |
| 100 | {
| |
| 101 | - | writelog("glMultiDrawIndirect OK");
|
| 101 | + | writelog("glMultiDrawElementsIndirect OK");
|
| 102 | } | |
| 103 | ||
| 104 | writelog("OGLR->Init()");
| |
| 105 | //OGLR->Init(); | |
| 106 | ||
| 107 | writelog("MAIN LOOP");
| |
| 108 | ||
| 109 | while(!glfwWindowShouldClose(window)) | |
| 110 | {
| |
| 111 | glClear(GL_COLOR_BUFFER_BIT); | |
| 112 | ||
| 113 | glfwSwapBuffers(window); | |
| 114 | glfwPollEvents(); | |
| 115 | } | |
| 116 | ||
| 117 | glfwDestroyWindow(window); | |
| 118 | glfwTerminate(); | |
| 119 | ||
| 120 | return EXIT_SUCCESS; | |
| 121 | } |