Копия проекта с 01
This commit is contained in:
parent
dd3c1d7b02
commit
6de9e29b3c
17
.vscode/c_cpp_properties.json
vendored
Normal file
17
.vscode/c_cpp_properties.json
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "some_name",
|
||||
"includePath": [
|
||||
"${workspaceFolder}/include",
|
||||
"${workspaceFolder}/../dependencies/GLFW/include",
|
||||
"${workspaceFolder}/../dependencies/glad/include"
|
||||
],
|
||||
"compilerPath": "C:/MinGW/bin/g++.exe",
|
||||
"cStandard": "c11",
|
||||
"cppStandard": "c++11",
|
||||
"intelliSenseMode": "gcc-x86"
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
}
|
73
.vscode/tasks.json
vendored
Normal file
73
.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
{
|
||||
"tasks": [
|
||||
{
|
||||
"type": "cppbuild",
|
||||
"label": "C/C++: g++.exe сборка активного файла",
|
||||
"command": "C:/MinGW/bin/g++.exe",
|
||||
"args": [
|
||||
"-fdiagnostics-color=always",
|
||||
"${workspaceRoot}/src/*.cpp",
|
||||
"${workspaceRoot}/../dependencies/glad/src/glad.c",
|
||||
|
||||
"-I${workspaceRoot}/include",
|
||||
|
||||
"--std=c++11",
|
||||
|
||||
"-I${workspaceRoot}/../dependencies/GLFW/include",
|
||||
"-L${workspaceRoot}/../dependencies/GLFW/lib-mingw",
|
||||
"-I${workspaceFolder}/../dependencies/glad/include",
|
||||
"-static",
|
||||
"-lopengl32",
|
||||
"-lglfw3dll",
|
||||
"-o",
|
||||
"${workspaceRoot}/${workspaceFolderBasename}.exe"
|
||||
],
|
||||
"options": {
|
||||
"cwd": "${fileDirname}"
|
||||
},
|
||||
"problemMatcher": [
|
||||
"$gcc"
|
||||
],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
},
|
||||
"detail": "Задача создана отладчиком."
|
||||
},
|
||||
{
|
||||
"type": "cppbuild",
|
||||
"label": "C/C++ x64: g++.exe сборка активного файла",
|
||||
"command": "C:/MinGW64/bin/g++.exe",
|
||||
"args": [
|
||||
"-fdiagnostics-color=always",
|
||||
"${workspaceRoot}/src/*.cpp",
|
||||
"${workspaceRoot}/../dependencies/glad/src/glad.c",
|
||||
|
||||
"-I${workspaceRoot}/include",
|
||||
|
||||
"--std=c++11",
|
||||
|
||||
"-I${workspaceRoot}/../dependencies/GLFW/include",
|
||||
"-L${workspaceRoot}/../dependencies/GLFW/lib-mingw-w64",
|
||||
"-I${workspaceFolder}/../dependencies/glad/include",
|
||||
"-static",
|
||||
"-lopengl32",
|
||||
"-lglfw3dll",
|
||||
"-o",
|
||||
"${workspaceRoot}/${workspaceFolderBasename}.exe"
|
||||
],
|
||||
"options": {
|
||||
"cwd": "${fileDirname}"
|
||||
},
|
||||
"problemMatcher": [
|
||||
"$gcc"
|
||||
],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
},
|
||||
"detail": "Задача создана отладчиком."
|
||||
}
|
||||
],
|
||||
"version": "2.0.0"
|
||||
}
|
76
src/main.cpp
Normal file
76
src/main.cpp
Normal file
@ -0,0 +1,76 @@
|
||||
#include <glad/glad.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#define WINDOW_WIDTH 800
|
||||
#define WINDOW_HEIGHT 600
|
||||
#define WINDOW_CAPTION "OPENGL notes on rekovalev.site"
|
||||
|
||||
// Функция-callback для изменения размеров буфера кадра в случае изменения размеров поверхности окна
|
||||
void framebuffer_size_callback(GLFWwindow* window, int width, int height)
|
||||
{
|
||||
glViewport(0, 0, width, height);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
GLFWwindow* window; // Указатель на окно GLFW3
|
||||
|
||||
// Инициализация GLFW3
|
||||
if (!glfwInit())
|
||||
{
|
||||
std::cout << "GLFW init error\n";
|
||||
return -1;
|
||||
}
|
||||
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); // Мажорная версия спецификаций OpenGL
|
||||
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 6); // Минорная версия спецификаций OpenGL
|
||||
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); // Контекст OpenGL, который поддерживает только основные функции
|
||||
|
||||
// Создание окна GLFW3 с заданными шириной, высотой и заголовком окна
|
||||
window = glfwCreateWindow(WINDOW_WIDTH, WINDOW_HEIGHT, WINDOW_CAPTION, NULL, NULL);
|
||||
if (!window)
|
||||
{
|
||||
std::cout << "GLFW create window error\n";
|
||||
glfwTerminate(); // Завершение работы с GLFW3 в случае ошибки
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Установка основного контекста окна
|
||||
glfwMakeContextCurrent(window);
|
||||
// Установка callback-функции для изменения размеров окна и буфера кадра
|
||||
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
|
||||
|
||||
glfwSwapInterval(1); // Вертикальная синхронизация
|
||||
|
||||
// Загрузка функций OpenGL с помощью GLAD
|
||||
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress))
|
||||
{
|
||||
std::cout << "GLAD load GL error\n";
|
||||
glfwTerminate(); // Завершение работы с GLFW3 в случае ошибки
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Установка цвета очистки буфера цвета
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||
// Пока не произойдет событие запроса закрытия окна
|
||||
while(!glfwWindowShouldClose(window))
|
||||
{
|
||||
// Очистка буфера цвета
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
|
||||
// Тут производится рендер
|
||||
// ...
|
||||
|
||||
// Представление содержимого буфера цепочки показа на окно
|
||||
glfwSwapBuffers(window);
|
||||
// Обработка системных событий
|
||||
glfwPollEvents();
|
||||
}
|
||||
|
||||
// Завершение работы с GLFW3 перед выходом
|
||||
glfwTerminate();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user