diff --git a/src/c1/main.cpp b/src/c1/main.cpp index 294989d..5bdfe4a 100644 --- a/src/c1/main.cpp +++ b/src/c1/main.cpp @@ -1,3 +1,44 @@ +#include +#include +#include +#include +#include +#include +#include +#include + 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"); + } -} \ No newline at end of file + std::cout<<"OpenGL version:"< +int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { + main(); +} +#endif \ No newline at end of file diff --git a/xmake.lua b/xmake.lua index 88e4fa3..6bf6699 100644 --- a/xmake.lua +++ b/xmake.lua @@ -1,5 +1,17 @@ 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_packages("glfw","glad","glm")