opengl
MagiChos
这个作者很懒,什么都没留下…
展开
-
画椭球
#include <GL/glut.h>/************************************************************************//* 初始化材料属性、光源属性、光照模型、打开深度缓冲区 *//*****原创 2016-02-23 17:40:52 · 1727 阅读 · 0 评论 -
单击屏幕坐标获取三维坐标
在利用opengl显示点云时,有时需要通过单击鼠标获取屏幕点的三维坐标,其实这是一个矩阵的逆变换过程,opengl的glut库已经有相关的函数为我们为我们完成了复杂的矩阵计算,我们只需要调用就行。template <class PointType>bool Pick(const int & x, const int &y, PointType &pp){ GLdouble res[3];原创 2017-06-01 20:55:15 · 3897 阅读 · 1 评论 -
使用VAO VBO绘制图形
//使用VAO VBO绘制图形#include <GL/glew.h> #include <GL/freeglut.h> void userInit(); //自定义初始化void reshape(int w, int h); //重绘void display(void);void keyboardAction(unsigned char key, int x, int y);原创 2017-06-06 00:59:40 · 742 阅读 · 0 评论 -
混合数组
void glInterleavedArrays(GLenum format,GLsizei stride,const GLvoid *pointer); glInterleavedArrays,可以设置混合数组。这个函数会自动调用glVertexPointer, glColorPointer等函数,并且自动的开启或禁用相关的数组。 函数的第一个参数表示了混合数组的类型。例如GL_C3F_V3原创 2017-04-15 21:59:14 · 1230 阅读 · 0 评论 -
opengl顶点数组
当我们开始学习opengl的时候,一般都是采用glBegin()和glEnd()对之间进行绘图,下面给一段代码。 GLfloat v[6] = { -1.0 , -0.58 , 1.0 , -0.58 , 0.0 , 1.15 }; glClear(GL_COLOR_BUFFER_BIT); glColor3f(0.0, 0.0, 1.0); glViewport(0原创 2017-04-15 10:14:45 · 591 阅读 · 0 评论 -
opengl丢弃缓存数据相关函数
如果要抛弃缓存对象中的部分或者全部数据,那么我们可以调用glInvalidateBufferData()或者glInvalidateBufferSubData()函数。这两个函数的原型如下: void glInvalidateBufferData(GLuint buffer) void glInvalidateBufferSubData(GLuint buffer , GLint offset原创 2017-04-13 20:41:32 · 758 阅读 · 0 评论 -
opengl图形拾取示例
#include <iostream>#include <GL/glut.h>#include <stdlib.h>#include<math.h>using namespace std;int SCREEN_WIDTH = 400; //屏幕尺寸int SCREEN_HEIGHT = 400;int posx1 = 150;int posy1 = 200;int posx2 = 2原创 2017-04-11 23:55:21 · 3095 阅读 · 2 评论 -
opengl glu鼠标操作
单击鼠标左键画点。#include <iostream>#include <GL/glut.h>GLsizei winWidth = 400;GLsizei winHeight = 300;void init(){ glClearColor(0.0, 0.0, 1.0, 1.0); glMatrixMode(GL_PROJECTION); gluOrtho2D(0.0,原创 2017-03-30 10:32:23 · 540 阅读 · 0 评论 -
透视透视示例
#include <iostream>#include <GL/glut.h>using namespace std;GLint winWidth = 600;GLint winHeight = 600;GLfloat eyex = 50, eyey = 50.0, eyez = 50.0;//参考坐标系原点在世界坐标系下的坐标GLfloat xref = 100.0, yref = 50原创 2017-03-29 20:37:08 · 599 阅读 · 3 评论 -
OpenGL中的FBO对象(含源码)
概要在OpenGL的渲染管线中,几何数据和纹理通过一系列变换和测试,最终被渲染成屏幕上的二维像素。那些用于存储颜色值和测试结果的二维数组的几何被称为帧缓冲区(frame buffer)。这些二维数组按用途划分,可分为颜色缓冲区(color buffer),深度缓冲区(depth buffer),模版缓冲区(stencil buffer)和累加缓冲区(accumulation buffer)。当我们创转载 2016-06-05 15:29:18 · 632 阅读 · 0 评论 -
GLFW库
在进行opengl开发时常用到glut辅助库,但是glut库版本又太老,而且并不免费,于是就有了freeglut作为替代,看到网上说freeglut存在很多bug(目前来说我还没有遇到),于是就又有了GLFW作为替代,下面就是用一个简单的例子演示GLFW的用法。#include <GL/freeglut.h>#include <GLFW/glfw3.h>int main(void){ G原创 2017-06-06 09:46:55 · 1345 阅读 · 2 评论