void MainLoop(CPlatform * const pPlatform) { static float degrees[] = {0,0}; CMatrix44 rot; Transform transform(10); //update the main application pPlatform->Tick(); WRender::ClearScreenBuffer(COLOR_BIT | DEPTH_BIT); //not really needed transform.Push(); program.SetMtx44(mt,transform.GetCurrentMatrix().data); WRender::Draw(WRender::TRIANGLE_STRIP, WRender::U_BYTE, sizeof(indices)/sizeof(unsigned char), 0); transform.Translate(0.2f,0.0,0.0); program.SetMtx44(mt,transform.GetCurrentMatrix().data); WRender::Draw(WRender::TRIANGLE_STRIP, WRender::U_BYTE, sizeof(indices)/sizeof(unsigned char), 0); transform.Push(); transform.Translate(-0.4f,0.0,0.0); rot.Identity(); rot.Rotate(degrees[0],0,0,1); transform.ApplyTransform(rot); program.SetMtx44(mt,transform.GetCurrentMatrix().data); WRender::Draw(WRender::TRIANGLE_STRIP, WRender::U_BYTE, sizeof(indices)/sizeof(unsigned char), 0); transform.Push(); transform.Translate(0.0,0.3f,0); program.SetMtx44(mt,transform.GetCurrentMatrix().data); WRender::Draw(WRender::TRIANGLE_STRIP, WRender::U_BYTE, sizeof(indices)/sizeof(unsigned char), 0); transform.Pop(); transform.Pop(); transform.Push(); rot.Identity(); rot.Rotate(degrees[1],0,0,1); transform.ApplyTransform(rot); transform.Translate(0.0,-0.3f,0.0); transform.ApplyTransform(rot); program.SetMtx44(mt,transform.GetCurrentMatrix().data); WRender::Draw(WRender::TRIANGLE_STRIP, WRender::U_BYTE, sizeof(indices)/sizeof(unsigned char), 0); transform.Pop(); transform.Pop(); //swap buffers pPlatform->UpdateBuffers(); degrees[0] -= 360.0f*pPlatform->GetDT(); degrees[1] += 180.0f*pPlatform->GetDT(); if(degrees[0] < 0.0f) degrees[0] += 360.0f; if(degrees[1] > 360.0f) degrees[1] -= 360.0f; }
void DrawGeometry(bool shadowPass) { CMatrix44 rot; rot.Rotate(45,1,0,0); transform.Push(); if(shadowPass == false) shadow_transform.Push(); transforms.mvp = transforms.proj * transform.GetCurrentMatrix(); WRender::UpdateBuffer(WRender::UNIFORM, WRender::DYNAMIC, ubo, sizeof(Transforms), (void*)&transforms, 0); if(shadowPass == false) program.SetMtx44(uShadowMtx, shadow_transform.GetCurrentMatrix().data); //Plane WRender::BindVertexArrayObject(vaoPlane); WRender::DrawArray(WRender::TRIANGLES, 4*3, 0); transform.Pop(); if(shadowPass == false) shadow_transform.Pop(); transform.Push(); if(shadowPass == false) shadow_transform.Push(); transform.ApplyTransform(rot); transform.Translate(0, 5.0f, 0); if(shadowPass == false) { shadow_transform.ApplyTransform(rot); shadow_transform.Translate(0, 5.0f, 0); } transforms.mvp = transforms.proj * transform.GetCurrentMatrix(); WRender::UpdateBuffer(WRender::UNIFORM, WRender::DYNAMIC, ubo, sizeof(Transforms), (void*)&transforms, 0); if(shadowPass == false) program.SetMtx44(uShadowMtx, shadow_transform.GetCurrentMatrix().data); //Torus WRender::BindVertexArrayObject(vaoTorus); WRender::DrawArray(WRender::TRIANGLES, nTorusVertices, 0); transform.Pop(); if(shadowPass == false) shadow_transform.Pop(); }