//Called to update the display. //You should call glutSwapBuffers after all of your rendering to display what you rendered. //If you need continuous updates of the screen, call glutPostRedisplay() at the end of the function. void display() { glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClearDepth(1.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); if (g_pConeMesh && g_pCylinderMesh && g_pCubeTintMesh && g_pCubeColorMesh && g_pPlaneMesh) { const glm::vec3 &camPos = ResolveCamPosition(); glutil::MatrixStack camMatrix; camMatrix.SetMatrix(CalcLookAtMatrix(camPos, g_camTarget, glm::vec3(0.0f, 1.0f, 0.0f))); glBindBuffer(GL_UNIFORM_BUFFER, g_GlobalMatricesUBO); glBufferSubData(GL_UNIFORM_BUFFER, sizeof(glm::mat4), sizeof(glm::mat4), glm::value_ptr(camMatrix.Top())); glBindBuffer(GL_UNIFORM_BUFFER, 0); glutil::MatrixStack modelMatrix; //Draw Scene DrawRoom(modelMatrix); DrawArmchair(modelMatrix); DrawTable(modelMatrix); DrawCarpet(modelMatrix); DrawLowTable(modelMatrix); DrawPicture(modelMatrix); DrawLamp(modelMatrix); DrawPlant(modelMatrix); DrawCandlesInLoop(modelMatrix); } glutSwapBuffers(); glutPostRedisplay(); }
void CDbgLuaHelper::DrawVariable(lua_State * l, const char* name, bool bOpenTable) { Variable var; strcpy(var.szName, name ); const char * type; int ntype = lua_type(l, -1); type = lua_typename(l, ntype); strcpy(var.szType, type); char value[64]; switch(ntype) { case LUA_TNUMBER: sprintf(value, "%f", lua_tonumber(l, -1)); strcpy(var.szValue, value ); break; case LUA_TBOOLEAN: sprintf(value, "%s", lua_toboolean(L, -1) ? "true" : "false"); strcpy(var.szValue, value ); break; case LUA_TSTRING: sprintf(value, "%.63s", lua_tostring(l, -1)); strcpy(var.szValue, value ); break; case LUA_TTABLE: var.szValue[0]=0; debugger()->AddLocalVariable(var); if(bOpenTable) DrawTable(l, name, false); return; break; /* case LUA_TUSERDATA:{ luabind::detail::object_rep* obj = static_cast<luabind::detail::object_rep*>(lua_touserdata(L, -1)); luabind::detail::lua_reference& r = obj->get_lua_table(); lua_State * ls = NULL; r.get(ls); DrawTable(ls, name); return; }break;*/ default: value[0] = '\0'; break; } debugger()->AddLocalVariable(var); }
void GotoPage(DmOpenRef db, Int16 page) { UInt16 pageCount = PrivPageCount(db); g_CurrentPage = page; if (g_CurrentPage < 0) g_CurrentPage = 0; if (g_CurrentPage > pageCount) g_CurrentPage = pageCount; UInt16 lastPageSize = GetSMSCount(db, g_SelectedCategory) - pageCount * TABLE_PAGE_SIZE; if (g_CurrentPage == pageCount) { if (g_CurrentSelection >= lastPageSize) { g_CurrentSelection = lastPageSize - 1; } } DrawTable(db, g_SelectedCategory); }
int CPrintDlg::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CDialogEx::OnCreate(lpCreateStruct) == -1) return -1; CClientDC dc(this); CRect rect; GetClientRect(&rect); int nTable, nItem; m_pCase->GetCount(nTable,nItem); m_nLength = (TABLE_GAP + HEAD_HEIGHT) * nTable + ROW_HEIGHT * nItem + TABLE_BOTTOM_GAP; //打印内容总长 //创建m_mdcBuf m_mdcTitle m_mdcTable m_mdcBuf.Create(rect.right, rect.bottom, &dc); m_mdcTitle.Create(rect.right, TITLE_HEIGHT, &dc); m_mdcTable.Create(g_nRowWidth, m_nLength, &dc); //画打印内容 DrawTable(g_nRowWidth, m_nLength); //滚动条 m_scrollBarV.Create(SBS_VERT | WS_CHILD | WS_VISIBLE | SIF_PAGE, CRect(0,0,0,0), this, IDC_SCROLLBARV); m_scrollBarV.SetScrollPos(0); return 0; }
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 COthelloView::OnLButtonDown(UINT nFlags, CPoint point) { CClientDC dc(this); COthelloDoc *pDoc=GetDocument(); if (m_Current>=0 && (pDoc->m_MainTable).GetTable(m_Current)<1) { if (m_CurPlay==T_BLACK && (pDoc->m_MainTable).IsDown(m_CurCol,m_CurRow,T_BLACK)) { BiltBitmap(m_CurX,m_CurY,m_CurX+33,m_CurY+33,m_hBlack); (pDoc->m_MainTable).SetTable(m_Current,T_BLACK); DrawTable(m_CurCol,m_CurRow,T_BLACK); if (!(pDoc->m_MainTable).HaveDown(T_WHITE)) { if (!(pDoc->m_MainTable).HaveDown(T_BLACK)) { pDoc->GameOver(); } else { MessageBox("White Pass!!!"); m_CurPlay=T_BLACK; } } else { ::SetClassLong(GetSafeHwnd(),GCL_HCURSOR,NULL); SetCursor(m_hcurWhite); cont: CPoint point,pos; point=pDoc->TryIt(T_WHITE,T_DEPTH); (pDoc->m_MainTable).SetTable(point.x,point.y,T_WHITE); pos=GetPosition(point.x,point.y); //MessageBeep(MB_ICONINFORMATION); BiltBitmap(pos.x,pos.y,pos.x+33,pos.y+33,m_hWhite); Sleep(100); dc.FillSolidRect(pos.x,pos.y,34,34,m_NormalColor); Sleep(100); BiltBitmap(pos.x,pos.y,pos.x+33,pos.y+33,m_hWhite); Sleep(100); dc.FillSolidRect(pos.x,pos.y,34,34,m_NormalColor); Sleep(100); BiltBitmap(pos.x,pos.y,pos.x+33,pos.y+33,m_hWhite); DrawTable(point.x,point.y,T_WHITE); m_CurPlay=T_BLACK; if (!(pDoc->m_MainTable).HaveDown(T_BLACK)) { if (!(pDoc->m_MainTable).HaveDown(T_WHITE)) { pDoc->GameOver(); } else { MessageBox("Black Pass!!!"); m_CurPlay=T_WHITE; goto cont; } } } ::SetClassLong(GetSafeHwnd(),GCL_HCURSOR,NULL); SetCursor(m_hcurDefault); DispDown(pDoc,&dc); } else { if (m_CurPlay==T_WHITE && (pDoc->m_MainTable).IsDown(m_CurCol,m_CurRow,T_WHITE)) { BiltBitmap(m_CurX,m_CurY,m_CurX+33,m_CurY+33,m_hWhite); (pDoc->m_MainTable).SetTable(m_Current,T_WHITE); DrawTable(m_CurCol,m_CurRow,T_WHITE); if (!(pDoc->m_MainTable).HaveDown(T_BLACK)) { if (!(pDoc->m_MainTable).HaveDown(T_WHITE)) { MessageBox("Game Over!!!"); } else { MessageBox("No!!!"); m_CurPlay=T_WHITE; } } else { m_CurPlay=T_BLACK; } ::SetClassLong(GetSafeHwnd(),GCL_HCURSOR,NULL); SetCursor(m_hcurDefault); } } } // TODO: Add your message handler code here and/or call default CView::OnLButtonDown(nFlags, point); }