void CheckTime() // TimePass: { float A; if(Game.status < 1) { //Game.time--; if(Game.time < 0) { for(int h = 0; h < Game.players; h++) { Death[h].speed += .02; } } if(Game.time == 0) { if(Game.status != -501) { PlaySound(5); srand(time(NULL)); for(int h = 0; h < Game.players; h++) { A = rand() % 6 + (float)rand() / .28; // RND(1) * 6.28 Death[h].x = 160 + (cos(A) * 200); Death[h].y = 100 + (sin(A) * 200); Death[h].frame = rand() % 3; Death[h].speed = .5; } } else { DrawObjects(); SPrint("POTION BONUS", 112, 50, Game.textcol); BlastLine(110, 59, 208, 59, Game.textcol); SPrint("NO BONUS!", 124, 83, Game.textcol); BlastLine(110, 115, 208, 115, Game.textcol); BlitAndWait(200); Game.status = 501; } } if(Game.time == 15) { if(Game.status > -501 && Game.status < 1) { RedrawLevel(); DrawObjects(); PlaySound(4); //DMAplay EMSseg, 0, SoundLen(4), 11025& for(int o = 0; o < 4; o++) { SPrint("HURRY UP!!", 120, 90, Game.textcol); BlitAndWait(24); RedrawLevel(); DrawObjects(); BlitAndWait(24); } //if(Game.status > -1) ChangePal(0); } } } }
void RenderGI() { giRT->Bind(); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_DEPTH_TEST); giShader.Bind(); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, vplRT->Texture()); giShader.SetUniform("vplTexture", (int)1); glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, vplPosRT->Texture()); giShader.SetUniform("vplPosTexture", (int)2); glActiveTexture(GL_TEXTURE3); glBindTexture(GL_TEXTURE_2D, vplNormalRT->Texture()); giShader.SetUniform("vplNormalTexture", (int)3); SetMatrix(giShader); DrawObjects(giShader); giShader.Unbind(); }
void GameMenu::RunGameMenu2(void) { while(FSKEY_NULL!=FsInkey() || 0!=FsInkeyChar()) { FsPollDevice(); } key=FSKEY_NULL; for(;;) { FsPollDevice(); key=FsInkey(); if(key==FSKEY_ESC || key==FSKEY_S || key==FSKEY_M) { return; } glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); Initialize(); DrawBackground(); DrawObjects(); DrawWelcomeText(); DrawLogo(25, 575); FsSwapBuffers(); FsSleep(20); } }
void QuadTree::DrawObjects(QuadTreeNode* node,Frustum* frust){ vec3 testVec(node->position.x,0.0f,node->position.y); if(!frust->CheckRect(testVec,node->size/2.0f)){ node->culled = true; return; } node->culled = false; int count = 0; for(int child = 0; child < 4; child++){ if(node->nodes[child] != 0){ count++; DrawObjects(node->nodes[child],frust); } } if(count!=0) return; if(node->indices){ //get shader Shader* treeShader = m_shaderMan->GetElement(m_treeShader); for(int obj = 0; obj < node->numObjs; obj++){ if(node->objPositions[obj].y < 20.0f) continue; if(frust->CheckRect(node->objPositions[obj],5.0f)){ treeShader->SetUniform("translation",glm::translate(node->objPositions[obj])); m_tree->Render(); } } } }
void RenderScene() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); #if FIX_FUNCTION glLightfv(GL_LIGHT0, GL_POSITION, g_lightPos); #else if (lightPosLocation1 != -1) { //glUniformMatrix4fv(lightPosLocation, 1, GL_FALSE, lightPos); glUniform3fv(lightPosLocation1, 1, g_lightPos); } #endif glMatrixMode(GL_MODELVIEW); glPushMatrix(); gluLookAt(0.0, 0.0, 20.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); glTranslatef(0.0f, 0.0f, -50.0f); float mat[4*4]; ConvertQuaternionToMatrix(g_Rotate, mat); /*float invmat[4*4]; m3dInvertMatrix44(invmat, mat); if (lightPosLocation != -1) { glUniformMatrix4fv(lightPosLocation, 1, GL_FALSE, mat); }*/ glMultMatrixf(mat); DrawGround(); DrawObjects(); glPopMatrix(); TwDraw(); glutSwapBuffers(); glutPostRedisplay(); }
void ProcessSelection(int xPos, int yPos) { static GLuint selectBuff[BUFFER_LENGTH]; GLint hits, viewport[4]; glSelectBuffer(BUFFER_LENGTH, selectBuff); glGetIntegerv(GL_VIEWPORT, viewport); glMatrixMode(GL_PROJECTION); glPushMatrix(); glRenderMode(GL_SELECT); glLoadIdentity(); gluPickMatrix(xPos, viewport[3] - yPos + viewport[1], 2,2, viewport); gluPerspective(60.0f, fAspect, 1.0, 1000.0); DrawObjects(); hits = glRenderMode(GL_RENDER); glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); if(hits == 1) { MakeSelection(selectBuff[3]); if(selectedObject == selectBuff[3]) selectedObject = 0; else selectedObject = selectBuff[3]; } printf("holaaaaa donde estoy en %d , %d\n", xPos, yPos); glutPostRedisplay(); }
void ProcessSelection(int xPos, int yPos) { // Space for selection buffer GLuint selectBuff[BUFFER_LENGTH]; // Hit counter and viewport storeage GLint hits, viewport[4]; // Setup selection buffer glSelectBuffer(BUFFER_LENGTH, selectBuff); // Get the viewport glGetIntegerv(GL_VIEWPORT, viewport); // Switch to projection and save the matrix glMatrixMode(GL_PROJECTION); glPushMatrix(); // Change render mode glRenderMode(GL_SELECT); // Establish new clipping volume to be unit cube around // mouse cursor point (xPos, yPos) and extending two pixels // in the vertical and horzontal direction glLoadIdentity(); gluPickMatrix(xPos, viewport[3] - yPos, 2,2, viewport); // Apply perspective matrix gluPerspective(60.0f, fAspect, 1.0, 425.0); // Draw the scene DrawObjects(); // Collect the hits hits = glRenderMode(GL_RENDER); // Restore the projection matrix glMatrixMode(GL_PROJECTION); glPopMatrix(); // Go back to modelview for normal rendering glMatrixMode(GL_MODELVIEW); // If a single hit occured, display the info. if(hits == 1) { MakeSelection(selectBuff[3]); if(nWho == selectBuff[3]) nWho = 0; else nWho = selectBuff[3]; } glutPostRedisplay(); }
BOOL CNCaptureView::GetImageByRect(const CRect& rcSrc, CImage& Image) { if (m_pImage) { CImageDC dcImage(Image); DrawObjects(m_canvasImage.GetMemoryDC()); BitBlt(dcImage, 0, 0, rcSrc.Width(), rcSrc.Height(), m_canvasImage.GetMemoryDC(), rcSrc.left, rcSrc.top, SRCCOPY); CRect rcImage(0, 0, m_pImage->GetWidth(), m_pImage->GetHeight()); m_pImage->Draw(m_canvasImage, rcImage); return TRUE; } return FALSE; }
void RenderVPLNormal() { vplNormalRT->Bind(); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_DEPTH_TEST); vpl_normalShader.Bind(); SetMatrix(vpl_normalShader); DrawObjects(vpl_normalShader); vpl_normalShader.Unbind(); }
void RenderShadowmap() { lightRT->Bind(); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_DEPTH_TEST); lightShader.Bind(); SetMatrix(lightShader); DrawObjects(lightShader); lightShader.Unbind(); }
void ProcessSelection(int xPos, int yPos) { // 选择缓冲区 static GLuint selectBuff[BUFFER_LENGTH]; GLint hits, viewport[4]; //设置选择缓冲区 glSelectBuffer(BUFFER_LENGTH, selectBuff); glGetIntegerv(GL_VIEWPORT, viewport); //切换到投影矩阵 glMatrixMode(GL_PROJECTION); glPushMatrix(); //进入选择模式 glRenderMode(GL_SELECT); glLoadIdentity(); //在鼠标位置下,创建一个挑选矩阵 gluPickMatrix(xPos, viewport[3] - yPos + viewport[1], 2,2, viewport); gluPerspective(60.0f, fAspect, 1.0, 425.0); //绘制物体 DrawObjects(); //收集点击记录 hits = glRenderMode(GL_RENDER); // glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); // 如果选中了一个物体,处理选择的信息 if(hits == 1) { MakeSelection(selectBuff[3]); if(selectedObject == selectBuff[3]) selectedObject = 0; else selectedObject = selectBuff[3]; } glutPostRedisplay(); }
void RenderVPL() { vplRT->Bind(); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_DEPTH_TEST); vplShader.Bind(); vplShader.SetUniform("uLightIntensity", lightIntensity[0], lightIntensity[1], lightIntensity[2], lightIntensity[3]); SetMatrix(vplShader); DrawObjects(vplShader); vplShader.Unbind(); }
void RenderObject() { cameraRT->Bind(); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_DEPTH_TEST); shader.Bind(); shader.SetUniform("resolution", (float)cameraRT->Size(), (float)cameraRT->Size()); shader.SetUniform("uAmbient", ambient[0], ambient[1], ambient[2], ambient[3]); shader.SetUniform("uLightIntensity", lightIntensity[0], lightIntensity[1], lightIntensity[2], lightIntensity[3]); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, lightRT->Texture()); shader.SetUniform("shadowMap", (int)0); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, giRT->Texture()); shader.SetUniform("giTexture", (int)1); SetMatrix(shader); DrawObjects(shader); shader.Unbind(); // テクスチャ描画 const float aspect = (float)windowWidth / windowHeight; glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, lightRT->Texture()); DrawTexture(0.9f, -0.8f, 0.1f, 0.1f * aspect); glBindTexture(GL_TEXTURE_2D, vplRT->Texture()); DrawTexture(0.6f, -0.8f, 0.1f, 0.1f * aspect); glBindTexture(GL_TEXTURE_2D, vplPosRT->Texture()); DrawTexture(0.3f, -0.8f, 0.1f, 0.1f * aspect); glBindTexture(GL_TEXTURE_2D, vplNormalRT->Texture()); DrawTexture(0.0f, -0.8f, 0.1f, 0.1f * aspect); glBindTexture(GL_TEXTURE_2D, giRT->Texture()); DrawTexture(-0.3f, -0.8f, 0.1f, 0.1f * aspect); }
int main() { ret = init_vga(G320x200x256, VGA, PCI_DEVICE_ID_S3_TRIO64V2); int i; for(i=0;i<64;i++){ vga_setpalette(i, i, i, i); } for(i=0;i<64;i++){ vga_setpalette(i+64, i, 0, 0); } for(i=0;i<64;i++){ vga_setpalette(i+64+64, 0, i, 0); } buffer = (unsigned char *)malloc(VGA_WIDTH*VGA_HEIGHT);//virtual canvas memset(buffer, 0, VGA_WIDTH*VGA_HEIGHT); set_raw_mode(); unsigned int seed = (unsigned) time(NULL); srand(seed); /*srand(seed);rand();*/ float period = 1.0/60.0; //period_ts = double_to_timespec(period); //old versions of MaRTE OS double_to_timespec(period,&period_ts); //new versions of MaRTE OS while(1){ DrawObjects(); //flip vga_drawscansegment(buffer,0,0,VGA_WIDTH*VGA_HEIGHT); nanosleep(&period_ts, NULL); } while(getchar()==-1); return 0; }
void RenderScene(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); DrawObjects(); if(selectedObject != 0) { GLint viewport[4]; glGetIntegerv(GL_VIEWPORT, viewport); glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); glOrtho(viewport[0], viewport[2], viewport[3], viewport[1], -1, 1); glMatrixMode(GL_MODELVIEW); glDisable(GL_LIGHTING); glColor3f(1.0f, 0.0f, 0.0f); glBegin(GL_LINE_LOOP); glVertex2i(boundingRect.left, boundingRect.top); glVertex2i(boundingRect.left, boundingRect.bottom); glVertex2i(boundingRect.right, boundingRect.bottom); glVertex2i(boundingRect.right, boundingRect.top); glEnd(); glEnable(GL_LIGHTING); } glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glutSwapBuffers(); }
// Called to draw scene void RenderScene(void) { // Clear the window with current clearing color glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Draw the objects in the scene DrawObjects(); // If something is selected, draw a bounding box around it if(nWho != 0) { int viewport[4]; // Get the viewport glGetIntegerv(GL_VIEWPORT, viewport); // Remap the viewing volume to match window coordinates (approximately) glMatrixMode(GL_PROJECTION); glPushMatrix(); glLoadIdentity(); // Establish clipping volume (left, right, bottom, top, near, far) glOrtho(viewport[0], viewport[2], viewport[3], viewport[1], -1, 1); glMatrixMode(GL_MODELVIEW); glDisable(GL_LIGHTING); glColor3ub(255,0,0); glBegin(GL_LINE_LOOP); glVertex2i(bRect.left, bRect.top); glVertex2i(bRect.left, bRect.bottom); glVertex2i(bRect.right, bRect.bottom); glVertex2i(bRect.right, bRect.top); glEnd(); glEnable(GL_LIGHTING); } glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); glutSwapBuffers(); }
// 출력 void Draw() { if(!(refresh_object || refresh_message || refresh_status || refresh_time)) { return; } if(refresh_object) { refresh_object = 0; DrawFloor(map_id); DrawObjects(); } if(refresh_message) { refresh_message = 0; DrawMessage(); } if(refresh_status) { refresh_status = 0; DrawStatus(); } if(refresh_time) { refresh_time = 0; DrawTime(); } mvaddch(22, 78, ' '); refresh(); }
void MakeSelection(int nChoice) { //选择缓冲区 static GLfloat feedBackBuff[FEED_BUFF_SIZE]; int size,i,j,count; //初始化边界的最大和最小值 boundingRect.right = boundingRect.bottom = -999999.0f; boundingRect.left = boundingRect.top = 999999.0f; //设置反馈缓冲区 glFeedbackBuffer(FEED_BUFF_SIZE,GL_2D, feedBackBuff); //进入反馈模式 glRenderMode(GL_FEEDBACK); //绘制物体 DrawObjects(); //离开反馈模式 size = glRenderMode(GL_RENDER); //解析反馈的数据,获得被选择物体的最大的和最小的窗口坐标 i = 0; while(i < size) { // 搜索用户自定义的标记 if(feedBackBuff[i] == GL_PASS_THROUGH_TOKEN) //判断标记是否与我们选择的物体名称相同 if(feedBackBuff[i+1] == (GLfloat)nChoice) { i+= 2; while(i < size && feedBackBuff[i] != GL_PASS_THROUGH_TOKEN) { //多边形的标记 if(feedBackBuff[i] == GL_POLYGON_TOKEN) { //获得所有多边形的反馈信息 count = (int)feedBackBuff[++i];//有多少个顶点 i++; for(j = 0; j < count; j++) //遍历每一个顶点 { //取得x的最大最小值 if(feedBackBuff[i] > boundingRect.right) boundingRect.right = feedBackBuff[i]; if(feedBackBuff[i] < boundingRect.left) boundingRect.left = feedBackBuff[i]; i++; //取得y的最大最小值 if(feedBackBuff[i] > boundingRect.bottom) boundingRect.bottom = feedBackBuff[i]; if(feedBackBuff[i] < boundingRect.top) boundingRect.top = feedBackBuff[i]; i++; } } else i++; } break; } i++; } }
//----------------------------------------------------------------------------- // Name : FrameAdvance () (Private) // Desc : Called to signal that we are now rendering the next frame. //----------------------------------------------------------------------------- void CGameApp::FrameAdvance() { static TCHAR FrameRate[ 50 ]; static TCHAR TitleBuffer[ 255 ]; // Advance the timer m_Timer.Tick( 60 ); // Skip if app is inactive if ( !m_bActive ) return; // Get / Display the framerate if ( m_LastFrameRate != m_Timer.GetFrameRate() ) { m_LastFrameRate = m_Timer.GetFrameRate( FrameRate, 50 ); sprintf_s( TitleBuffer, _T("Game : %s"), FrameRate ); SetWindowText( m_hWnd, TitleBuffer ); } // End if Frame Rate Altered if(StartGame == true) { SetCursor( NULL ); // Poll & Process input devices ProcessInput(); // Collision detection between game objects BricksExist=false; CollisionDetection(); if(BricksExist == false) { Vec2 brickPos; brickPos.x = START_BRICK_POS_X; brickPos.y = START_BRICK_POS_Y; countBricks = 0; countGifts = 0; nrBricks = 0; // delete objects from previous level for(auto it = m_vGameObjects.begin(); it != m_vGameObjects.end(); ++it) { CGameObject * pGameObj = it->get(); if(pGameObj->GetObjectTypeSub() == GOT_BrickUnbreakable) { countBricks++; } } for(int cBricks = 0; cBricks <= countBricks; cBricks++) { for(auto it2 = m_vGameObjects.begin(); it2 != m_vGameObjects.end(); ++it2) { CGameObject * pGameObj = it2->get(); if(pGameObj->GetObjectTypeSub() == GOT_BrickUnbreakable) { m_vGameObjects.erase(it2); break; } } } for(auto it = m_vGameObjectsGift.begin(); it != m_vGameObjectsGift.end(); ++it) { CGameObject * pGameObj = it->get(); countGifts++; } for(int cGifts = 0; cGifts <= countGifts; cGifts++) { for(auto it2 = m_vGameObjectsGift.begin(); it2 != m_vGameObjectsGift.end(); ++it2) { CGameObject * pGameObj = it2->get(); m_vGameObjectsGift.erase(it2); break; } } // load new objects m_pBall.lock()->myVelocity.x = 0; m_pBall.lock()->myVelocity.y = 0; m_pBall.lock()->myPosition.x = m_pPlayer.lock()->myPosition.x; m_pBall.lock()->myPosition.y = m_nViewHeight - m_pBall.lock()->GetHeight() - m_pPlayer.lock()->GetHeight() - ONE; FollowPlayer = true; UnstoppableBall = false; StickyBar = false; MoveBall = false; SystemParametersInfo(SPI_SETMOUSESPEED, NULL, (void*)10, SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE ); ballPos.x = 0; if(ShrinkBar == true) { ShrinkBar = false; m_pPlayer.lock()->Normal_Bar(); } nrLevel++; level.LoadBricks(nrLevel); level.RandomBricks("-ud"); string::iterator it; for(it = level.bricks.begin(); it < level.bricks.end(); it++) { if(*it == '-') { continue; } auto pBrick = std::make_shared<Brick>(*it); m_vGameObjects.push_back(pBrick); } for(auto it = m_vGameObjects.begin(); it != m_vGameObjects.end(); ++it) { CGameObject * pGameObj = it->get(); if(pGameObj->GetObjectType() == GOT_Brick) { for(std::size_t levelbricks = 0; levelbricks < level.bricks.size(); levelbricks++) { if(level.bricks[nrBricks] == '-') { brickPos.x += pGameObj->GetWidth(); if(brickPos.x >= m_nViewWidth - GET_MAX_BRICK_POS_X) { brickPos.x = START_BRICK_POS_X; brickPos.y += pGameObj->GetHeight(); } } else { nrBricks++; break; } nrBricks++; } pGameObj->Init(Vec2(brickPos.x, brickPos.y)); brickPos.x += pGameObj->GetWidth(); if(brickPos.x >= m_nViewWidth - GET_MAX_BRICK_POS_X) { brickPos.x = START_BRICK_POS_X; brickPos.y += pGameObj->GetHeight(); } } } if(level.Winner == true) { LevelChange = false; } else { LevelChange = true; } } // Animate the game objects AnimateObjects(); } // Drawing the game objects DrawObjects(); }
void CSm3GroundDrawer::Draw(bool drawWaterReflection,bool drawUnitReflection,unsigned int overrideVP) { if (wireframe) { glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); } terrain::RenderContext *currc = rc; tr->SetShaderParams(mapInfo->light.sunDir, currc->cam->pos); if (shadowHandler->drawShadows) { terrain::ShadowMapParams params; shadowHandler->GetShadowMapSizeFactors (params.f_a, params.f_b); params.mid [0] = shadowHandler->xmid; params.mid [1] = shadowHandler->ymid; params.shadowMap = shadowHandler->shadowTexture; for (int a=0;a<16;a++) params.shadowMatrix[a] = shadowHandler->shadowMatrix[a]; tr->SetShadowParams (¶ms); } tr->SetActiveContext (currc); glEnable(GL_CULL_FACE); glFrontFace(GL_CW); glColor4f(1.0f,1.0f,1.0f,1.0f); glEnable(GL_LIGHTING); glLightfv(GL_LIGHT0, GL_POSITION, mapInfo->light.sunDir); float d[4]={0.0f,0.0f,0.0f,1.0f}; for (int a=0;a<3;a++) d[a]=mapInfo->light.groundSunColor[a]; glLightfv(GL_LIGHT0, GL_DIFFUSE, d); for (int a=0;a<3;a++) d[a]=mapInfo->light.groundAmbientColor[a]; glLightfv(GL_LIGHT0, GL_AMBIENT, d); for (int a=0;a<3;a++) d[a]=mapInfo->light.groundSpecularColor[a]; glLightfv (GL_LIGHT0, GL_SPECULAR, d); for (int a=0;a<4;a++) d[a]=0.0f; glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, d); const float zero[] = { 0.0f, 0.0f, 0.0f, 1.0f }; glLightModelfv (GL_LIGHT_MODEL_AMBIENT, zero); glDisable(GL_LIGHT1); glEnable(GL_LIGHT0); glEnable(GL_RESCALE_NORMAL); // glLightfv (GL_LIGHT0, GL_SPOT_DIRECTION,dir.getf()); // glLightf (GL_LIGHT0, GL_SPOT_CUTOFF, 90.0f); /* const float ambient[] = { 0.4f, 0.4f, 0.4f, 1.0f }; const float diffuse[] = { 1.0f, 1.0f, 1.0f, 1.0f }; glLightfv (GL_LIGHT0, GL_DIFFUSE, diffuse); glLightfv (GL_LIGHT0, GL_AMBIENT, ambient); glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1); const float md[] = { 1.0f, 1.0f, 1.0f, 1.0f }; glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, md); glMaterialfv (GL_FRONT_AND_BACK, GL_SPECULAR, md); glMaterialf (GL_FRONT_AND_BACK, GL_SHININESS, 10.0f);*/ ///////////////////// tr->Draw (); glDisable(GL_LIGHT0); glDisable(GL_LIGHTING); if (wireframe) { glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); } if (drawMode != drawNormal) { glEnable(GL_BLEND); glDepthMask(GL_FALSE); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_POLYGON_OFFSET_FILL); glPolygonOffset(0.0f,- 10.0f); glColor4f(1.0f,1.0f,1.0f,0.5f); tr->DrawOverlayTexture (infoTex); glDisable(GL_POLYGON_OFFSET_FILL); glDepthMask(GL_FALSE); glDisable(GL_BLEND); } glFrontFace(GL_CCW); glDisable(GL_CULL_FACE); glColor3ub(255,255,255); DrawObjects(drawWaterReflection, drawUnitReflection); glActiveTextureARB(GL_TEXTURE0_ARB); glDisable(GL_TEXTURE_2D); }
//--------------------------------------------------------------------------- void __fastcall TFormMain::FormPaint(TObject *Sender) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glFlush(); DrawObjects(); }
static void DrawWindow(void) { struct window *w = CurrentWindow(); static GLfloat light_pos[] = { 0.0, 20.0, 0.0, 1.0 }; GLfloat dist = 20.0; GLfloat eyex, eyey, eyez; if (w->drawBuffer == GL_NONE) { glDrawBuffer(GL_BACK); glReadBuffer(GL_BACK); } else { glDrawBuffer(w->drawBuffer); glReadBuffer(w->drawBuffer); } glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); if (w->drawBuffer == GL_NONE) { glDrawBuffer(GL_NONE); } eyex = dist * cos(w->yrot * DEG2RAD) * cos(w->xrot * DEG2RAD); eyez = dist * sin(w->yrot * DEG2RAD) * cos(w->xrot * DEG2RAD); eyey = dist * sin(w->xrot * DEG2RAD); /* view from top */ glPushMatrix(); gluLookAt( eyex, eyey, eyez, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0 ); glLightfv( GL_LIGHT0, GL_POSITION, light_pos ); /* draw table into stencil planes */ glDisable( GL_DEPTH_TEST ); glEnable( GL_STENCIL_TEST ); glStencilFunc( GL_ALWAYS, 1, 0xffffffff ); glStencilOp( GL_REPLACE, GL_REPLACE, GL_REPLACE ); glColorMask( GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE ); DrawTable(w); glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE ); glEnable( GL_DEPTH_TEST ); /* render view from below (reflected viewport) */ /* only draw where stencil==1 */ if (eyey>0.0) { glPushMatrix(); glStencilFunc( GL_EQUAL, 1, 0xffffffff ); /* draw if ==1 */ glStencilOp( GL_KEEP, GL_KEEP, GL_KEEP ); glScalef( 1.0, -1.0, 1.0 ); /* Reposition light in reflected space. */ glLightfv(GL_LIGHT0, GL_POSITION, light_pos); DrawObjects(w, eyex, eyey, eyez); glPopMatrix(); /* Restore light's original unreflected position. */ glLightfv(GL_LIGHT0, GL_POSITION, light_pos); } glDisable( GL_STENCIL_TEST ); glEnable( GL_BLEND ); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); glEnable( GL_TEXTURE_2D ); DrawTable(w); glDisable( GL_TEXTURE_2D ); glDisable( GL_BLEND ); /* view from top */ glPushMatrix(); DrawObjects(w, eyex, eyey, eyez); glPopMatrix(); glPopMatrix(); if (w->showBuffer == GL_DEPTH) { ShowDepthBuffer(w->width, w->height, 1.0, 0.0); } else if (w->showBuffer == GL_STENCIL) { ShowStencilBuffer(w->width, w->height, 255.0, 0.0); } else if (w->showBuffer == GL_ALPHA) { ShowAlphaBuffer(w->width, w->height); } if (w->drawBuffer == GL_FRONT) glFinish(); else glutSwapBuffers(); /* calc/show frame rate */ { static GLint t0 = 0; static GLint frames = 0; GLint t = glutGet(GLUT_ELAPSED_TIME); frames++; if (t - t0 >= 5000) { GLfloat seconds = (t - t0) / 1000.0; GLfloat fps = frames / seconds; printf("%d frames in %g seconds = %g FPS\n", frames, seconds, fps); fflush(stdout); t0 = t; frames = 0; } } }
void CSM3GroundDrawer::Draw(const DrawPass::e& drawPass) { if (wireframe) { glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); } terrain::RenderContext* currc = rc; tr->SetShaderParams(sky->GetLight()->GetLightDir(), currc->cam->pos); if (shadowHandler->ShadowsLoaded()) { terrain::ShadowMapParams params; params.mid[0] = shadowHandler->GetShadowParams().x; params.mid[1] = shadowHandler->GetShadowParams().y; params.f_a = shadowHandler->GetShadowParams().z; params.f_b = shadowHandler->GetShadowParams().w; params.shadowMap = shadowHandler->GetShadowTextureID(); for (int a = 0; a < 16; a++) params.shadowMatrix[a] = shadowHandler->GetShadowMatrixRaw()[a]; tr->SetShadowParams(¶ms); } tr->SetActiveContext(currc); glEnable(GL_CULL_FACE); glFrontFace(GL_CW); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); glEnable(GL_LIGHTING); glLightfv(GL_LIGHT0, GL_POSITION, sky->GetLight()->GetLightDir()); float d[4] = {0.0f, 0.0f, 0.0f, 1.0f}; const float z[] = {0.0f, 0.0f, 0.0f, 1.0f}; for (int a = 0; a < 3; a++) d[a] = sunLighting->groundDiffuseColor[a]; glLightfv(GL_LIGHT0, GL_DIFFUSE, d); for (int a = 0; a < 3; a++) d[a] = sunLighting->groundAmbientColor[a]; glLightfv(GL_LIGHT0, GL_AMBIENT, d); for (int a = 0; a < 3; a++) d[a] = sunLighting->groundSpecularColor[a]; glLightfv(GL_LIGHT0, GL_SPECULAR, d); for (int a = 0; a < 4; a++) d[a] = 0.0f; glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, d); glLightModelfv(GL_LIGHT_MODEL_AMBIENT, z); glDisable(GL_LIGHT1); glEnable(GL_LIGHT0); glEnable(GL_RESCALE_NORMAL); // glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION,dir.getf()); // glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, 90.0f); /* const float ambient[] = { 0.4f, 0.4f, 0.4f, 1.0f }; const float diffuse[] = { 1.0f, 1.0f, 1.0f, 1.0f }; glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse); glLightfv(GL_LIGHT0, GL_AMBIENT, ambient); glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1); const float md[] = { 1.0f, 1.0f, 1.0f, 1.0f }; glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, md); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, md); glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 10.0f);*/ ///////////////////// tr->Draw(); glDisable(GL_LIGHT0); glDisable(GL_LIGHTING); if (wireframe) { glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); } if (drawMode != drawNormal) { glEnable(GL_BLEND); glDepthMask(GL_FALSE); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_POLYGON_OFFSET_FILL); glPolygonOffset(0.0f, -10.0f); glColor4f(1.0f, 1.0f, 1.0f, 0.5f); tr->DrawOverlayTexture(infoTex); glDisable(GL_POLYGON_OFFSET_FILL); glDepthMask(GL_TRUE); glDisable(GL_BLEND); } glFrontFace(GL_CCW); glDisable(GL_CULL_FACE); glColor3ub(255, 255, 255); DrawObjects(drawPass); glActiveTextureARB(GL_TEXTURE0_ARB); glDisable(GL_TEXTURE_2D); }
/* Overridable function, if necessary, for doing all of the drawing. Base class version checks whether a redraw is needed and does nothing if not. See Redraw() function. If a redraw is needed then there is an option to either redraw the whole screen or just redraw the moving objects. If redrawing the whole screen then: 1a) SetupBackgroundBuffer is called to draw the background to the background buffer. 1b) DrawScreen is called to copy the background buffer onto the screen, then draw the moving objects. 1c) SDL_UpdateRect() is called to actually redraw the whole screen. If only redrawing the moving objects then: 2a) DrawChangingObjects() is called to remove the objects from their old positions, and redraw them in their new positions. 2b) GetUpdateRectanglesForChangingObjects() is called to calculate where on the screen needs redrawing. 2c) SDL_UpdateRects() is called to redraw the parts of the screen which changed. */ void BaseEngine::GameRender(void) { if ( !m_bNeedsRedraw ) return; // Just drawn so no more redraw needed m_bNeedsRedraw = false; // Note: the redraw flags must only be set early in this method, not at the end, since the drawing/moving of the moving objects may // potentially flag a win/lose condition and a state change, which will set the redraw flag again to force a full draw after the // state changes. if ( m_bWholeScreenUpdate ) { // Drawn whole screen now, so no need to draw it again. See note above about the importance of not resetting this after DrawChangingObjects() m_bWholeScreenUpdate = false; // Lock surface if needed if (SDL_MUSTLOCK(m_pActualScreen)) { m_bInsideDraw = true; if (SDL_LockSurface(m_pActualScreen) < 0) return; } // Draw the screen as it should appear now. // First draw the background //this->CopyBackgroundPixels( 100, 100, 100, 100 ); CopyAllBackgroundBuffer(); // Draw the text for the user DrawStrings(); // Single function in case people want to use that instead DrawStringsUnderneath(); // Draw the string underneath the other objects here // Then draw the changing objects DrawObjects(); // Another option for where to put the draw strings code - if you want it on top of the moving objects DrawStringsOnTop(); // Unlock if needed if (SDL_MUSTLOCK(m_pActualScreen)) SDL_UnlockSurface(m_pActualScreen); m_bInsideDraw = false; SDL_UpdateTexture( m_pSDL2Texture,NULL,m_pActualScreen->pixels,m_pActualScreen->pitch ); //SDL_RenderClear( m_pSDL2Renderer ); SDL_RenderCopy( m_pSDL2Renderer,m_pSDL2Texture,NULL,NULL ); SDL_RenderPresent( m_pSDL2Renderer ); //SDL_UpdateRect(m_pActualScreen, 0, 0, m_iScreenWidth, m_iScreenHeight); } else { // Here we assume that the background buffer has already been set up // Lock surface if needed if (SDL_MUSTLOCK(m_pActualScreen)) { m_bInsideDraw = true; if (SDL_LockSurface(m_pActualScreen) < 0) return; } // Remove objects from their old positions UndrawObjects(); // Remove the old strings be re-drawing the background UnDrawStrings(); // Draw the text for the user DrawStrings(); // Single function in case people want to use that instead DrawStringsUnderneath(); // Draw the string underneath the other objects here // Draw objects at their new positions DrawObjects(); // Another option for where to put the draw strings code - if you want it on top of the moving objects DrawStringsOnTop(); // Unlock if needed if (SDL_MUSTLOCK(m_pActualScreen)) SDL_UnlockSurface(m_pActualScreen); m_bInsideDraw = false; // Copy the screen display into the window and display it SDL_UpdateTexture( m_pSDL2Texture,NULL,m_pActualScreen->pixels,m_pActualScreen->pitch ); //SDL_RenderClear( m_pSDL2Renderer ); SDL_RenderCopy( m_pSDL2Renderer,m_pSDL2Texture,NULL,NULL ); SDL_RenderPresent( m_pSDL2Renderer ); } }
void QuadTree::DrawTrees(Frustum* frust){ DrawObjects(m_root,frust); }
void THFrame::Draw() { PreDraw(); DrawObjects(); PostDraw(); }
void CSm3GroundDrawer::Draw(bool drawWaterReflection,bool drawUnitReflection,unsigned int overrideVP) { if(drawUnitReflection || drawWaterReflection) return; terrain::RenderContext *currc; if (drawWaterReflection) { if (!reflectrc) { reflectrc = tr->AddRenderContext(&reflectCam, true); tr->Update(); } SpringCamToTerrainCam(*camera, reflectCam); currc = reflectrc; } else currc = rc; tr->SetShaderParams(gs->sunVector, currc->cam->pos); /* if (shadowHandler->drawShadows) { terrain::ShadowMapParams params; shadowHandler->GetShadowMapSizeFactors (params.f_a, params.f_b); params.mid [0] = shadowHandler->xmid; params.mid [1] = shadowHandler->ymid; params.shadowMap = shadowHandler->shadowTexture; for (int a=0;a<16;a++) params.shadowMatrix[a] = shadowHandler->shadowMatrix[a]; tr->SetShadowParams (¶ms); }*/ tr->SetActiveContext (currc); glEnable(GL_CULL_FACE); glFrontFace(GL_CW); glColor4f(1.0f,1.0f,1.0f,1.0f); glEnable(GL_LIGHTING); glLightfv(GL_LIGHT0, GL_POSITION,gs->sunVector4); float d[4]={0.0f,0.0f,0.0f,1.0f}; for (int a=0;a<3;a++) d[a]=map->sunColor[a]; glLightfv(GL_LIGHT0, GL_DIFFUSE, d); for (int a=0;a<3;a++) d[a]=map->ambientColor[a]; glLightfv(GL_LIGHT0, GL_AMBIENT, d); for (int a=0;a<3;a++) d[a]=map->specularColor[a]; glLightfv (GL_LIGHT0, GL_SPECULAR, d); for (int a=0;a<4;a++) d[a]=0.0f; glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, d); const float zero[] = { 0.0f, 0.0f, 0.0f, 1.0f }; glLightModelfv (GL_LIGHT_MODEL_AMBIENT, zero); glDisable(GL_LIGHT1); glEnable(GL_LIGHT0); glEnable(GL_RESCALE_NORMAL); // glLightfv (GL_LIGHT0, GL_SPOT_DIRECTION,dir.getf()); // glLightf (GL_LIGHT0, GL_SPOT_CUTOFF, 90.0f); /* const float ambient[] = { 0.4f, 0.4f, 0.4f, 1.0f }; const float diffuse[] = { 1.0f, 1.0f, 1.0f, 1.0f }; glLightfv (GL_LIGHT0, GL_DIFFUSE, diffuse); glLightfv (GL_LIGHT0, GL_AMBIENT, ambient); glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1); const float md[] = { 1.0f, 1.0f, 1.0f, 1.0f }; glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, md); glMaterialfv (GL_FRONT_AND_BACK, GL_SPECULAR, md); glMaterialf (GL_FRONT_AND_BACK, GL_SHININESS, 10.0f);*/ ///////////////////// tr->Draw (); glDisable(GL_LIGHT0); glDisable(GL_LIGHTING); if (drawMode != drawNormal) { glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glColor4f(1.0f,1.0f,1.0f,0.5f); tr->DrawOverlayTexture (infoTex); glDisable(GL_BLEND); } glFrontFace(GL_CCW); glDisable(GL_CULL_FACE); glColor3ub(255,255,255); DrawObjects(drawWaterReflection, drawUnitReflection); glActiveTextureARB(GL_TEXTURE0_ARB); glDisable(GL_TEXTURE_2D); }
bool WLD_SetPoint::loadFile(const QString &fileName, WorldData FileData, dataconfigs &configs, LevelEditingSettings options) { QFile file(fileName); WldData = FileData; setCurrentFile(fileName); WldData.modified = false; WldData.untitled = false; if (!file.open(QFile::ReadOnly | QFile::Text)) { QMessageBox::warning(this, tr("Read file error"), tr("Cannot read file %1:\n%2.") .arg(fileName) .arg(file.errorString())); return false; } StartWldData = WldData; //Save current history for made reset ui->graphicsView->setBackgroundBrush(QBrush(Qt::black)); ui->graphicsView->setInteractive(true); ui->graphicsView->setCursor(Qt::CrossCursor); ui->graphicsView->setDragMode(QGraphicsView::NoDrag); ui->graphicsView->setRenderHint(QPainter::Antialiasing, true); ui->graphicsView->viewport()->setMouseTracking(true); //Check if data configs exists if( configs.check() ) { WriteToLog(QtCriticalMsg, QString("Error! *.INI configs not loaded")); QMessageBox::warning(this, tr("Configurations not loaded"), tr("Cannot open level world %1:\nbecause object configurations are not loaded\n." "Please check that the ""config/SMBX"" directory exists and contains the *.INI files with object settings.") .arg(fileName)); WriteToLog(QtCriticalMsg, QString(" << close subWindow")); this->close(); WriteToLog(QtCriticalMsg, QString(" << closed, return false")); return false; } WriteToLog(QtDebugMsg, QString(">>Starting to load file")); //Declaring of the scene scene = new WldScene(ui->graphicsView, configs, WldData, this); scene->opts = options; scene->isSelectionDialog = true; ui->animation->setChecked(scene->opts.animationEnabled); //Preparing point selection mode scene->SwitchEditingMode(WldScene::MODE_SetPoint); if(mapPointIsNull) { scene->selectedPointNotUsed = true; } else { scene->selectedPointNotUsed = false; scene->selectedPoint = mapPoint; } scene->setItemPlacer(5); connect(scene, SIGNAL(pointSelected(QPoint)), this, SLOT(pointSelected(QPoint))); int DataSize=0; DataSize += 3; DataSize += 6; QProgressDialog progress(tr("Loading World map data"), tr("Abort"), 0, DataSize, this); progress.setWindowTitle(tr("Loading World data")); progress.setWindowModality(Qt::WindowModal); progress.setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint | Qt::WindowStaysOnTopHint); progress.setFixedSize(progress.size()); progress.setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, progress.size(), qApp->desktop()->availableGeometry())); progress.setMinimumDuration(0); if(! DrawObjects(progress) ) { WldData.modified = false; this->close(); return false; } QApplication::setOverrideCursor(Qt::WaitCursor); if( !progress.wasCanceled() ) progress.close(); QApplication::restoreOverrideCursor(); setAutoUpdateTimer(31); WldData.modified = false; WldData.untitled = false; progress.deleteLater(); return true; }
void CNCaptureView::DoPaint(CDCHandle dc) { FUNCTION_BLOCK_TRACE(20); if ( m_bIsDrawing ) { return; } m_bIsDrawing = TRUE; BOOL bRet = FALSE; CRect rcClientLogical; GetClientRect(rcClientLogical); dc.DPtoLP(rcClientLogical); rcClientLogical.InflateRect(4, 4); //fix scroll brush display error //CRect rcClient; //GetClientRect(&rcClient); //CWindowDC WndDc(m_hWnd); //WndDc.FillRect(&rcClient, m_brBackground); { //make sure MemDC bitblt //CMemoryDC memDC(dc.m_hDC, rcClient); CZoomScrollMemDC memDC (dc.m_hDC, rcClientLogical); PrepareDC(memDC.m_hDC); memDC.SetBrushOrg( -m_ptOffset.x , -m_ptOffset.y); //API_VERIFY(memDC.FillRect(&rcClip, m_brBackground)); //API_VERIFY(memDC.FillRect(&rcClientLogical, m_brBackground)); memDC.FillSolidRect(&rcClientLogical, NCAPTUREVIEW_BACKGROUND_CLR); if (m_pImage) { CRect rcImage(0, 0, m_pImage->GetWidth(), m_pImage->GetHeight()); if (m_canvasImage.IsCanvasChanged(rcImage) || m_bImageChanged) { m_canvasImage.Release(); API_VERIFY(m_canvasImage.Create(m_hWnd, rcImage.Width(), rcImage.Height())); m_bImageChanged = FALSE; //API_VERIFY(m_pImage->Draw(m_canvasImage, rcImage)); } API_VERIFY(m_pImage->Draw(m_canvasImage, rcImage)); DrawObjects(m_canvasImage.GetMemoryDC()); { //When Capture image size multiply by zoom bigger than 32767, GDI CAN NOT display the image memDC.SetStretchBltMode(HALFTONE); //HALFTONE); bRet = memDC.BitBlt( 0, 0, //rcClientLogical.left, rcClientLogical.top rcImage.Width(), rcImage.Height(),// rcClientLogical.Width(), rcClientLogical.Height(), m_canvasImage.GetMemoryDC(), 0, 0, //rcClientLogical.left, rcClientLogical.top, SRCCOPY); if(!bRet) { FTLTRACE(TEXT("%s StretchBlt Failed, LastError=%d\n"), __FILE__LINE__, ::GetLastError()); } } DrawTextObject(memDC.m_hDC); { CFMMTextDCGuard mmTextDCGuard(memDC); if (!m_pImage && m_pDefaultImage) { //no image ,just draw default image CRect rcClientDevice; GetClientRect(&rcClientDevice); CSize szDefaultImage(m_pDefaultImage->GetWidth(), m_pDefaultImage->GetHeight()); CRect rcDefaultImageTarget = m_pCalcRect->GetPhotoRect(rcClientDevice, &szDefaultImage, 1.0f, FALSE, FALSE); NDGraphics::DrawGdiplusImage(memDC, m_pDefaultImage, rcDefaultImageTarget.left, rcDefaultImageTarget.top, rcDefaultImageTarget.Width(), rcDefaultImageTarget.Height()); } DrawObjectsTracker(memDC.m_hDC); } } } //FTLTRACE(TEXT("DoPaint, m_rcDrawTarget=[%d,%d]x[%d,%d]\n"), m_rcDrawTarget.left, m_rcDrawTarget.top, // m_rcDrawTarget.right, m_rcDrawTarget.bottom); //CClientDC clientDC(m_hWnd); m_bIsDrawing = FALSE; }
void MakeSelection(int nChoice) { // Space for the feedback buffer GLfloat feedBackBuff[FEED_BUFF_SIZE]; // Storeage for counters, etc. int size,i,j,count; // Initial minimum and maximum values bRect.right = bRect.bottom = -999999.0f; bRect.left = bRect.top = 999999.0f; // Set the feedback buffer glFeedbackBuffer(FEED_BUFF_SIZE,GL_2D, feedBackBuff); // Enter feedback mode glRenderMode(GL_FEEDBACK); // Redraw the scene DrawObjects(); // Leave feedback mode size = glRenderMode(GL_RENDER); // Parse the feedback buffer and get the // min and max X and Y window coordinates i = 0; while(i < size) { // Search for appropriate token if(feedBackBuff[i] == GL_PASS_THROUGH_TOKEN) if(feedBackBuff[i+1] == (GLfloat)nChoice) { i+= 2; // Loop until next token is reached while(i < size && feedBackBuff[i] != GL_PASS_THROUGH_TOKEN) { // Just get the polygons if(feedBackBuff[i] == GL_POLYGON_TOKEN) { // Get all the values for this polygon count = (int)feedBackBuff[++i]; // How many vertices i++; for(j = 0; j < count; j++) // Loop for each vertex { // Min and Max X if(feedBackBuff[i] > bRect.right) bRect.right = feedBackBuff[i]; if(feedBackBuff[i] < bRect.left) bRect.left = feedBackBuff[i]; i++; // Min and Max Y if(feedBackBuff[i] > bRect.bottom) bRect.bottom = feedBackBuff[i]; if(feedBackBuff[i] < bRect.top) bRect.top = feedBackBuff[i]; i++; } } else i++; // Get next index and keep looking } break; } i++; } }