void ViewWindow::draw () { //bool use_solid = false; // unused if(!valid ()) InitGL (); glClearColor(backgroundColor.x,backgroundColor.y,backgroundColor.z,0.0f); glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity (); SetupProjectionMatrix (); bSelecting=false; selector_count=0; DrawScene (); SetRasterMatrix (); Draw2D (); if (bBoxSelect) { fltk::glsetcolor(fltk::WHITE); fltk::glstrokerect(click.x,click.y,last.x-click.x, last.y-click.y); } }
void EditorViewWindow::SetMode (int m) { mode = m; cam.Reset(); if (m == MAP_3D && cam.ctlmode==Camera::FPS) cam.pos.set(0,0,-10); if (m == MAP_3D && cam.ctlmode==Camera::Rotating) { cam.pitch=-M_PI/6; cam.zoom=20; } if (m != MAP_3D) cam.zoom = 0.1f; SetupProjectionMatrix (); redraw(); }
//************************************ // Method: GenerateDrawSurfaces // FullName: Renderer::GenerateDrawSurfaces // Access: public // Returns: void // Qualifier: // Description: Adds all of the view's objects to the list of draw surfaces. //************************************ void Renderer::GenerateDrawSurfaces() { // Add all of the different types of surfaces necessary // call back to the scene in order to get all of the polys // TODO: Let's just put something in the mean time... int i; poly_t *poly; for (i = 0, poly = refdef->polys; i < refdef->numPolys; i++, poly++) { // Add the poly refdef->AddDrawSurf(reinterpret_cast<surfaceType_t*>(poly)); } // Setup the projection matrix SetupProjectionMatrix(); AddEntitySurfaces(); }
//----------------------------------------------------------------------------- // Renders the world //----------------------------------------------------------------------------- void CRenderManager::RenderWorld() { CMatRenderContextPtr pRenderContext( g_pMaterialSystem ); pRenderContext->MatrixMode( MATERIAL_PROJECTION ); pRenderContext->PushMatrix(); pRenderContext->MatrixMode( MATERIAL_VIEW ); pRenderContext->PushMatrix(); pRenderContext->MatrixMode( MATERIAL_MODEL ); pRenderContext->PushMatrix(); pRenderContext->LoadIdentity(); if ( m_bRenderWorldFullscreen ) { m_nRenderX = m_nRenderY = 0; pRenderContext->GetRenderTargetDimensions( m_nRenderWidth, m_nRenderHeight ); } pRenderContext->DepthRange( 0, 1 ); pRenderContext->Viewport( m_nRenderX, m_nRenderY, m_nRenderWidth, m_nRenderHeight ); SetupProjectionMatrix( m_nRenderWidth, m_nRenderHeight, 90 ); SetupCameraRenderState(); g_pWorldManager->DrawWorld(); pRenderContext->MatrixMode( MATERIAL_PROJECTION ); pRenderContext->PopMatrix(); pRenderContext->MatrixMode( MATERIAL_VIEW ); pRenderContext->PopMatrix(); pRenderContext->MatrixMode( MATERIAL_MODEL ); pRenderContext->PopMatrix(); }
void MyRenderBase::OnPreRender() { m_eye = idVec4( view.m_pos, 1.0f ); SetupViewMatrix( view ); SetupProjectionMatrix( view ); }
void ViewWindow::Select(float sx, float sy, int w, int h, bool box) { int bufsize = 10000; // FIXME: Find some way to calculate this value uint *buffer; int vp[4]; // viewport make_current(); buffer = ALLOCA_ARRAY(uint, bufsize); selector_list = ALLOCA_ARRAY(ViewSelector*, bufsize); glMatrixMode(GL_PROJECTION); glLoadIdentity(); sy = this->h() - sy; glGetIntegerv(GL_VIEWPORT, vp); gluPickMatrix(sx + w / 2, sy - h / 2, w, h, vp); SetupProjectionMatrix(); glSelectBuffer(bufsize, (uint *)buffer); glRenderMode(GL_SELECT); glInitNames(); bSelecting = true; selector_count = 1; glPushName(0); DrawScene(); glPopName(); bSelecting = false; int a, hits; if ((hits = glRenderMode(GL_RENDER)) != 0) { Vector3 pos; if (!box) { pos = FindSelCoords(sx + w / 2, sy + h / 2); logger.Trace(NL_Msg, "SelPos: %d, %d, %d\n", (int) pos.x, (int) pos.y, (int) pos.z); } uint *pBuf = buffer; ViewSelector *best = 0; float bestscore = 0.; bool bRedraw = false; for (a = 0; a < hits; a++) { uint num = pBuf [0]; pBuf += 3; for (uint b=0;b<num;b++) { int sl_index = *(pBuf ++) - 1; // only the top of the name stack if (b < num - 1) continue; if (sl_index >= 0 && sl_index < bufsize) { ViewSelector *sel = selector_list [sl_index]; assert (sel); if (box) { sel->Toggle (pos, !sel->IsSelected ()); bRedraw=true; } else { float score = sel->Score(pos, GetCamDistance (pos)); if (!best || score < bestscore) { best=sel; bestscore=score; } } } } } if (best) { bool bSelect = !best->IsSelected (); best->Toggle (pos, bSelect); bRedraw=true; } if (bRedraw) editor->SelectionUpdated (); } }