This commit is contained in:
Zengtudor 2024-09-01 17:45:50 +08:00
parent 1b358909cc
commit 98cf7a3229
2 changed files with 19 additions and 6 deletions

View File

@ -1,12 +1,18 @@
#include <chrono>
#include <exception>
#include <fstream>
#include<glad/glad.h> #include<glad/glad.h>
#include<GLFW/glfw3.h> #include<GLFW/glfw3.h>
#include <chrono>
#include <iostream> #include <iostream>
#include <stdexcept> #include <stdexcept>
#include <thread> #include <thread>
void render(){
glBegin(GL_POINTS);
glVertex3f(0.0f,0.5f,0.0f);
glVertex3f(-0.5,-0.5,0.0f);
glVertex3f(0.5f,-0.5f,0.0f);
glEnd();
}
int main(){ int main(){
// 初始化GLFW // 初始化GLFW
if(glfwInit()==0){ if(glfwInit()==0){
@ -28,10 +34,17 @@ int main(){
std::cout<<"OpenGL version:"<<glGetString(GL_VERSION)<<"\n"; std::cout<<"OpenGL version:"<<glGetString(GL_VERSION)<<"\n";
glClear(GL_COLOR_BUFFER_BIT);
glEnable(GL_POINT_SMOOTH);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glPointSize(64.0f);
while(glfwWindowShouldClose(window)==false){ while(glfwWindowShouldClose(window)==false){
std::this_thread::sleep_for(std::chrono::milliseconds(1000/60)); render();
glfwSwapBuffers(window); glfwSwapBuffers(window);
glfwPollEvents(); glfwPollEvents();
std::this_thread::sleep_for(std::chrono::milliseconds(1000/60));
} }
return 0; return 0;
} }

View File

@ -15,5 +15,5 @@ end
add_requires("glfw","glad","glm") add_requires("glfw","glad","glm")
add_packages("glfw","glad","glm") add_packages("glfw","glad","glm")
target("c1") target("3point")
add_files("src/c1/*.cpp") add_files("src/c1/threePoints.cpp")