资源简介
OpenGL-- Shader 颜色 光照 5 多光源 基础 VS2015
http://blog.csdn.net/yulinxx/article/details/72838217

代码片段和文件信息
//main.cpp
#include
#define GLEW_STATIC
#include
#include
#include “Shader.h“
#include “Camera.h“
#include
#include
#include
#include
#include
#include “Shader.h“
#pragma comment(lib “./SOIL.lib“)
#pragma comment (lib “opengl32.lib“)
#pragma comment (lib “glew32s.lib“)
#pragma comment (lib “glfw3.lib“)
#pragma comment (lib “glfw3dll.lib“)
#pragma comment (lib “glew32mxs.lib“)
void key_callback(GLFWwindow* pWnd int key int scancode int action int mode);
void mouse_callback(GLFWwindow* pWnd double xpos double ypos);
void scroll_callback(GLFWwindow* pWnd double xoffset double yoffset);
void do_movement();
const GLuint WIDTH = 800 HEIGHT = 600;
Camera camera(glm::vec3(0.0f 0.0f 3.0f));
GLfloat lastX = WIDTH / 2.0;
GLfloat lastY = HEIGHT / 2.0;
bool keys[1024];
glm::vec3 lightPos(1.2f 1.0f 2.0f);
GLfloat deltaTime = 0.0f;
GLfloat lastframe = 0.0f;
/////////////////////////////////////////////////////////////////////////
int main()
{
glfwInit();
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR 3);
glfwWindowHint(GLFW_OPENGL_PROFILE GLFW_OPENGL_CORE_PROFILE);
glfwWindowHint(GLFW_RESIZABLE GL_FALSE);
GLFWwindow* pWnd = glfwCreateWindow(WIDTH HEIGHT “MultipleLight“ nullptr nullptr);
glfwMakeContextCurrent(pWnd);
glfwSetKeyCallback(pWnd key_callback);
glfwSetCursorPosCallback(pWnd mouse_callback);
glfwSetScrollCallback(pWnd scroll_callback);
// 鼠标指针隐藏
//glfwSetInputMode(pWnd GLFW_CURSOR GLFW_CURSOR_DISABLED);
glewExperimental = GL_TRUE;
glewInit();
glViewport(0 0 WIDTH HEIGHT);
glEnable(GL_DEPTH_TEST);
// Shader 处理 箱子 以及 灯光
Shader lightingObjShader(“./obj_vertex.vs“ “./obj_fragement.fs“);
Shader lampShader(“./lamp_vertex.vs“ “./lamp_fragement.fs“);
// 点数据
GLfloat vertices[] = { // 位置3 向量3 纹理2
// 背面
-0.5f -0.5f -0.5f 0.0f 0.0f -1.0f 0.0f 0.0f
0.5f -0.5f -0.5f 0.0f 0.0f -1.0f 1.0f 0.0f
0.5f 0.5f -0.5f 0.0f 0.0f -1.0f 1.0f 1.0f
0.5f 0.5f -0.5f 0.0f 0.0f -1.0f 1.0f 1.0f
-0.5f 0.5f -0.5f 0.0f 0.0f -1.0f 0.0f 1.0f
-0.5f -0.5f -0.5f 0.0f 0.0f -1.0f 0.0f 0.0f
// 前面
-0.5f -0.5f 0.5f 0.0f 0.0f 1.0f 0.0f 0.0f
0.5f -0.5f 0.5f 0.0f 0.0f 1.0f 1.0f 0.0f
0.5f 0.5f 0.5f 0.0f 0.0f 1.0f 1.0f 1.0f
0.5f 0.5f 0.5f 0.0f 0.0f 1.0f 1.0f 1.0f
-0.5f 0.5f 0.5f 0.0f 0.0f 1.0f 0.0f 1.0f
-0.5f -0.5f 0.5f 0.0f 0.0f 1.0f 0.0f 0.0f
// 左面
-0.5f 0.5f 0.5f -1.0f 0.0f 0.0f 1.0f 0.0f
-0.5f 0.5f -0.5f -1.0f 0.0f 0.0f 1.0f 1.0f
-0.5f -0.5f -0.5f -1.0f 0.0f 0.0f 0.0f 1.0f
-0.5f -0.5f -0.5f -1.0f 0.0f
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 3951 2016-12-16 17:45 OGLLight\Camera.h
文件 140 2017-03-25 23:26 OGLLight\lamp_fragement.fs
文件 268 2017-03-25 23:22 OGLLight\lamp_vertex.vs
文件 19366 2017-06-01 23:52 OGLLight\main.cpp
文件 3640 2017-06-02 00:02 OGLLight\obj_fragement.fs
文件 683 2017-05-24 23:36 OGLLight\obj_vertex.vs
文件 7535 2017-05-27 01:02 OGLLight\OGLLight.vcxproj
文件 1169 2016-12-16 23:34 OGLLight\OGLLight.vcxproj.filters
文件 3476 2016-12-16 17:50 OGLLight\Shader.h
文件 467893 2016-12-16 09:59 OGLLight\texture.png
文件 3974 2016-12-13 00:08 OGLLight\TextureShader.h
文件 144081 2016-12-16 16:54 OGLLight\texture_specular.png
文件 249209 2017-06-02 00:03 2017-06-02_000342.jpg
文件 1306 2016-12-16 23:33 OGLLight.sln
目录 0 2017-06-02 00:05 OGLLight
----------- --------- ---------- ----- ----
906691 15
- 上一篇:OGLShadow阴影基础
- 下一篇:OpenGL_射线选择初探
相关资源
- OpenGL参考手册
- phong模型(简单光照模型)
- Qt Creator opengl实现四元数鼠标控制轨迹
- OpenGL文档,api大全,可直接查询函数
- opengl轮廓字体源代码
- MFC读三维模型obj文件
- 利用OpenGL写毛笔字算法
- MFC中OpenGL面和体的绘制以及动画效果
- 基于OPENGL的光线跟踪源代码368758
- VC 实现三维旋转(源码)
- 自编用openGL实现3D分形树,分形山
- OpenGL球形贴图自旋程序
- OpenGL导入贴图的Texture类
- 计算机图形学(openGL)代码
- 用OpenGL开发的机械臂运动仿真程序(
- OpenGL-3D坦克模拟
- 将光照射到可极化的深色颗粒上
- OPENGL实现世界上最小的3D游戏
- VS2012OpenGL配置所需要的全部libdllh文件
- 基于OpenGL的仿蝗虫机器人三维动态仿
- 图形学 - OpenGL实现3种三维茶壶显示源
- opengl程序-会跳舞的骷髅
- opengl实现三维网格光顺Laplacian算法
- opengl——爆炸
- OpenGL三维地形建模
- opengl游戏编程徐明亮版(含源码)
- 用OPENGL画的一个简单的直升飞机
- opengl完美天空盒
- 3D绘图程序设计:使用Direct3D 10/9和Ope
- OpenGL绘制可运动自行车源程序.zip
评论
共有 条评论