MCPcopy Create free account
hub / github.com/OneLoneCoder/olcPixelGameEngine / DoGPUTask

Function DoGPUTask

olcPixelGameEngine.h:6337–6409  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6335 }
6336
6337 void DoGPUTask(const olc::GPUTask& task) override
6338 {
6339 SetDecalMode(task.mode);
6340 if (task.decal == nullptr)
6341 glBindTexture(GL_TEXTURE_2D, rendBlankQuad.Decal()->id);
6342 else
6343 glBindTexture(GL_TEXTURE_2D, task.decal->id);
6344
6345 locBindBuffer(0x8892, m_vbQuad);
6346
6347 //for (uint32_t i = 0; i < task.vb.size; i++)
6348 // pVertexMem[i] = { { decal.pos[i].x, decal.pos[i].y, decal.w[i] }, { decal.uv[i].x, decal.uv[i].y }, decal.tint[i] };
6349
6350 // ooooof... f^%ing win!!! B) [planned of course]
6351 locBufferData(0x8892, sizeof(GPUTask::Vertex) * task.vb.size(), task.vb.data(), 0x88E0);
6352
6353 // Use 3D Shader
6354 locUniform1i(m_uniIs3D, 1);
6355
6356 // Use MVP Matrix - yeah, but this needs to happen somewhere
6357 // and at least its per object which makes sense
6358 std::array<float, 16> matMVP;
6359 for (size_t c = 0; c < 4; c++)
6360 for (size_t r = 0; r < 4; r++)
6361 matMVP[c * 4 + r] =
6362 + matProjection[0 * 4 + r] * task.mvp[c * 4 + 0]
6363 + matProjection[1 * 4 + r] * task.mvp[c * 4 + 1]
6364 + matProjection[2 * 4 + r] * task.mvp[c * 4 + 2]
6365 + matProjection[3 * 4 + r] * task.mvp[c * 4 + 3];
6366 locUniformMatrix4fv(m_uniMVP, 1, false, matMVP.data());
6367
6368 float f[4] = { float(task.tint.r) / 255.0f, float(task.tint.g) / 255.0f, float(task.tint.b) / 255.0f, float(task.tint.a) / 255.0f };
6369 locUniform4fv(m_uniTint, 1, f);
6370
6371
6372 if (task.cull == olc::CullMode::NONE)
6373 {
6374 glCullFace(GL_FRONT);
6375 glDisable(GL_CULL_FACE);
6376 }
6377 else if(task.cull == olc::CullMode::CW)
6378 {
6379 glCullFace(GL_FRONT);
6380 glEnable(GL_CULL_FACE);
6381 }
6382 else if (task.cull == olc::CullMode::CCW)
6383 {
6384 glCullFace(GL_BACK);
6385 glEnable(GL_CULL_FACE);
6386 }
6387
6388 if(task.depth)
6389 glEnable(GL_DEPTH_TEST);
6390
6391
6392
6393 if (nDecalMode == DecalMode::WIREFRAME)
6394 glDrawArrays(GL_LINE_LOOP, 0, (GLsizei)task.vb.size());

Callers

nothing calls this directly

Calls 3

SetDecalModeFunction · 0.85
DecalMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected