Repository navigation
Expand file tree
/
Copy pathmain.cpp
More file actions
48 lines (44 loc) · 1.4 KB
/
Copy pathmain.cpp
File metadata and controls
48 lines (44 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <iostream>
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include <ostream>
#include <sal.h>
#include "HelloTriangle.h"
void __callback resizeCallbackFunc(GLFWwindow* window, int width, int height){
glViewport(0,0,width,height);
std::cout<<"new size:" << width<<" " <<height<<std::endl;
}
GLFWwindow* prepare_window(){
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
//glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
GLFWwindow* window = glfwCreateWindow(800,600, "LearnOpenGL", NULL, NULL);
if(window == NULL){
std::cout<<"failed to create window"<<std::endl;
glfwTerminate();
return NULL;
}
glfwMakeContextCurrent(window);
if (!gladLoadGLLoader((GLADloadproc)glfwGetProcAddress)) {
std::cout <<"failed to inti GLAD" <<std::endl;
return NULL;
}
glViewport(0,0,800,600);
glfwSetFramebufferSizeCallback(window, resizeCallbackFunc);
return window;
}
void window_loop(GLFWwindow* window){
while (!glfwWindowShouldClose(window)) {
glfwSwapBuffers(window);
glfwPollEvents();
}
glfwTerminate();
}
int main(int, char**) {
auto window = prepare_window();
if (!window) return 0;
HelloTriangle::DrawTwoTriangles(window);
if(window == nullptr)
}