update
This commit is contained in:
		
							parent
							
								
									eaf0a6092a
								
							
						
					
					
						commit
						1b358909cc
					
				@ -1,3 +1,44 @@
 | 
				
			|||||||
int main(){
 | 
					#include <chrono>
 | 
				
			||||||
 | 
					#include <exception>
 | 
				
			||||||
 | 
					#include <fstream>
 | 
				
			||||||
 | 
					#include<glad/glad.h>
 | 
				
			||||||
 | 
					#include<GLFW/glfw3.h>
 | 
				
			||||||
 | 
					#include <iostream>
 | 
				
			||||||
 | 
					#include <stdexcept>
 | 
				
			||||||
 | 
					#include <thread>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int main(){
 | 
				
			||||||
 | 
					    // 初始化GLFW
 | 
				
			||||||
 | 
					    if(glfwInit()==0){
 | 
				
			||||||
 | 
					        throw std::runtime_error("failed to init GLFW");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    GLFWwindow *window = glfwCreateWindow(640,480,"Example",nullptr,nullptr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if(window==nullptr){
 | 
				
			||||||
 | 
					        glfwTerminate();
 | 
				
			||||||
 | 
					        throw std::runtime_error("GLFW failed to create window");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    glfwMakeContextCurrent(window);//创建上下文
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if(gladLoadGL()==0){  //加载GL函数
 | 
				
			||||||
 | 
					        glfwTerminate();
 | 
				
			||||||
 | 
					        throw std::runtime_error("GLAD Load GL functions failed");
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    std::cout<<"OpenGL version:"<<glGetString(GL_VERSION)<<"\n";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    while(glfwWindowShouldClose(window)==false){
 | 
				
			||||||
 | 
					        std::this_thread::sleep_for(std::chrono::milliseconds(1000/60));
 | 
				
			||||||
 | 
					        glfwSwapBuffers(window);
 | 
				
			||||||
 | 
					        glfwPollEvents();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#ifdef _MSC_VER 
 | 
				
			||||||
 | 
					#include<Windows.h>
 | 
				
			||||||
 | 
					int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
 | 
				
			||||||
 | 
					    main();
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
							
								
								
									
										12
									
								
								xmake.lua
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								xmake.lua
									
									
									
									
									
								
							@ -1,5 +1,17 @@
 | 
				
			|||||||
add_rules("mode.release","mode.debug")
 | 
					add_rules("mode.release","mode.debug")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					set_languages("c++23")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if is_mode("release")then 
 | 
				
			||||||
 | 
					    if is_plat("mingw")then 
 | 
				
			||||||
 | 
					        add_ldflags("-mwindows")
 | 
				
			||||||
 | 
					    end
 | 
				
			||||||
 | 
					    if is_plat("windows")then 
 | 
				
			||||||
 | 
					        add_ldflags("/SUBSYSTEM:WINDOWS")
 | 
				
			||||||
 | 
					    end 
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
add_requires("glfw","glad","glm")
 | 
					add_requires("glfw","glad","glm")
 | 
				
			||||||
add_packages("glfw","glad","glm")
 | 
					add_packages("glfw","glad","glm")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user