// // 渲染接收阴影 // VOID CRenderQuene::RenderReceiveShadow(const CEntityCamera *pCamera, const CEntityShadow *pShadow, DWORD dwSolution, DWORD dwPassGroup, DWORD dwBeginRenderID, DWORD dwEndRenderID) { ASSERT(pCamera); ASSERT(pShadow); // // 1. 查找场景渲染队列 // SceneRenderQueneMap::iterator itSceneRenderQuene = m_sceneRenderQuenes.find(pCamera); if (itSceneRenderQuene == m_sceneRenderQuenes.end()) return; // // 2. 查找阴影渲染队列 // ShadowRenderQueneMap::iterator itShadowRenderQuene = m_shadowRenderQuenes.find(pShadow); if (itShadowRenderQuene == m_shadowRenderQuenes.end()) return; // // 3. 设置相机 // Renderer()->SetPerspective(pCamera->GetFovy(), pCamera->GetAspect(), pCamera->GetZNear(), pCamera->GetZFar()); Renderer()->SetLookAt(*pCamera->GetPosition(), *pCamera->GetForwardDirection(), *pCamera->GetUpDirection()); // // 4. 渲染 // BOOL bOccludeQuery = itSceneRenderQuene->second.bRenderQuery; BOOL bCastShadow = FALSE; BOOL bReceiveShadow = TRUE; BOOL bTransparence = FALSE; const MATRIX4 *mtxShadowProjection = &itShadowRenderQuene->second.mtxShadowProjection; Render(itShadowRenderQuene->second.receives, dwSolution, dwPassGroup, dwBeginRenderID, dwEndRenderID, bOccludeQuery, bCastShadow, bReceiveShadow, bTransparence, mtxShadowProjection); }
// // 渲染查询 // VOID CRenderQuene::RenderQuery(const CEntityCamera *pCamera) { ASSERT(pCamera); // // 1. 查找场景渲染队列并检查是否已经渲染 // SceneRenderQueneMap::iterator itSceneRenderQuene = m_sceneRenderQuenes.find(pCamera); if (itSceneRenderQuene == m_sceneRenderQuenes.end()) return; if (itSceneRenderQuene->second.bRenderQuery) return; // // 2. 设置相机 // Renderer()->SetPerspective(pCamera->GetFovy(), pCamera->GetAspect(), pCamera->GetZNear(), pCamera->GetZFar()); Renderer()->SetLookAt(*pCamera->GetPosition(), *pCamera->GetForwardDirection(), *pCamera->GetUpDirection()); // // 3. 渲染 // RenderQuery(itSceneRenderQuene->second.materials, itSceneRenderQuene->second.lights); // // 4. 设置已经渲染 // itSceneRenderQuene->second.bRenderQuery = TRUE; }
StageState::StageState(int type) : GState() { this->genreType = type; this->bgImage = new GImage(Renderer(), "./Resource/LogoState.bmp"); int x, y; char temp[256] = { 0, }; for (int i = 0; i < 15; i++) { if (i >= 0 && i <= 7) { Blocks[i] = NILL; if (i >= 0 && i <= 3) { y = 100; x = 200 + ((i % 4) * 200); } if( i>=4 && i<=7) { y = 250; x = 200 + ((i % 4) * 200); } } if (i >= 8 && i <= 11) { y = 500; x = 200 + ((i%4) * 240); } sprintf(temp, "./Resource/StageImg/stageX.bmp"); this->NButtons[i] = new GButton(new GImage(Renderer(), temp), x, y); } }
void GStateManager::Draw() { Renderer()->Clear(); Renderer()->Begin(); //TODO: Scene Draw 처리 if (currentState != NOT_SET_STATE) m_states[currentState]->OnDraw(); Renderer()->End(); Renderer()->Present(); }
void DrawSelectionbox(const glm::vec4& posDim, const GFXColor& color) { glm::vec4 cspos = glm::vec4( posDim.x / float(Renderer().GetWindowWidth() / 2) - 1.0f, 1.0f - posDim.y / float(Renderer().GetWindowHeight() / 2), posDim.z / float(Renderer().GetWindowWidth())*2, posDim.w / float(Renderer().GetWindowHeight())*2); Renderer().DrawSelectionbox(cspos, color); }
void Debug::DrawPoint(GFXVec2 point, GFXColor color, float size) { DebugPoint p; p.position = glm::vec3( point.x / float(Renderer().GetWindowWidth()/2) - 1.0f, 1.0f - point.y / float(Renderer().GetWindowHeight()/2), 0.0); p.size = size; p.color = color; DebugDrawing().AddPoint(p); }
void Debug::DrawRectangle(GFXVec2 position, GFXVec2 dimensions, bool solid, GFXColor color) { DebugRect r; r.color = color; r.position = glm::vec3( position.x / float(Renderer().GetWindowWidth() / 2) - 1.0f, 1.0f - position.y / float(Renderer().GetWindowHeight() / 2), 0.0f); r.dimensions = glm::vec3( dimensions.x / float(Renderer().GetWindowWidth())*2, dimensions.y / float(Renderer().GetWindowHeight())*2, 0.0f); DebugDrawing().AddRect(r, solid); }
// // 渲染遮挡 // VOID CRenderQuene::RenderOcclude(const RenderQuene &occludes) { Renderer()->BeginOcclude(); { for (RenderQuene::const_iterator itEntity = occludes.begin(); itEntity != occludes.end(); ++itEntity) { const CEntityRenderable *pEntity = *itEntity; ASSERT(pEntity); pEntity->RenderOcclude(); } } Renderer()->EndOcclude(); }
void DrawFilledRect(GFXVec2 position, GFXVec2 dimensions, GFXColor color) { FilledRect r; r.color = color; r.position = glm::vec3( position.x / float(Renderer().GetWindowWidth() / 2) - 1.0f, 1.0f - position.y / float(Renderer().GetWindowHeight() / 2), 0.0f); r.dimensions = glm::vec3( dimensions.x / float(Renderer().GetWindowWidth()) * 2, dimensions.y / float(Renderer().GetWindowHeight()) * 2, 0.0f); Renderer().AddFilledRect(r); }
void Debug::DrawCircle(GFXVec2 position, float radius, unsigned int lineWidth, GFXColor color) { DebugRect c; c.position = glm::vec3( (position.x-radius) / float(Renderer().GetWindowWidth() / 2) - 1.0f, 1.0f - (position.y+radius) / float(Renderer().GetWindowHeight() / 2), 0.0f); c.color = color; c.dimensions = glm::vec3( radius * 2 / float(Renderer().GetWindowWidth() / 2), radius * 2 / float(Renderer().GetWindowHeight() / 2), radius); c.lineWidth = (lineWidth == 0) ? -1.0f : (float)lineWidth; DebugDrawing().AddCircle(c); }
void Debug::DrawLine(GFXVec2 p1, GFXVec2 p2, GFXColor color, float thickness) { DebugLine l; l.color = color; l.start = glm::vec3( p1.x / float(Renderer().GetWindowWidth() / 2) - 1.0f, 1.0f - p1.y / float(Renderer().GetWindowHeight() / 2), 0.0); l.end = glm::vec3( p2.x / float(Renderer().GetWindowWidth() / 2) - 1.0f, 1.0f - p2.y / float(Renderer().GetWindowHeight() / 2), 0.0); l.thickness = thickness; DebugDrawing().AddLine(l); }
// // 渲染灯光 // VOID CRenderQuene::RenderLight(const LightQuene &lights, BOOL bOccludeQuery) { Renderer()->BeginLighting(); { for (LightQuene::const_iterator itLight = lights.begin(); itLight != lights.end(); ++itLight) { const CEntityLight *pLight = *itLight; ASSERT(pLight); if (bOccludeQuery == FALSE || Renderer()->QueryResult(pLight->GetQuery())) { pLight->RenderLighting(); } } } Renderer()->EndLighting(); }
Panzerfaust::Panzerfaust() { m_renderer = Renderer(); //debugUnitTest(m_elements); m_internalTime = 0.f; m_isQuitting = m_renderer.m_fatalError; m_console.m_log = ConsoleLog(); //m_world = World(); m_worldCamera = Camera(); m_displayConsole = false; //HACK test values m_console.m_log.appendLine("This is a test of the emergency broadcast system"); m_console.m_log.appendLine("Do not be alarmed or concerned"); m_console.m_log.appendLine("This is only a test"); UnitTestXMLParser(".\\Data\\UnitTest.xml"); unitTestEventSystem(); //g_serverConnection = new Connection("129.119.246.221", "5000"); g_serverConnection = new Connection("127.0.0.1", "8080"); g_localUser = User(); g_localUser.m_unit = Entity(); g_localUser.m_unit.m_color = Color4f(0.2f, 1.0f, 0.2f, 1.f); g_localUser.m_userType = USER_LOCAL; g_localUser.m_unit.m_position = Vector2f(0,0); g_flag.m_color = Color4f(1.f, 1.f, 1.f, 1.f); CommandParser::RegisterCommand("connect", ChangeServer); CommandParser::RegisterCommand("color", ChangeColor); }
bool Game::InitGraphics( const uint16Vec2& windowSize, const uint8 rendererType ) { if( !m_pWindow ) return false; m_pRenderer = shared_ptr< Renderer >( ZN_NEW Renderer() ); return m_pRenderer->Init( rendererType, windowSize, m_pWindow->IsFullscreen(), m_pWindow->GetWindowImpl() ); }
Renderer Window::makeRenderer(RendererState state) { auto renderer = SDL_CreateRenderer(ptr, -1, underlying_value(state)); if (renderer == nullptr) { throw CreateRendererFailure(); } return Renderer(renderer); }
Flag::Flag() { //이미지 초기화 this->img = new GImage(Renderer(), "./Resource/Action_img/Action_FLAG_Body.png"); //좌표 초기화 x = 800; y = 158; }
void Sandbox::View::Initialize( _In_ Sandbox::AppViewPtr view ) { m_bActivated = false; m_bClosed = false; m_bVisible = false; m_renderer = alloc_ref_new Renderer(); m_renderer->Driver(D3D_DRIVER_TYPE_HARDWARE); //m_renderer->Driver(D3D_DRIVER_TYPE_HARDWARE); //m_renderer->Driver(D3D_DRIVER_TYPE_REFERENCE); }
// // 设置粒子总量 // VOID CGfxBillboard::SetParticleQuota(INT quota) { Renderer()->DestroyVAO(&m_vao); Renderer()->DestroyVBO(&m_vbo); Renderer()->DestroyVBO(&m_ibo); if (quota > 0) { INDEX *indices = (INDEX *)SAFE_MALLOC(6 * quota * sizeof(*indices), MEMTYPE_STACK); { for (INT index = 0; index < quota; index++) { indices[6 * index + 0] = 4 * index + 0; indices[6 * index + 1] = 4 * index + 1; indices[6 * index + 2] = 4 * index + 2; indices[6 * index + 3] = 4 * index + 2; indices[6 * index + 4] = 4 * index + 3; indices[6 * index + 5] = 4 * index + 0; } m_vao = Renderer()->CreateVAO(); m_vbo = Renderer()->CreateVBO(GL_ARRAY_BUFFER, 4 * quota * sizeof(VERTEX), NULL, GL_DYNAMIC_DRAW); m_ibo = Renderer()->CreateVBO(GL_ELEMENT_ARRAY_BUFFER, 6 * quota * sizeof(INDEX), indices, GL_STATIC_DRAW); } SAFE_FREE(indices); } }
// // 渲染查询 // VOID CRenderQuene::RenderQuery(const MaterialQuene &materials, const LightQuene &lights) { Renderer()->BeginQuery(); { for (MaterialQuene::const_iterator itRenderQuene = materials.begin(); itRenderQuene != materials.end(); ++itRenderQuene) { for (RenderQuene::const_iterator itEntity = itRenderQuene->second.begin(); itEntity != itRenderQuene->second.end(); ++itEntity) { const CEntityRenderable *pEntity = *itEntity; ASSERT(pEntity); pEntity->RenderQuery(); } } for (LightQuene::const_iterator itEntity = lights.begin(); itEntity != lights.end(); ++itEntity) { const CEntityLight *pEntity = *itEntity; ASSERT(pEntity); pEntity->RenderQuery(); } } Renderer()->EndQuery(); }
void operator () (const Array& array) const { out << "["; std::list<Value>::const_iterator iterator; iterator = array.values.begin(); while (iterator != array.values.end()) { boost::apply_visitor(Renderer(out), *iterator); if (++iterator != array.values.end()) { out << ","; } } out << "]"; }
/// <summary> /// Stop the render timer and abort the rendering process. /// Optionally block until stopping is complete. /// </summary> /// <param name="wait">True to block, else false.</param> void FractoriumEmberControllerBase::StopRenderTimer(bool wait) { if (m_RenderTimer) m_RenderTimer->stop(); if (m_Renderer.get()) m_Renderer->Abort(); if (wait) { while (m_Rendering || RenderTimerRunning() || (Renderer() && (!m_Renderer->Aborted() || m_Renderer->InRender()))) QApplication::processEvents(); } }
void operator () (const Object& object) const { out << "{"; std::map<std::string, Value>::const_iterator iterator; iterator = object.values.begin(); while (iterator != object.values.end()) { out << "\"" << (*iterator).first << "\":"; boost::apply_visitor(Renderer(out), (*iterator).second); if (++iterator != object.values.end()) { out << ","; } } out << "}"; }
void operator()(const Object &object) const { out << "{"; auto iterator = object.values.begin(); while (iterator != object.values.end()) { out << "\"" << (*iterator).first << "\":"; mapbox::util::apply_visitor(Renderer(out), (*iterator).second); if (++iterator != object.values.end()) { out << ","; } } out << "}"; }
void EC_MeshmoonWater::OnParentEntitySet() { if (!framework || framework->IsHeadless()) return; OgreRendererPtr renderer = Renderer(); if (!renderer) { // Try to resolve the renderer now. Might have not been done in ctor if constructed as unparented! OgreRenderingModule* renderingModule = framework->Module<OgreRenderingModule>(); if (!renderingModule) return; renderer_ = renderingModule->Renderer(); if (renderer_.expired()) return; renderer = renderer_.lock(); } if (world_.expired() && ParentScene()) world_ = ParentScene()->GetWorld<OgreWorld>(); connect(renderer.get(), SIGNAL(DeviceCreated()), this, SLOT(RecreateOcean()), Qt::UniqueConnection); connect(renderer.get(), SIGNAL(MainCameraChanged(Entity *)), this, SLOT(OnActiveCameraChanged(Entity *)), Qt::UniqueConnection); connect(framework->Frame(), SIGNAL(Updated(float)), this, SLOT(OnUpdate(float)), Qt::UniqueConnection); OnActiveCameraChanged(renderer->MainCamera()); // Detect sky components if already in scene, otherwise will be detected via ComponentAdded signal EntityList ents = ParentScene()->EntitiesWithComponent(EC_MeshmoonSky::TypeIdStatic()); for (EntityList::iterator iter = ents.begin(); iter != ents.end(); ++iter) { IComponent *comp = (*iter)->Component(EC_MeshmoonSky::TypeIdStatic()).get(); if (comp) OnComponentAdded(0, comp, AttributeChange::LocalOnly); } ents = (windConditionsComp_.expired() ? ParentScene()->EntitiesWithComponent(EC_SkyX::TypeIdStatic()) : EntityList()); for (EntityList::iterator iter = ents.begin(); iter != ents.end(); ++iter) { IComponent *comp = (*iter)->Component(EC_SkyX::TypeIdStatic()).get(); if (comp) OnComponentAdded(0, comp, AttributeChange::LocalOnly); } connect(ParentScene(), SIGNAL(ComponentAdded(Entity*, IComponent*, AttributeChange::Type)), this, SLOT(OnComponentAdded(Entity*, IComponent*, AttributeChange::Type)), Qt::UniqueConnection); connect(ParentScene(), SIGNAL(ComponentRemoved(Entity*, IComponent*, AttributeChange::Type)), this, SLOT(OnComponentRemoved(Entity*, IComponent*, AttributeChange::Type)), Qt::UniqueConnection); CreateOcean(); }
int Game_Init(void *parms) { // this function is where you do all the initialization // for your game renderer = Renderer(); renderer.initialize(main_window_handle, WINDOW_WIDTH, WINDOW_HEIGHT); renderer.createZBuffer(); open_light = 1; // 设置光源 ambient_light.state = LIGHTV1_STATE_ON; ambient_light.attr = LIGHTV1_ATTR_AMBIENT; ambient_light.c_ambient = ColourValue::Gray; ambient_light.c_diffuse = ColourValue::ZERO; directional_light.state = LIGHTV1_STATE_ON; directional_light.attr = LIGHTV1_ATTR_DIRECTIONAL; directional_light.c_ambient = ColourValue::ZERO; directional_light.c_diffuse = ColourValue::Gray; //ColourValue(1.0f, 1.0f, 0.0f); directional_light.dir = Vector4(0, 2, -2, 1); //CreatePlane(g_Obj, Vector4(0, 0, 5, 1)); CreateCube(g_Obj, Vector4(0, 0, 5, 1), "../Texture/struct_rotation1.bmp"); CreateCube(g_Obj_c, Vector4(4, 0, 5, 1)); CreateCube(g_Obj_s, Vector4(-4, 0, 5, 1)); // 设置相机 camera.CameraCreate(CAMERA_TYPE_ELUER, Vector4(0, 0, 0, 1), Vector3::zero, Vector4(0, 0, 0, 1), Vector4(0, 0, 1, 1), 0, 1, 50, 120, WINDOW_WIDTH, WINDOW_HEIGHT); //camera.CameraCreate(CAMERA_TYPE_ELUER, Vector4(0.1f, 3.5f, 4.f, 1.0f), Vector3(40, 0, 0) , Vector4(0, 0, 0, 1), Vector4(0, 0, 1, 1), 0, 5, 50, 90, WINDOW_WIDTH, WINDOW_HEIGHT); //camera.CameraCreate(CAMERA_TYPE_UVN, Vector4(5, 0, 6, 1), Vector3::zero, Vector4(0, 0, 5, 1), Vector4(0, 0, 1, 1), 0, 5, 50, 90, WINDOW_WIDTH, WINDOW_HEIGHT); camera.CameraUpdateMatrix(); camera.BuildProjectMatrix(); camera.BuildScreenMatrix(); // return success return(1); } // end Game_Init
// // 渲染产生阴影 // VOID CRenderQuene::RenderCastShadow(const CEntityShadow *pShadow, DWORD dwSolution, DWORD dwPassGroup, DWORD dwBeginRenderID, DWORD dwEndRenderID) { ASSERT(pShadow); // // 1. 查找阴影渲染队列 // ShadowRenderQueneMap::iterator itShadowRenderQuene = m_shadowRenderQuenes.find(pShadow); if (itShadowRenderQuene == m_shadowRenderQuenes.end()) return; // // 2. 设置相机 // Renderer()->SetOrtho(pShadow->GetLeft(), pShadow->GetRight(), pShadow->GetBottom(), pShadow->GetTop(), pShadow->GetZNear(), pShadow->GetZFar()); Renderer()->SetLookAt(*pShadow->GetPosition(), *pShadow->GetForwardDirection(), *pShadow->GetUpDirection()); MATRIX4 mtxScaleAndBias; MtxSet(&mtxScaleAndBias, 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.0f, 0.0f, 0.0f, 0.5f, 0.0f, 0.5f, 0.5f, 0.5f, 1.0f); MtxMul(&itShadowRenderQuene->second.mtxShadowProjection, &(MATRIX4)Renderer()->GetModelViewProjectionMatrix(), &mtxScaleAndBias); // // 3. 渲染 // 1. 使用Scissor测试确保边缘不被渲染 // 2. 不论什么类型的光源都当作平行光处理, 即使用平行投影 // Renderer()->Enable(GL_SCISSOR_TEST); Renderer()->SetScissor(Renderer()->GetViewportX() + 1, Renderer()->GetViewportY() + 1, Renderer()->GetViewportWidth() - 2, Renderer()->GetViewportHeight() - 2); { BOOL bOccludeQuery = FALSE; BOOL bCastShadow = TRUE; BOOL bReceiveShadow = FALSE; BOOL bTransparence = FALSE; const MATRIX4 *mtxShadowProjection = NULL; Render(itShadowRenderQuene->second.receives, dwSolution, dwPassGroup, dwBeginRenderID, dwEndRenderID, bOccludeQuery, bCastShadow, bReceiveShadow, bTransparence, mtxShadowProjection); } Renderer()->Disable(GL_SCISSOR_TEST); }
void ProjectApplication::CallComponent(std::string id, bool pauseCurrentOne) { Application::CallComponent(id, pauseCurrentOne); if (!_activeComponent) return; if (pauseCurrentOne) { PauseComponent(_activeComponent->Name()); } else { StopComponent(_activeComponent->Name()); } Renderer()->CurrentScene(NULL); ReleaseActiveComponent(); _nextFrameCmpToStart = id; if (id.compare(CMP_TEMPLATE) == 0) { _nextFrameCmpToStart = CMP_TEMPLATE; } }
int main(void){ Dataset ds = Dataset(2); DataIO io = DataIO("test.dat"); io.open_for_writing(ds); ds.initialize_random(Dataset::RandomConfiguration::SOLAR_SYSTEM); number initial_energy = ds.compute_energy(GRAVITATIONAL_CONSTANT); std::cout << "initial energy in system: " << initial_energy << std::endl; Renderer renderer = Renderer(ds); StatLogger<number> energylogger = StatLogger<number>("energy-conservation.dat"); number dt = 153.0; //dt = 0.000001; Integrator::Integrator *integrator = new Integrator::EulerCromer(ds, dt, DISTANCE_SMOOTHING_FACTOR, GRAVITATIONAL_CONSTANT); unsigned long frame = 0; while(true){ if(frame > 100000000) break; integrator->swap(); integrator->step(); if(frame % 16000 == 0){ number3 center_of_mass = ds.compute_center_of_mass(); number energy = ds.compute_energy(GRAVITATIONAL_CONSTANT); //std::cout << "energy drift: initial_energy - energy = " << initial_energy << " - " << energy << " = " << (initial_energy - energy) << std::endl; energylogger.append(energy); //renderer.set_center_of_mass(center_of_mass.x, center_of_mass.y, center_of_mass.z); //renderer.push_tails(); } if(frame % 200000 == 0){ if(renderer.render()) break; io.append(); } frame++; } energylogger.finalize(); renderer.quit(); io.finalize(); }
bool CRenderer::Open(InputStream& s, CString name) { m_fn.Empty(); m_name.Empty(); m_file.Free(); m_renderer.Free(); try { m_file.Attach(DNew SubtitleFile()); m_file->Parse(s); m_renderer.Attach(DNew Renderer()); m_name = name; return true; } catch(Exception& e) { UNREFERENCED_PARAMETER(e); TRACE(_T("%s\n"), e.ToString()); } return false; }
// // 渲染 // VOID CGfxBillboard::Render(INT numParticles) { Renderer()->PushMatrix(); { // // 1. 设置变换矩阵 //7 Renderer()->SetModelWorldMatrix(mtxIdentity); // // 2. 提交缓冲 // Renderer()->BindVBO(GL_ARRAY_BUFFER, m_vbo); Renderer()->BindVBO(GL_ELEMENT_ARRAY_BUFFER, m_ibo); Renderer()->SubmitVertexBuffer(CRenderer::VERTEX_FORMAT_PARTICLE, NULL); // // 3. 渲染 // Renderer()->Render(NULL, 6 * numParticles); } Renderer()->PopMatrix(); }