OpenGL
ロ畏蓅ㄧ氓
这个作者很懒,什么都没留下…
展开
-
从零开始的openGL--cs游戏(17) Tweener
Tweener类似于unity中的doTweener比如我想达下面的效果 auto x = [this](float p) { Log("当前时间" + to_string(p)); }; Tween::DoTween<float>(0.0f, 2.0f, 2.0f, x); auto y = [this](glm::vec3 p) { Log("当前x值" + to_string(p.x) + "---当前y值" + to_string(p.y) + "---当前原创 2021-12-28 19:06:31 · 1933 阅读 · 0 评论 -
从零开始的openGL--cs游戏(16) 定时器。
在游戏中定时器十分常见,主要有定时一段时间循环执行,延迟执行等等。比如我要实现这样的功能,延迟2秒执行a,在每隔1秒执行b,持续10次。 auto a = [this]() { int k = 0; Log(to_string(Width) + "----------" + to_string(Height)); this->Log("延迟2秒后"); auto b = [&k ,this]() { this->Log("延迟1秒输出" + to_s原创 2021-12-28 13:57:58 · 2234 阅读 · 0 评论 -
从零开始的openGL--cs游戏(15) Volume阴影。
Volume阴影我认为是做cs游戏的最难的一个点,但了解实现原理后其实不难。 目前完成的实现效果 shadow volume原理不过让我不理解的是,计算shadow volume三角面的扩展顶点使得cpu计算时间增加了10倍,就图中两个模型加载一共耗时将近1分钟。应该有更优化的方法。而且加了Volume阴影我的天空盒无法显示,这个问题有待解决。关键点一:扩展三角面顶点,一般三角面是3原创 2021-12-24 17:30:24 · 2041 阅读 · 0 评论 -
从零开始的openGL--cs游戏
github地址,项目开源CsGame原创 2021-12-17 16:19:43 · 1244 阅读 · 0 评论 -
从零开始的openGL--cs游戏(14) 延迟渲染G缓冲。
window类中定义G缓冲#ifndef Window_H#define Window_H#include <glad/glad.h>#include <GLFW/glfw3.h>#include <iostream>using namespace std;class Scene;class Time;class Input;class Shader;enum class Key;void Resize(GLFWwindow* window, .原创 2021-12-17 16:09:27 · 1429 阅读 · 0 评论 -
从零开始的openGL--cs游戏(13) 完成cs游戏的第一阶段,完成模型载入和动画,下一步做成阴影
B站上的视频记录一下 自己做的OpenGL游戏,第一阶段完成原创 2021-12-16 18:07:58 · 1143 阅读 · 0 评论 -
从零开始的openGL--cs游戏(12)Mesh和ModelComponent
mesh类#ifndef Mesh_H#define Mesh_H#include"Component.h"#include <glm/glm.hpp>#include <glm/gtc/matrix_transform.hpp>#include <string>#include <vector>#include <map>#include "Texture.h"#include "Shader.h"#define MAX_B原创 2021-12-15 18:52:31 · 467 阅读 · 0 评论 -
从零开始的openGL--cs游戏(11)3种常用shader
纯材质#version 430 corelayout(location = 0) in vec3 aPos;layout(location = 1) in vec2 aTexCoord;layout(std140 , binding = 0) uniform PV{ mat4 projection; mat4 view;};out vec2 TexCoord;uniform mat4 model;void main(){ gl_Position = projection * v原创 2021-12-15 18:49:54 · 288 阅读 · 0 评论 -
从零开始的openGL--cs游戏(10)MoveComponent,主角移动组件
主角也是摄像机的移动类#ifndef MoveComponent_H#define MoveComponent_H#include"Component.h"#include <glm/glm.hpp>#include <glm/gtc/matrix_transform.hpp>class MoveComponent : public Component{public: const float moveSpeed = 10.0f; const float camer原创 2021-12-14 18:11:28 · 301 阅读 · 0 评论 -
从零开始的openGL--cs游戏(9)CubeMeshComponent,一个正方形物体------------第一个页面完成
CubeMeshComponent#ifndef CubeMeshComponent_H#define CubeMeshComponent_H#include"Component.h"#include"Shader.h"class CubeMeshComponent :public Component{public: float length, width, height; unsigned int cubeVAO; unsigned int cubeVBO; float* cubeV原创 2021-12-13 19:50:01 · 131 阅读 · 0 评论 -
从零开始的openGL--cs游戏(8)CameraComponent类。相机组件
相机组件#ifndef CameraComponent_H#define CameraComponent_H#include"Component.h"#include <glm/glm.hpp>#include <glm/gtc/matrix_transform.hpp>class CameraComponent : public Component{public: const float YAW = -90.0f; const float PITCH = 0.0原创 2021-12-13 19:45:39 · 204 阅读 · 0 评论 -
从零开始的openGL--cs游戏(7)Scene类
Scene类似unity中的场景#ifndef Scene_H#define Scene_H#include "Window.h"using namespace std;class Transform;class GameObject;class CameraComponent;class Scene{private: static unsigned int _uboPV; Scene(); static Scene* Init(); friend void Window::In原创 2021-12-13 19:41:25 · 247 阅读 · 0 评论 -
从零开始的openGL--cs游戏(6)Input类
Input类主要解决游戏中的输入#ifndef Input_H#define Input_Henum class Key{ W = 0, A = 1, S = 2, D = 3, Mouse1 = 4, Mouse2 = 5, Space = 6, Shift = 7, R = 8,};class Input{private: bool _keys[9]{ false }; void Check(Key key, bool newValue);public: sta原创 2021-12-13 13:56:52 · 451 阅读 · 0 评论 -
从零开始的openGL--cs游戏(5)EventCenter类事件类
开发游戏必不可少的就是事件,再此用到了boost::function,再看这篇文章前可以了解下boost。#ifndef EventCenter_H#define EventCenter_H#include<map>#include <string>#include <vector>#include <Map>#include <boost/function.hpp>using namespace std;class Multi原创 2021-12-13 13:54:33 · 662 阅读 · 0 评论 -
从零开始的openGL--cs游戏(3)Time类
Time类#ifndef Time_H#define Time_H#include "Window.h"class Time{private: static float _deltaTime; static float _startTime; static float _curTime; friend void Window::SetDeltaTime(float time); friend void Window::SetCurTime(float time); friend v原创 2021-12-10 19:13:05 · 379 阅读 · 0 评论 -
从零开始的openGL--cs游戏(4)GameObject类 ,Component类,Transform类
Time类主要定义和时间相关#ifndef Time_H#define Time_H#include "Window.h"class Time{private: static float _deltaTime; static float _startTime; static float _curTime; friend void Window::SetDeltaTime(float time); friend void Window::SetCurTime(float time);原创 2021-12-10 19:03:05 · 293 阅读 · 0 评论 -
从零开始的openGL--cs游戏(2)Shader类,Texture2D类,ResourceManager类
Shader类,Texture2D类,ResourceManager类都是从learnopengl中复制过来的。主要是这些代码的确写的很好,基本没有修改的必要,我直接复制了。( ̄_, ̄ )Shader类#ifndef SHADER_H#define SHADER_H#include <string>#include <glad/glad.h>#include <glm/glm.hpp>#include <glm/gtc/type_ptr.hpp&g原创 2021-12-09 18:22:48 · 974 阅读 · 0 评论 -
从零开始的openGL--cs游戏(1)Window类
主要采用了Learn-Computer-Graphicsmain类#pragma once#include <iostream>using namespace std;#include "Window.h"int main();#include "main.h"int main(){ Window* window = new Window(800, 600); window->Mainloop(); delete window; return 0;}原创 2021-12-09 12:31:43 · 193 阅读 · 0 评论 -
从零开始的openGL--cs游戏(1)Window类,已经更新
Window类是游戏窗口,相当于main我主要采用了Learn-Computer-Graphics中的窗口类。main类#pragma once#include <iostream>using namespace std;#include "Window.h"int main();-----------------------------------------------------#include "main.h"int main(){ Window* wind原创 2021-12-09 12:27:39 · 368 阅读 · 0 评论 -
从零开始的openGL--cs游戏(0)
再学习了openGL后,自己准备动手写一个CS游戏,之后每两天发布一次文章。基础的代码,主要参考learnOpenGL。主要的插件有glad,glfw,assimp5.0。希望大家追更( ̄_, ̄ )ㄟ( ▔, ▔ )ㄏ。原创 2021-12-08 16:44:05 · 354 阅读 · 0 评论