MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / Draw

Method Draw

Source/Objects/reflectioncaptureobject.cpp:63–109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61}
62
63void ReflectionCaptureObject::Draw() {
64 if (g_debug_runtime_disable_reflection_capture_object_draw) {
65 return;
66 }
67
68 if (scenegraph_->map_editor->IsTypeEnabled(_reflection_capture_object) &&
69 cube_map_ref.valid() &&
70 !Graphics::Instance()->media_mode() &&
71 scenegraph_->map_editor->state_ != MapEditor::kInGame &&
72 ActiveCameras::Instance()->Get()->GetFlags() == Camera::kEditorCamera) {
73 PROFILER_GPU_ZONE(g_profiler_ctx, "ReflectionCaptureObject::Draw");
74
75 Shaders* shaders = Shaders::Instance();
76 Graphics* graphics = Graphics::Instance();
77
78 GLState gl_state;
79 gl_state.blend = false;
80 gl_state.cull_face = true;
81 gl_state.depth_test = true;
82 gl_state.depth_write = true;
83
84 graphics->setGLState(gl_state);
85
86 int shader_id = shaders->returnProgram("reflectioncapture");
87 shaders->setProgram(shader_id);
88
89 Camera* camera = ActiveCameras::Get();
90 shaders->SetUniformVec3("cam_pos", camera->GetPos());
91 shaders->SetUniformMat4("model_mat", GetTransform());
92 shaders->SetUniformMat4("view_mat", camera->GetViewMatrix());
93 shaders->SetUniformMat4("proj_mat", camera->GetProjMatrix());
94
95 Textures::Instance()->bindTexture(cube_map_ref);
96
97 int vert_attrib_id = shaders->returnShaderAttrib("vertex", shader_id);
98 Model* probe_model = &Models::Instance()->GetModel(scenegraph_->light_probe_collection.probe_model_id);
99 if (!probe_model->vbo_loaded) {
100 probe_model->createVBO();
101 }
102 probe_model->VBO_vertices.Bind();
103 probe_model->VBO_faces.Bind();
104 graphics->EnableVertexAttribArray(vert_attrib_id);
105 glVertexAttribPointer(vert_attrib_id, 3, GL_FLOAT, false, 3 * sizeof(GL_FLOAT), 0);
106 graphics->DrawElements(GL_TRIANGLES, (unsigned int)probe_model->faces.size(), GL_UNSIGNED_INT, 0);
107 graphics->ResetVertexAttribArrays();
108 }
109}
110
111ReflectionCaptureObject::~ReflectionCaptureObject() {
112}

Callers

nothing calls this directly

Calls 15

media_modeMethod · 0.80
setGLStateMethod · 0.80
returnProgramMethod · 0.80
setProgramMethod · 0.80
SetUniformMat4Method · 0.80
GetViewMatrixMethod · 0.80
GetProjMatrixMethod · 0.80
bindTextureMethod · 0.80
returnShaderAttribMethod · 0.80
createVBOMethod · 0.80

Tested by

no test coverage detected