Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define GL_SILENCE_DEPRECATION //выключаем предупреждения mac os о open gl
- /*
- #include <openGL/gl.h> // библиотеки на open gl для mac
- #include <GLUT/glut.h>
- #include <GLFW/glfw3.h>
- #define GLEW_STATIC
- #include <GL/glew.h>
- #include <stdio.h>
- */
- #include <iostream>
- #define GLEW_STATIC
- #include <GL/glew.h>
- #include <GLFW/glfw3.h>
- int main(void)
- {
- GLFWwindow* window; //инициализируем библиотеку
- if (!glfwInit())
- return -1;
- window = glfwCreateWindow(640, 480, "Hello World", //создаем окно контекста open gl
- NULL, NULL);
- if (!window) //проверка открылось ли окно
- {
- glfwTerminate();
- return -1;
- }
- glfwMakeContextCurrent(window); //сделать данное контекстное окно главным
- if (glewInit() != GLEW_OK)
- std::cout << "Error" << std::endl;
- std::cout << glGetString(GL_VERSION) <<
- std::endl;
- float positions[6] = {
- -0.5f, -0.5f,
- 0.0f, 0.5f,
- 0.5f, -0.5f
- };
- unsigned int buffer;
- glGenBuffers (1, &buffer);
- glBindBuffer (GL_ARRAY_BUFFER, buffer);
- glBufferData (GL_ARRAY_BUFFER, 6 *
- sizeof(float), positions, GL_STATIC_DRAW);
- glEnableVertexAttribArray(0);
- glVertexAttribPointer(0,2, GL_FLOAT, GL_FALSE,
- sizeof(float) * 2, 0);
- glBindBuffer (GL_ARRAY_BUFFER, 0);
- //unsigned int(a);
- //glGenBuffers(1, &a);
- while (!glfwWindowShouldClose(window)) //цикл пока пользователь не закроет окно
- {
- glClear(GL_COLOR_BUFFER_BIT); //рендер
- glDrawArrays(GL_TRIANGLES, 0, 3); //рисуем трeугольник
- glfwSwapBuffers(window); //меняет передний и задний буферы
- glfwPollEvents();
- }
- glfwTerminate();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement