#include "DrawCall.h"#include "Light.h"DrawCall::DrawCall() {mVBO = nullptr;mIBO = nullptr;mMaterial = 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(camera)// vbo->drawstatic 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);//program -> bind//lightmaps -> bind//ambient,emissive//shadow map//Light::mMainLight->Bindif (mIBO == nullptr) {glDrawArrays(GL_TRIANGLES, 0, mVBO->mVertexCount);}//for light in lights// set light state// material->add->bind(camera)// vbo->drawfor (auto iter = Light::mLights.begin(); iter != Light::mLights.end(); ++iter) {//1000static 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);//program -> bind//light -> binidif (mIBO == nullptr) {glDrawArrays(GL_TRIANGLES, 0, mVBO->mVertexCount);}}//300//->defferedmVBO->Unbind();if (mNext != nullptr) {Next<DrawCall>()->Draw(camera);}}void DrawCall::DefferedGPass(Camera* camera) {mVBO->Bind();mMaterial->mBaseRenderPass->Bind(camera);//program -> bindif (mIBO == nullptr) {glDrawArrays(GL_TRIANGLES, 0, mVBO->mVertexCount);}mVBO->Unbind();if (mNext != nullptr) {Next<DrawCall>()->Draw(camera);}}void DrawCall::DefferedLightPass(Camera* camera) {}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。