nehe的幾個opengl框架都是win32 sdk版本的,我現在需要在mfc下學習opengl,今天看了他寫的第乙個opengl框架,就在mfc中實現了下。為了簡單起見,把全屏那部分就拋棄掉了,畢竟重點不在這上面,而且mfc要實現這個全屏的功能也不像sdk那麼容易。。。
/////
//protected
:boolsetwindowpixelformat(hdchdc);
//設定畫素格式
boolcreateviewglcontext(hdchdc);
//建立繪製環境(rc)並使之成為當前繪製環境
boolinitgl(glvoid);
//初始化opengl
intdrawglscene(glvoid);
//繪圖**區
intm_glpixelindex;
hglrcm_hglcontext;
//繪製環境
//copengldemoview::copengldemoview()
boolcopengldemoview::precreatewindow(createstruct
&cs)
boolcopengldemoview::setwindowpixelformat(hdchdc)
;this
->
m_glpixelindex
=choosepixelformat(hdc,
&pixeldesc);
//選擇最相近的畫素格式if(
this
->
m_glpixelindex==0
)}if(setpixelformat(hdc,
this
->
m_glpixelindex,
&pixeldesc)
==false)
return
true;
}boolcopengldemoview::initgl(glvoid)
//allsetupforopenglgoeshere
boolcopengldemoview::createviewglcontext(hdchdc)
if(wglmakecurrent(hdc,
this
->
m_hglcontext)
==false)
return
true;
}int
copengldemoview::oncreate(lpcreatestructlpcreatestruct)if(
this
->
createviewglcontext(hdc)
==false)if(
!this
->
initgl())
return0;
}void
copengldemoview::ondestroy()if(
this
->
m_hglcontext
!=null)
}void
copengldemoview::onsize(uintntype,
intcx,
intcy)
glviewport(0,
0,width,height);
//resetthecurrentviewport
glmatrixmode(gl_projection);
//selecttheprojectionmatrix
glloadidentity();
//resettheprojectionmatrix
//calculatetheaspectratioofthewindow
gluperspective(
45.0f
,(glfloat)width
/(glfloat)height,
0.1f
,100.0f
);//
透視投影
Nehe的OpenGL框架 MFC版
nehe的幾個opengl框架都是win32 sdk版本的,我現在需要在mfc下學習opengl,今天看了他寫的第乙個opengl框架,就在mfc中實現了下。為了簡單起見,把全屏那部分就拋棄掉了,畢竟重點不在這上面,而且mfc要實現這個全屏的功能也不像sdk那麼容易。opengldemoview.h...
openGL學習, NeHe教材
這幾天開始學習opengl的學習,看的是aman jiang 江超宇 翻譯nehe寫的教材,整個文件中有非常詳細的講解,很容易看懂.在第一課的 中,nehe已經構建出了乙個簡單的opengl應用框架,使得我們很容易的在裡面新增和修改 在看過lesson1的 和注釋後,我們可以發現大部分的 是有關於w...
NeHe學習之框架三
wndproc 的實現 視窗訊息處理函式 lresult callback wndproc hwnd hwnd,uint umsg,wparam wparam,lparam lparam else return 0 case wm syscommand 系統中斷 break 如果不是上述中斷事件,就...