opengl 矩阵变换

这篇博客介绍了OpenGL中的矩阵变换,包括模型矩阵、视图矩阵和投影矩阵的使用。通过实例展示了如何进行平移、旋转和缩放操作,并将这些变换组合成ModelViewProjection矩阵,用于在shader中更新顶点位置,实现三维图形在屏幕上的正确绘制。
摘要由CSDN通过智能技术生成
opengl 矩阵变换
opengl 坐标系的变换如下图:

我们给我们的图形,设置好顶点坐标后,通过Model Matrix 变换为世界坐标,然后 view Matrix相机坐标,Projection Matrix 屏幕坐标x,y ∈(-1,1)。
矩阵变换的结果是把三维的世界最终裁剪为二维的屏幕,数学的说法就是从一个集合到另一个集合的映射。
#include "glew.h"
#include <glfw3.h>
#include "common/loadShader.h"
#include "glm.hpp"
#include "ext.hpp"

int main(void)
{
	GLFWwindow* window;

	/* Initialize the library */
	if (!glfwInit())
		return -1;

	/* Create a windowed mode window and its OpenGL context */
	window = glfwCreateWindow(480, 320, "Hello World", NULL, NULL);
	if (!window)
	{
		glfwTerminate();
		return -1;
	}

	/* Make the window's context current */
	glfwMakeContextCurrent(window);

	// Needed in core profile
	if( glewInit() != GLEW_OK)
	{
		glfwTerminate();
		return -
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值