- 博客(18)
- 收藏
- 关注
原创 C++:带头结点的单链表基本功能实现
#include<iostream>using namespace std;class ListNode{public: int data; ListNode* link; ListNode(); ListNode(int item, ListNode* node); ListNode* nextNode();//return the pointer to the next node void insertAfter(ListNode* p); ListNode* rem.
2022-03-21 21:08:53
2302
原创 日地月(glut+纹理)
#include <GL/glut.h>#include<stdio.h>#include <stdlib.h>static int sunday = 0,year = 0, day = 0, month = 0, moonday = 0;static GLuint texname[3];char sunname[] = "sun.bmp";char earthname[] = "ear.bmp";char moonname[] = "moon.bmp";.
2021-12-09 14:58:15
940
2
原创 OpenGL地球(自转+贴图)
#include <stdio.h>#include<stdlib.h>#include <GL/glut.h>GLuint texture_id1; //纹理idint angle = 0;GLUquadricObj* q = gluNewQuadric();int load_texture(char* file_name, int width, int height, int depth, GLenum colour_type, GLenum fi.
2021-11-25 15:35:08
1588
1
原创 B样条曲线(三次)
#include<vector>#include<stdlib.h>#include<GL/glut.h>using namespace std;class ObjPoint{public: ObjPoint(int xv, int yv) :x(xv), y(yv) {} int x; int y;};vector<ObjPoint> cp;//控制点int cw, ch;//当前窗口的宽高void display(void){.
2021-11-25 15:21:44
724
原创 计算机图形学:旋转风车(二维基本几何变换+鼠标监听)
#include <GL/glut.h>#include <stdlib.h>#include<math.h>static GLfloat spin = 0.0;const double PI = 3.14159265357f;void display(void){ glClear(GL_COLOR_BUFFER_BIT); glPushMatrix(); glRotatef(spin, 0.0, 0.0, 1.0); //红色菱形 glBegin.
2021-11-18 12:11:25
2058
2
原创 计算机图形学:旋转矩形(二维几何变换、键盘监听)
#include<GL/glut.h>#include<stdlib.h>#include<math.h>void init(void){ glClearColor(0.0, 0.0, 1.0, 0.0); glShadeModel(GL_FLAT);}void draw_rec(void){ glBegin(GL_LINE_LOOP); glVertex2f(-50, 50); glVertex2f(-50, -50); glVertex2f.
2021-11-18 09:45:57
372
原创 计算机图形学:二维基本几何变换——对称
#include <GL/glut.h>#include <stdlib.h>#include<math.h>void init(void){ glClearColor(0.0, 0.0, 0.0, 0.0); glShadeModel(GL_FLAT);}void draw_triangle(void){ //绘制一个三角形 glBegin(GL_LINE_LOOP); glVertex2f(0.0, 25.0); glVertex2f(25..
2021-11-17 16:56:31
1189
原创 计图实验:裁剪算法
#include <GL/glut.h>#include <stdlib.h>#define DIST(x1,y1,x2,y2) sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))#include<vector>using namespace std;//class declarationclass ObjPoint{public: ObjPoint(int xv, int yv) :x(xv), y(yv) {} int x.
2021-11-17 16:00:49
303
转载 glfwSwapBuffers(GLFWwindow* window)
glfwSwapBuffers(GLFWwindow *window)SwapBuffers翻译过来是交换缓冲区的意思,既然buffer加了s,也就意味着不止一个buffer,所以这里涉及到了一个双缓冲的概念.因为电脑绘图是一个个像素逐一画的,需要时间,如果单一缓冲,我们可能会看到具体绘画过程,会造成屏幕闪烁等问题,而我们用户不需要具体看到你绘制的过程,所以为了解决这个问题,这里用了双缓冲技术,用两个内存区域来保存数据,分为前缓冲区和后缓冲区,前缓冲区用于展示屏幕上的内容,而后缓冲区就用来绘制,然后
2021-11-13 10:33:50
750
翻译 OpenGL:窗口
#include<glad/glad.h>#include<GLFW/glfw3.h>#include<iostream>void framebuffer_size_callback(GLFWwindow* window, int width, int height);//当用户改变窗口大小的时候,视口也应被调整void processInput(GLFWwindow* window);//settingsconst unsigned int SCR_WI.
2021-11-11 11:46:56
258
原创 计图实验:中点画线算法(任意斜率)
#include<iostream>#include<stdlib.h>#include<GL/glut.h>//函数声明void myDisplay();//将直线展示在画面中void myReshape(GLsizei w,GLsizei h);//设置视口void lineMid(int x1, int y1, int x2, int y2);//绘制直线int main(int argc,char*argv[]){ glutInit(&.
2021-11-07 19:52:56
817
原创 管理3D图形数据
/** 管理3D图形数据:* 想要绘制一个对象,它的顶点数据需要被发送给顶点着色器。* 通常会把顶点数据在C++端放入一个缓冲区,并把这个缓冲区和着色器中声明的顶点属性相关联。* 有些步骤只需要一次,如果是动画场景的话,有些步骤需要每帧一次*//** 缓冲区和顶点属性——————————————————————//* 只做一次的步骤(一般在init()函数中)* 1、创建一个缓冲区* 2、将顶点数据复制到缓冲区* 每帧都要做的步骤(一般在display()函数中)* 1、启用包含.
2021-11-03 11:06:34
182
原创 学习笔记:用来构建矩阵变换的GLSL函数
/** 场景动画:* mian()函数结构支持动画,只需要设计display()函数随时间改变绘制的东西* 场景的每一次绘制叫一帧,调用display()函数的频率叫做帧率* 在程序逻辑中移动的速率可以通过自前一帧到目前经过的时间来控制* (所以将currentTime作为display()函数的参数)*//** 用来构建矩阵变换的GLSL函数:* 存储自己写的3D变换矩阵的GLSL数据类型是mat4* GLSL中用于初始化mat4矩阵的语法以列为单位读入值。*///在GLSL.
2021-11-02 20:29:57
518
原创 学习笔记:管线概览
/** OpenGL图形管线简化概览(只包含主要阶段):** C++应用程序* | ————————* 顶点着色器 顶点处理* | ————————* 曲面细分着色器* | 图元(三角形)处理* 几何着色器* | ————————* 光栅化* | 片段(像素)处理* 片段着色器* ...
2021-11-02 18:50:35
274
原创 学习笔记:着色器
/** 顶点着色器和片段着色器* 点、线、三角形等叫做图元,多数3D图形是由许多三角形图元构成* 顶点的来源:从文件中读取并由C++/OpenGL载入缓冲区、直接在C++文件中硬编码或者直接在GLSL(OpenGL着色语言)代码中* 在加载顶点之前,C++/OpenGL应用必须编译并链接合适的GLSL顶点着色器和片段着色器程序,之后将它们载入管线* C++/OpenGL应用同时也负责通知OpenGL构建三角形:* glDrawArrays(GLenum mode,Glint first,GLs.
2021-10-28 10:12:05
132
原创 学习笔记:OpenGL设置窗口(利用GLFW和GLEW)
#include<GL\glew.h>#include<GLFW\glfw3.h>#include<iostream>//#pragma comment(lib,"glew32.lib")using namespace std;void init(GLFWwindow* window) {}void display(GLFWwindow* window, double currentTime){ glClearColor(1.0, 0.0, 0.0...
2021-10-27 22:01:21
1751
原创 warning LNK4098: 默认库“MSVCRT”与其他库的使用冲突;请使用 /NODEFAULTLIB:library
*#include<GL\glew.h>#include<GLFW\glfw3.h>#include<iostream>using namespace std;void init(GLFWwindow* window) {}void display(GLFWwindow* window, double currentTime){ glClearColor(1.0, 0.0, 0.0, 1.0); glClear(GL_COLOR_BUFFER_BIT);.
2021-10-27 21:12:47
1340
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人