void runMainLoop(int val) { double currentTime = glutGet(GLUT_ELAPSED_TIME); nbFrames++; if (currentTime - lastTime >= 1000.0) { // If last prinf() was more than 1 sec ago // printf and reset timer fps = nbFrames * 1000.0 / (currentTime - lastTime); lastTime = currentTime; nbFrames = 0; std::stringstream c; c << "Collision Test FPS: " << fps; glutSetWindowTitle(c.str().c_str()); } //Frame logic if (mode) { update(); render(); } else { update2D(); render2D(); } //Run frame one more time glutTimerFunc(1000 / SCREEN_FPS, runMainLoop, val); }
//POST FX bool FX_FlashBlanc(Vec2f size, float speed, Color color, float fps, float currfps) { if(FlashAlpha < 0.f) return false; if(FlashAlpha == 0.f) FlashAlpha = 1.f; UseRenderState state(render2D().blendAdditive()); GRenderer->ResetTexture(0); ColorRGBA col = (color * FlashAlpha).toRGB(); TexturedVertex v[4]; v[0].p = Vec3f(0.f, 0.f, 0.01f); v[0].w = 1.f; v[0].color = col; v[1].p = Vec3f(size.x - 1.f, 0.f, 0.01f); v[1].w = 1.f; v[1].color = col; v[2].p = Vec3f(0.f, size.y - 1.f, 0.01f); v[2].w = 1.f; v[2].color = col; v[3].p = Vec3f(size.x - 1.f, size.y - 1.f, 0.01f); v[3].w = 1.f; v[3].color = col; FlashAlpha -= speed * fps / currfps; EERIEDRAWPRIM(Renderer::TriangleStrip, v, 4); return true; }
void PrecastSpellsGui::draw() { UseRenderState state(render2D().blendAdditive()); std::vector<PrecastSpellIconSlot>::iterator itr; for(itr = m_icons.begin(); itr != m_icons.end(); ++itr) { itr->draw(); } }
void DrawImproveVisionInterface() { if(ombrignon) { float mod = 0.6f + PULSATE * 0.35f; Color3f color = Color3f((0.5f + PULSATE * 0.1f) * mod, 0.f, 0.f); UseRenderState state(render2D().blendAdditive()); EERIEDrawBitmap(Rectf(g_size), 0.0001f, ombrignon, color.to<u8>()); } }
void DrawImproveVisionInterface() { if(ombrignon) { float mod = 0.6f + PULSATE * 0.35f; UseRenderState state(render2D().blendAdditive()); EERIEDrawBitmap(Rectf(g_size), 0.0001f, ombrignon, Color::red * ((0.5f + PULSATE * 0.1f) * mod)); } }
void HitStrengthGauge::draw() { { UseRenderState state(render2D().blendAdditive()); EERIEDrawBitmap(m_rect, 0.0001f, m_fullTex, Color3f::gray(m_intensity).to<u8>()); } EERIEDrawBitmap(m_rect, 0.0001f, m_emptyTex, Color::white); if(m_flashActive && player.m_skillFull.etheralLink >= 40) { float j = 1.0f - m_flashIntensity; Color col = (j < 0.5f) ? Color3f(j * 2.f, 1.f, 0.f).to<u8>() : Color3f(1.f, m_flashIntensity, 0.f).to<u8>(); UseRenderState state(render2D().blendAdditive()); EERIEDrawBitmap(m_hitRect, 0.0001f, m_hitTex, col); } }
void MecanismIcon::draw() { if(m_nbToDraw >= 3) { return; } UseRenderState state(render2D().blendAdditive()); EERIEDrawBitmap(m_rect, 0.01f, m_tex, m_color); }
void cCore::render(cApplication* application) { { PROFILE(_T("render 3D")); render3D(application); } { PROFILE(_T("render 2D")); render2D(application); } renderProfile(); present(); }
void ScreenArrows::draw() { if(!config.input.borderTurning) { return; } UseRenderState state(render2D().blendAdditive()); Color lcolor = Color3f::gray(.5f).to<u8>(); EERIEDrawBitmap(m_left, 0.01f, m_arrowLeftTex, lcolor); EERIEDrawBitmapUVs(m_right, .01f, m_arrowLeftTex, lcolor, Vec2f(1.f, 0.f), Vec2f(0.f, 0.f), Vec2f(1.f, 1.f), Vec2f(0.f, 1.f)); EERIEDrawBitmapUVs(m_top, .01f, m_arrowLeftTex, lcolor, Vec2f(0.f, 1.f), Vec2f(0.f, 0.f), Vec2f(1.f, 1.f), Vec2f(1.f, 0.f)); EERIEDrawBitmapUVs(m_bottom, .01f, m_arrowLeftTex, lcolor, Vec2f(1.f, 1.f), Vec2f(1.f, 0.f), Vec2f(0.f, 1.f), Vec2f(0.f, 0.f)); }
void CheckMr() { if(cur_mr == 3) { if(GRenderer && Mr_tc) { Vec2f pos = Vec2f(g_size.topRight()) + Vec2f(-128.f * g_sizeRatio.x, 0.f); Vec2f size = Vec2f(128.f, 128.f) * g_sizeRatio; Rectf rect = Rectf(pos, size.x, size.y); UseRenderState state(render2D().blendAdditive()); EERIEDrawBitmap(rect, 0.0001f, Mr_tc, Color::gray(0.5f + PULSATE * 0.1f)); } else { Mr_tc = TextureContainer::LoadUI("graph/particles/(fx)_mr"); } } }
void CursorTrail::DrawLine2D(float _fSize, Color3f color) { if(iNbOldCoord < 2) { return; } float incSize = _fSize / iNbOldCoord; float currentSize = incSize; Color3f incColor = Color3f(color.r / iNbOldCoord, color.g / iNbOldCoord, color.b / iNbOldCoord); Color3f currentColor = incColor; UseRenderState state(render2D().blend(BlendDstColor, BlendInvDstColor)); GRenderer->ResetTexture(0); TexturedVertex v[4]; v[0].p.z = v[1].p.z = v[2].p.z = v[3].p.z = 0.f; v[0].w = v[1].w = v[2].w = v[3].w = 1.f; v[0].color = v[2].color = currentColor.toRGB(); if(!ComputePer(iOldCoord[0], iOldCoord[1], &v[0], &v[2], currentSize)) { v[0].p.x = v[2].p.x = iOldCoord[0].x; v[0].p.y = v[2].p.y = iOldCoord[1].y; } for(int i = 1; i < iNbOldCoord - 1; i++) { currentSize += incSize; currentColor += incColor; if(ComputePer(iOldCoord[i], iOldCoord[i + 1], &v[1], &v[3], currentSize)) { v[1].color = v[3].color = currentColor.toRGB(); EERIEDRAWPRIM(Renderer::TriangleStrip, v, 4); v[0].p.x = v[1].p.x; v[0].p.y = v[1].p.y; v[0].color = v[1].color; v[2].p.x = v[3].p.x; v[2].p.y = v[3].p.y; v[2].color = v[3].color; } } }
void CheckboxWidget::render(bool mouseOver) { m_label->render(mouseOver); TextureContainer * texture = (m_checked ? m_textureOn : m_textureOff); Color color = m_enabled ? Color::white : Color::gray(0.25f); UseRenderState state(render2D().blendAdditive()); EERIEDrawBitmap(m_button, 0.f, texture, color); if(mouseOver) { EERIEDrawBitmap(m_button, 0.f, texture, color); } }
void MemorizedRunesHud::draw() { if(!(CurrSpellSymbol || player.SpellToMemorize.bSpell)) { return; } Vec2f pos = m_rect.topLeft(); for(int i = 0; i < 6; i++) { bool bHalo = false; if(SpellSymbol[i] != RUNE_NONE) { if(SpellSymbol[i] == player.SpellToMemorize.iSpellSymbols[i]) { bHalo = true; } else { player.SpellToMemorize.iSpellSymbols[i] = SpellSymbol[i]; for(int j = i + 1; j < 6; j++) { player.SpellToMemorize.iSpellSymbols[j] = RUNE_NONE; } } } if(player.SpellToMemorize.iSpellSymbols[i] != RUNE_NONE) { Vec2f size = Vec2f(32.f, 32.f) * m_scale; Rectf rect = Rectf(pos, size.x, size.y); TextureContainer * tc = gui::necklace.pTexTab[player.SpellToMemorize.iSpellSymbols[i]]; if(bHalo) { ARX_INTERFACE_HALO_Render(Color3f(0.2f, 0.4f, 0.8f), HALO_ACTIVE, tc->getHalo(), pos, Vec2f(m_scale)); } EERIEDrawBitmap(rect, 0, tc, Color::white); if(!player.hasRune(player.SpellToMemorize.iSpellSymbols[i])) { UseRenderState state(render2D().blend(BlendInvDstColor, BlendOne).alphaCutout()); EERIEDrawBitmap(rect, 0, cursorMovable, Color3f::gray(.8f).to<u8>()); } pos.x += 32 * m_scale; } } if(g_gameTime.now() - player.SpellToMemorize.lTimeCreation > GameDurationMs(30000)) { player.SpellToMemorize.bSpell = false; } }
static void ARX_INTERFACE_ShowLogo(TextureContainer * logo) { if(logo == NULL) { return; } GRenderer->Clear(Renderer::ColorBuffer); UseRenderState state(render2D().noBlend()); UseTextureState textureState(TextureStage::FilterLinear, TextureStage::WrapClamp); Vec2f size = Vec2f(logo->size()); Vec2f pos = Vec2f(g_size.center()) - size / 2.f; EERIEDrawBitmap(Rectf(pos, size.x, size.y), 0.001f, logo, Color::white); }
void QuickSaveIconGui::draw() { if(m_remainingTime == 0) { return; } UseRenderState state(render2D().blend(BlendSrcColor, BlendOne).alphaCutout()); // Flash the icon twice, starting at about 0.7 opacity float step = 1.f - (m_remainingTime / m_duration); float alpha = std::min(1.f, 0.6f * (std::sin(step * (7.f / 2.f * glm::pi<float>())) + 1.f)); TextureContainer * tex = TextureContainer::LoadUI("graph/interface/icons/menu_main_save"); arx_assert(tex); Vec2f size = Vec2f(tex->size()); EERIEDrawBitmap(Rectf(Vec2f(0, 0), size.x, size.y), 0.f, tex, Color::gray(alpha)); }
void MenuWindow::render() { if(!m_currentPage) { return; } // Draw backgound and border { UseRenderState state(render2D().blend(BlendZero, BlendInvSrcColor)); EERIEDrawBitmap(Rectf(m_pos, RATIO_X(m_background->m_size.x), RATIO_Y(m_background->m_size.y)), 0, m_background, Color::white); } EERIEDrawBitmap(Rectf(m_pos, RATIO_X(m_border->m_size.x), RATIO_Y(m_border->m_size.y)), 0, m_border, Color::white); m_currentPage->render(); if(g_debugInfo == InfoPanelGuiDebug) { m_currentPage->drawDebug(); } }
void CharacterCreation::render() { arx_assert(ARXmenu.mode() == Mode_CharacterCreation); GRenderer->Clear(Renderer::ColorBuffer); //------------------------------------------------------------------------- arx_assert(BookBackground); { UseRenderState state(render2D()); EERIEDrawBitmap(Rectf(Vec2f(0, 0), g_size.width(), g_size.height()), 0.9f, BookBackground, Color::white); g_playerBook.stats.manageNewQuest(); bool DONE = (player.Skill_Redistribute == 0 && player.Attribute_Redistribute == 0); Color color = Color::none; Rectf book = g_playerBook.getArea(); Vec2f spacing = Vec2f(20.f, 30.f) * minSizeRatio(); Vec2f quickGenerateButtonSize(hFontMenu->getTextSize(str_button_quickgen).size()); Rectf quickGenerateButton(book.bottomLeft() + Vec2f(0.f, spacing.y), quickGenerateButtonSize.x, quickGenerateButtonSize.y); Vec2f doneButtonSize(hFontMenu->getTextSize(str_button_done).size()); Rectf doneButton(book.bottomRight() + Vec2f(-doneButtonSize.x, spacing.y), doneButtonSize.x, doneButtonSize.y); Vec2f skinButtonSize(hFontMenu->getTextSize(str_button_skin).size()); Rectf skinButton((quickGenerateButton.centerRight() + doneButton.centerLeft() - skinButtonSize) / 2.f, skinButtonSize.x, skinButtonSize.y); if(quickGenerateButton.right > skinButton.left - spacing.x) { quickGenerateButton.move(skinButton.left - spacing.x - quickGenerateButton.right, 0.f); } if(doneButton.left < skinButton.right + spacing.x) { doneButton.move(skinButton.right + spacing.x - doneButton.left, 0.f); } // Button QUICK GENERATION if(quickGenerateButton.contains(Vec2f(DANAEMouse))) { cursorSetInteraction(); if(!eeMousePressed1() && eeMouseUp1()) { m_cheatQuickGenButtonClickCount++; int iSkin = player.skin; ARX_SOUND_PlayMenu(g_snd.MENU_CLICK); if(bQuickGenFirstClick) { ARX_PLAYER_MakeAverageHero(); bQuickGenFirstClick = false; } else { ARX_PLAYER_QuickGeneration(); } player.skin = checked_range_cast<char>(iSkin); } characterCreationAddDescription(m_desc_quickgen); color = Color::white; } else { color = Color(232, 204, 143); } ARX_UNICODE_DrawTextInRect(hFontMenu, quickGenerateButton.topLeft(), 999999, str_button_quickgen, color); // Button SKIN if(skinButton.contains(Vec2f(DANAEMouse))) { cursorSetInteraction(); if(eeMouseUp1()) { m_cheatSkinButtonClickCount++; ARX_SOUND_PlayMenu(g_snd.MENU_CLICK); player.skin++; if(player.skin > 3) { player.skin = 0; } ARX_PLAYER_Restore_Skin(); } characterCreationAddDescription(m_desc_skin); color = Color::white; } else { color = Color::rgb(0.91f, 0.8f, 0.56f); } ARX_UNICODE_DrawTextInRect(hFontMenu, skinButton.topLeft(), 999999, str_button_skin, color); // Button DONE if(doneButton.contains(Vec2f(DANAEMouse))) { if(DONE) cursorSetInteraction(); if(DONE && eeMouseUp1()) { if(m_cheatSkinButtonClickCount == 8 && m_cheatQuickGenButtonClickCount == 10) { m_cheatSkinButtonClickCount = -2; } else if(m_cheatSkinButtonClickCount == -1) { ARX_PLAYER_MakeSpHero(); player.skin = 4; ARX_PLAYER_Restore_Skin(); m_cheatSkinButtonClickCount = 0; SP_HEAD = 1; } else { if(SP_HEAD) { player.skin = 4; ARX_PLAYER_Restore_Skin(); SP_HEAD = 0; } ARX_SOUND_PlayMenu(g_snd.MENU_CLICK); MenuFader_start(Fade_In, Mode_InGame); } } else { if(DONE) { color = Color::white; } else { color = Color::gray(0.75f); } } characterCreationAddDescription(m_desc_done); } else { if(DONE) { color = Color(232, 204, 143); } else { color = Color::gray(0.75f); } } if(m_cheatSkinButtonClickCount < 0) { color = Color::magenta; } ARX_UNICODE_DrawTextInRect(hFontMenu, doneButton.topLeft(), 999999, str_button_done, color); } EERIE_LIGHT * light = lightHandleGet(torchLightHandle); light->pos.x = 0.f + GInput->getMousePosition().x - (g_size.width() >> 1); light->pos.y = 0.f + GInput->getMousePosition().y - (g_size.height() >> 1); if(pTextManage) { pTextManage->Update(g_platformTime.lastFrameDuration()); pTextManage->Render(); } ARX_INTERFACE_RenderCursor(true); if(MenuFader_process()) { if(iFadeAction == Mode_InGame) { ARX_MENU_NEW_QUEST_Clicked_QUIT(); MenuFader_reset(); if(pTextManage) { pTextManage->Clear(); } } } }
void REV_process(tMapQ3 * map) { //Variables f32 preWait = 0, postWait = 0; static u8 firstFrame = 1; TRACKER * auxT; setUp3D(); //Wait just before drawing (instead of after), this should enhance performance VIDEO_Flush(); preWait = (f32)(ticks_to_millisecs(gettime())); VIDEO_WaitVSync(); postWait = (f32)(ticks_to_millisecs(gettime())); GPUWaitTime = 0.001f * (postWait - preWait); //Update physics updatePhysics(); setBGColor(SC_BLUE); //Clasify objects into solid or transparent queues //This is done before everything else because this clasification is the same for every viewport clasify3D(mainRoot->rootNode); //Now we use the clasified queues to render shadows //if(mainRoot->shadowCaster) //mainRoot->shadowScene(); //Render each Viewport into it's texture GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR); //GX_SetZMode (GX_TRUE, GX_LEQUAL, GX_TRUE); std::multimap<CAMERA*, TRender2Texture*>::iterator iter = mainRoot->m_Render2Textures.begin(); for(;iter != mainRoot->m_Render2Textures.end(); ++iter) { (*iter).second->setForRender(perspective); (*iter).second->getCamera()->setForRender(view); //Before rendering the scene, render the skyBox GX_SetZMode (GX_FALSE, GX_LEQUAL, GX_TRUE); mainRoot->skyBox.render((*iter).second->getCamera()); GX_SetZMode (GX_TRUE, GX_LEQUAL, GX_TRUE); //Now render the map //GX_LoadPosMtxImm(view, GX_PNMTX0); //if(map) //renderQ3Map(tTex->cam->getPos(), map); //Now render objects GX_SetCullMode(GX_CULL_NONE); auxT = solidQueue; while(auxT) { render(auxT->target, (*iter).second->getCamera()->getPos()); auxT = auxT->next; } orderQueue((*iter).second->getCamera()); auxT = transQueue; while(auxT) { render(auxT->target, (*iter).second->getCamera()->getPos()); auxT = auxT->next; } //Copy the embeded frame buffer to the texture (*iter).second->copyTexture(); } while(solidQueue) { auxT = solidQueue; solidQueue = solidQueue->next; free(auxT); } while(transQueue) { auxT = transQueue; transQueue = transQueue->next; free(auxT); } setBGColor(SC_WHITE); //2D System //GX_SetZMode (GX_FALSE, GX_LEQUAL, GX_TRUE); GX_SetCopyFilter(rMode->aa,rMode->sample_pattern,GX_TRUE,rMode->vfilter); GX_SetViewport(0,0, w, h,0,1); GX_SetScissor(0,0, w, h); guOrtho(perspective,0,h,0,w, 1.0,100.0); GX_LoadProjectionMtx(perspective, GX_ORTHOGRAPHIC); GX_SetCullMode(GX_CULL_NONE); setUp2D(); parse2D(mainRoot->rootN2D); order2D(); render2D(); GX_DrawDone(); GX_CopyDisp(frameBuffer[fb],GX_TRUE); VIDEO_SetNextFramebuffer(frameBuffer[fb]); //Set out black screen after first frame if(firstFrame) { firstFrame = 0; VIDEO_SetBlack(FALSE); } fb ^= 1; }
void MainMenuDoFrame() { UseRenderState state(render2D()); UseTextureState textureState(TextureStage::FilterLinear, TextureStage::WrapClamp); if(!g_mainMenu || g_mainMenu->bReInitAll) { MENUSTATE page = Page_None; float scroll = 0.f; if(g_mainMenu) { page = g_mainMenu->requestedPage(); if(g_mainMenu->m_window) { scroll = g_mainMenu->m_window->scroll(); } delete g_mainMenu, g_mainMenu = NULL; } g_mainMenu = new MainMenu(); g_mainMenu->init(); g_mainMenu->requestPage(page); if(page != Page_None) { g_mainMenu->initWindowPages(); g_mainMenu->m_window->setScroll(scroll); } } if(pMenuCursor == NULL) { pMenuCursor = new MenuCursor(); } pMenuCursor->update(); g_mainMenu->update(); g_mainMenu->render(); pMenuCursor->DrawCursor(); g_thumbnailCursor.render(); if(MenuFader_process()) { switch(iFadeAction) { case Mode_Credits: ARX_MENU_Clicked_CREDITS(); MenuFader_start(Fade_Out, -1); break; case Mode_CharacterCreation: ARX_MENU_Clicked_NEWQUEST(); MenuFader_start(Fade_Out, -1); cinematicBorder.reset(); break; case Mode_InGame: mainApp->quit(); MenuFader_start(Fade_Out, -1); break; default: break; } } }