freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

基于mfc的opengl編程-在線瀏覽

2024-09-20 17:35本頁(yè)面
  

【正文】 下,2, 創(chuàng)建一個(gè)MFC SDI應(yīng)用程序,在項(xiàng)目屬性中加入所需要鏈接的庫(kù)文件1, ://OpenGLgl/includegl/include這些應(yīng)該放在PreCreateWindow()中。CCY457OpenGLView::PreCreateWindow(CREATESTRUCTamp。cs){//ModifyWindoworheremodifying//thecs//AnWindowbewithfollowing|=|return}4,m_hRC。ContextCDC*//DeviceInitializeOpenGL()。OpenGLBOOL//SettheFormatvoid//RenderScene5,intlpCreateStruct)(CView::OnCreate(lpCreateStruct)1)return//InitializeHereInitializeOpenGL()。0。CCY457OpenGLView::InitializeOpenGL(){//GetDCtheAream_pDCnew//FailureGet==Obtainingreturn}//FailuresetpixelFALSE。Rendering=(m_pDCGetSafeHdc//FailureCreateContextif(m_hRC0){MessageBox(ErrorRC)。FALSE。theCurrentif(::wglMakeCurrent(),makingCurrent)。FALSE。Blackthecolor::glClearColor(,)。theofbufferclear//EnableTesting::glEnable(GL_DEPTH_TEST)。TRUE。PixelCCY457OpenGLView::SetupPixelFormat(){staticpfd{sizeof(PIXELFORMATDESCRIPTOR),//ofpfd1,//numberPFD_DRAW_TO_WINDOWsupport|//OpenGLPFD_DOUBLEBUFFER,//bufferedPFD_TYPE_RGBA,//type24,24bitdepth0,0,0,//bitsnobuffer0,//bitnobuffer0,0,//bits//zbuffer0,//stencilnobufferPFD_MAIN_PLANE,mainreserved0,0layerignored}。m_nPixelFormat::ChoosePixelFormat(m_pDCGetSafeHdc(),pfd)。(==){FALSE。(m_nPixelFormat,pfd)FALSE){FALSE。TRUE。在OnSize()中一般用來(lái)設(shè)置視口和視錐,因?yàn)檫@些是和窗口大小相關(guān)的。voidnType,cx,cy)cx,GLdoublewidth/height(=||=){return。selectfullarea::glViewport(0,cx,//theratio//willallscales=//thematrixclear::glLoadIdentity()。selectviewingaspect_ratio,)。switchtomodelviewandit::glMatrixMode(GL_MODELVIEW)。}7,在繪制場(chǎng)景時(shí),一般包括如下步驟:1)清空緩存。3)Flush掉渲染流水線。voidpDC){CCY457OpenGLDoc*=ASSERT_VALID(pDoc)。Cleartheamp。depthGL_COLOR_BUFFER_BITGL_DEPTH_BUFFER_BITRenderScene()。Telltoits//Swapbuffers::SwapBuffers()。CCY457OpenGLView::RenderScene發(fā)生閃爍的原因是Windows先繪制背景,然后再是OpenGL繪制,因?yàn)槲覀円呀?jīng)讓OpenGL負(fù)責(zé)清空背景色,因此我們不需要Windows去清空背景了BOOLpDC)WindowstotheTRUE。內(nèi)存泄露的原因是我們?cè)赟etupPixelFormat()中使用了new運(yùn)算符來(lái)為CClientDC對(duì)象分配內(nèi)存,因此需要顯示delete掉。CCY457OpenGLView::OnDestroy()//MakeRC(0,0)FALSE){MessageBox(Couldmakenoncurrent)。thecontextif(::wglDeleteContextnotRC)。them_pDC。itNULLm_pDCNULL。In OpenGL when you create a window to draw in we must specify the coordinate system we want to use and how to map the specified coordinates into physical screen coordinates. We would be using the 2D Cartesian coordinate system with the origin 0,0 at the centre of the screen. Before we can start plotting points, lines and shapes in a window we must also specify how to translate coordinate pairs into screen coordinates, by specifying the clipping area the region of Cartesian space that occupies the window.s client area that is used for drawing the clipping area.m_bPoint。ofm_bLine。ofm_bPolygon。ofm_bTriangle。ofvoid{//畫(huà)點(diǎn)m_bPointTRUE。=m_bPolygonFALSE。=InvalidateRect(NULL,FALSE)。CCY457OpenGLView::OnShapesLine()=m_bLineTRUE。=m_bTriangleFALSE。}void{//畫(huà)多邊形m_bPointFALSE。=m_bPolygonTRUE。=InvalidateRect(NULL,FALSE)。CCY457OpenGLView::OnShapesTriangle()=m_bLineFALSE。=m_bTriangleTRUE。}3,修改第二篇文章中的OnSize()函數(shù),因?yàn)楸疚闹兄焕L制2維圖形.voidnType,cx,cy)cx,GLdoublewidth/height(=||=){return。selectfullarea::glViewport(0,cx,//theratio//willallscales=//thematrixclear::glLoadIdentity()。selectviewingaspect_ratio,)。,)。switchtomodelviewandit::glMatrixMode(GL_MODELVIEW)。}4,在RenderScene中加入具體的繪制代碼:void(){//繪制函數(shù)if(m_bPoint==TRUE){glPointSize()。glVertex2f(,)。glVertex2f(,)。}elseglVertex2f(,)。glEnd()。if(m_bTriangle==TRUE){glBegin(GL_TRIANGLES)。glVertex2f(,)。glEnd()。if(m_bPolygon==TRUE){glBegin(GL_POLYGON)。glVertex2f(,)。glVertex2f(,)。glEnd()。光榮在于平淡,艱巨因?yàn)槁L(zhǎng)《基于MFC的OpenGL編程》Part 4 Drawing Simple 3D objects 視見(jiàn)體 Viewing Volume is nothing but the region of 3D Cartesian space in that will occupy the window. It is nothing but the minimum and maximum x, y and z values that are inside the window. So if a vertex is outside this range of x, y and z values then they are clipped by OpenGL before rendering can occur. Z BufferThe new term we have to deal with in addition to width and height of an object in 3D graphics is depth. The depth of an object is its distance from the viewpoint. The viewpoint is the location from which we are looking at that point. This depth value goes into the depth or Zbuffer. If we are drawing 2 objects that have some pixels that overlap, the first object will after it is rendered have its depth value in the depth buffer. When the next object is rendered, OpenGL will check to see whether the pixel it’s about to draw is in front of (with respect to the viewpoint) any pixel from the first object that’s already drawn. It does this by checking the Z value of the current pixel with the value that is already in the buffer. If the new pixel is closer to the viewpoint, OpenGL places its depth value in the depth buffer. This is how the Zbuffer works.正交投影和透視投影One term we need to understand very well to lear
點(diǎn)擊復(fù)制文檔內(nèi)容
環(huán)評(píng)公示相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1