代码拉取完成,页面将自动刷新
#include "DrawCall.h"
#include "Material.h"
#include "GL20/VBO.h"
#include "GL20/IBO.h"
#include "Light.h"
DrawCall::DrawCall()
:mMaterial(nullptr), mIBO(nullptr), mVBO(nullptr){
}
void DrawCall::Draw(Camera* camera) {
switch (mCatalog){
case kRenderCatalogForward:
ForwardRendering(camera);
break;
case kRenderCatalogDefferedGPass:
DefferedGPass(camera);
break;
case kRenderCatalogDefferedLightPass:
DefferedLightPass(camera);
break;
}
}
void DrawCall::ForwardRendering(Camera* camera) {
mVBO->Bind();
//set main light
//material base bind
//vbo->draw
static float main_light_pos[] = { -1.0f, 1.0f, 0.0f, 0.0f };
mMaterial->mBaseRenderPass->SetVec4("U_LightPosition", main_light_pos);
mMaterial->mBaseRenderPass->SetVec4("U_LightColor", Light::mMainLight->mDiffuse);
mMaterial->mBaseRenderPass->Bind(camera);
//lightmap->bind
//ambient,emissive
//shadow map
//Light::mMainLight->Bind
if (mIBO == nullptr) {
glDrawArrays(GL_TRIANGLES, 0, mVBO->mVertexCount);
}
//for light in lights
// set light state
// material->add->bind(Camera)
// vbo->draw
for (auto iter = Light::mLights.begin(); iter != Light::mLights.end(); ++iter) {
static float add_light_pos[] = { 1.0f, 1.0f, 0.0f, 0.0f };
mMaterial->mAdditiveRenderPass->SetVec4("U_LightPosition", add_light_pos);
mMaterial->mAdditiveRenderPass->SetVec4("U_LightColor", (*iter)->mDiffuse);
mMaterial->mAdditiveRenderPass->Bind(camera);
//light->bind
if (mIBO == nullptr) {
glDrawArrays(GL_TRIANGLES, 0, mVBO->mVertexCount);
}
}
//->deffered
mVBO->Unbind();
if (mNext != nullptr) {
Next<DrawCall>()->Draw(camera);
}
}
void DrawCall::DefferedGPass(Camera* camera) {
mVBO->Bind();
mMaterial->mBaseRenderPass->Bind(camera);
if (mIBO == nullptr) {
glDrawArrays(GL_TRIANGLES, 0, mVBO->mVertexCount);
}
mVBO->Unbind();
if (mNext != nullptr) {
Next<DrawCall>()->Draw(camera);
}
}
void DrawCall::DefferedLightPass(Camera* camera) {
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。