• 大小: 24.74M
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-06-14
  • 语言: 其他
  • 标签: 其他  

资源简介

9-6trirotate.rar

资源截图

代码片段和文件信息

#define _CRT_SECURE_NO_WARNINGS
#define BMP_Header_Length 54  //图像数据在内存块中的偏移量
#include 
#include 
#include 
#include 
#include “MatrixUtils.h“

GLuint texGround1 texGround2;
GLfloat mixValue = 0.3f; // 纹理混合参数
GLfloat angle = 0.0f;
void renderScene(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
float vertices[] = {
// 所需要的所有顶点集合
 -0.5f -0.5f 0.0f 1.0f 0.0f 0.0f0.0f 0.0f  // 0
0.5f  -0.5f 0.0f 0.0f 1.0f 0.0f1.0f 0.0f  // 1
0.5f  0.5f  0.0f 0.0f 0.0f 1.0f1.0f 1.0f  // 2
-0.5f 0.5f  0.0f 1.0f 1.0f 0.0f0.0f 1.0f   // 3
};
// 索引数据 需要的点的组合
unsigned int indices[] = {
0 1 2  // 第一个三角
0 2 3   // 第二个三角
};

// VBO对象将顶点从内存接受并在显存中管理
unsigned int VBO VAO EBO;
glGenVertexArrays(1 &VAO); // 生成顶点数组对象VAO
glGenBuffers(1 &VBO);  //  根据int类型的VBO这个ID生成一个VBO对象
glGenBuffers(1 &EBO);
// 绑定顶点数组对象VAO
glBindVertexArray(VAO);
// 绑定顶点缓冲对象VBO
glBindBuffer(GL_ARRAY_BUFFER VBO); //  绑定VBO到某个缓冲类型
glBufferData(GL_ARRAY_BUFFER sizeof(vertices) vertices GL_STATIC_DRAW);  // 初始化缓存后将数据拷贝此步骤后 数据被复制到在显存中
// 绑定元素缓冲对象EBO
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER EBO); // 绑定EBO到某个缓冲类型
glBufferData(GL_ELEMENT_ARRAY_BUFFER sizeof(indices) indices GL_STATIC_DRAW);

// 顶点属性指针(位置值几个分量值类型是否标准化步长偏移量)
// 顶点位置属性
glVertexAttribPointer(0 3 GL_FLOAT GL_FALSE
8 * sizeof(GL_FLOAT) (GLvoid*)0);
glEnableVertexAttribArray(0);
// 顶点颜色属性
glVertexAttribPointer(1 3 GL_FLOAT GL_FALSE
8 * sizeof(GL_FLOAT) (GLvoid*)(3 * sizeof(GL_FLOAT)));
glEnableVertexAttribArray(1);
// 顶点纹理坐标
glVertexAttribPointer(2 2 GL_FLOAT GL_FALSE
8 * sizeof(GL_FLOAT) (GLvoid*)(6 * sizeof(GL_FLOAT)));
glEnableVertexAttribArray(2);
//glVertexAttribPointer(0 3 GL_FLOAT GL_FALSE 3 * sizeof(float) (void*)0);
//glEnableVertexAttribArray(0);   // 启动定点属性
// 调用glVertexAttribPointer函数注册VBO为定点属性的绑定VBO之后就可以安全解除绑定.
glBindBuffer(GL_ARRAY_BUFFER 0);
// VAO处于活动状态下啊不要解绑EBO
//glBindBuffer(GL_ELEMENT_ARRAY_BUFFER 0);
// 你可以解绑VAO这样就不能改变VAO(这样的用法很少见)修改其他VAO需要glBindVertexArray所以一般不解绑VAOVBO除非明确需求.
glBindVertexArray(0);
// 填充模式(默认)
glPolygonMode(GL_FRONT_AND_BACK GL_FILL);
// 线框模式(只绘制线)
//glPolygonMode(GL_FRONT_AND_BACK GL_LINE);

// 循环渲染要求退出则为1取反为0循环终止.
// 渲染背景设置清空
glClearColor(0.2f 0.3f 0.3f 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
// 渲染三角形
glBindVertexArray(VAO); //绑定VAO时自动保存EBO的绑定
glDrawElements(GL_TRIANGLES 6 GL_UNSIGNED_INT 0);    //顶点数EBO偏移量.
// 双缓冲后台渲染完后一次性与前台交换力求一次呈现.
// 释放资源
glDeleteVertexArrays(1 &VAO);
glDeleteBuffers(1 &VBO);
glDeleteBuffers(1 &EBO);
// 结束GLFW
glutSwapBuffers();
}

void changeSize(int w int h) {

// Prevent a divide by zero when window is too short
// (you cant make a window of zero width).
if (h == 0)
h = 1;
//printf(“w is %d h is %d“ w h);
//float ratio = 1.0* w / h;

// Reset the coordinate system before mo

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

    ..A..H.     49664  2018-09-11 11:34  9-6trirotate\.vs\9-6trirotate\v15\.suo

     文件   48103424  2018-09-11 11:34  9-6trirotate\.vs\9-6trirotate\v15\Browse.VC.db

     文件   11796480  2018-09-06 17:35  9-6trirotate\.vs\9-6trirotate\v15\ipch\25a67ae791437d38.ipch

     文件   11796480  2018-09-11 09:13  9-6trirotate\.vs\9-6trirotate\v15\ipch\AutoPCH\2adc46de111a5960\MATRIXUTILS.ipch

     文件   34668544  2018-09-11 10:29  9-6trirotate\.vs\9-6trirotate\v15\ipch\AutoPCH\b551f1a5ab37a120\9-6TRIROTATE.ipch

     文件   11468800  2018-09-06 17:35  9-6trirotate\.vs\9-6trirotate\v15\ipch\AutoPCH\dba754898e433ee0\MATRIXUTILS.ipch

     文件        317  2018-09-06 17:03  9-6trirotate\9-6trirotate\1.vert

     文件        320  2018-09-06 11:42  9-6trirotate\9-6trirotate\2.frag

     文件      20404  2018-09-06 17:57  9-6trirotate\9-6trirotate\9-6trirotate.cpp

     文件       9667  2018-09-06 17:35  9-6trirotate\9-6trirotate\9-6trirotate.vcxproj

     文件       1490  2018-09-06 17:35  9-6trirotate\9-6trirotate\9-6trirotate.vcxproj.filters

     文件        165  2018-09-06 13:57  9-6trirotate\9-6trirotate\9-6trirotate.vcxproj.user

     文件       1050  2018-08-31 18:12  9-6trirotate\9-6trirotate\baseTypes.h

     文件        464  2018-09-06 17:57  9-6trirotate\9-6trirotate\Debug\9-6trirotate.log

     文件      45232  2018-09-06 17:57  9-6trirotate\9-6trirotate\Debug\9-6trirotate.obj

     文件        196  2018-09-06 17:57  9-6trirotate\9-6trirotate\Debug\9-6trirotate.tlog\9-6trirotate.lastbuildstate

     文件       2764  2018-09-06 17:57  9-6trirotate\9-6trirotate\Debug\9-6trirotate.tlog\CL.command.1.tlog

     文件      17458  2018-09-06 17:57  9-6trirotate\9-6trirotate\Debug\9-6trirotate.tlog\CL.read.1.tlog

     文件       1268  2018-09-06 17:57  9-6trirotate\9-6trirotate\Debug\9-6trirotate.tlog\CL.write.1.tlog

     文件       3692  2018-09-06 17:57  9-6trirotate\9-6trirotate\Debug\9-6trirotate.tlog\link.command.1.tlog

     文件       3278  2018-09-06 17:57  9-6trirotate\9-6trirotate\Debug\9-6trirotate.tlog\link.read.1.tlog

     文件        502  2018-09-06 17:57  9-6trirotate\9-6trirotate\Debug\9-6trirotate.tlog\link.write.1.tlog

     文件      29982  2018-09-06 17:35  9-6trirotate\9-6trirotate\Debug\MatrixUtils.obj

     文件     191488  2018-09-06 17:57  9-6trirotate\9-6trirotate\Debug\vc141.idb

     文件     102400  2018-09-06 17:57  9-6trirotate\9-6trirotate\Debug\vc141.pdb

     文件       8321  2018-09-06 16:59  9-6trirotate\9-6trirotate\MatrixUtils.c

     文件       8181  2018-09-06 17:35  9-6trirotate\9-6trirotate\MatrixUtils.cpp

     文件       2628  2018-08-31 18:12  9-6trirotate\9-6trirotate\MatrixUtils.h

     文件        225  2018-09-06 13:59  9-6trirotate\9-6trirotate\packages.config

     文件     151254  2018-08-31 16:45  9-6trirotate\9-6trirotate\test.bmp

............此处省略79个文件信息

评论

共有 条评论