>这是NENE的OPENGL的框架CB原代码,是黑屏的效果,最简单的。OPENGL我才开始学,很多不懂的,希望和大家交流,共同进步,我会把我的资料和大家共享的!</P>
>首先在CB下建立一个CONSOLE的程序,然后把CONSOLE APPLICATION的勾去掉即可。然后再把以下的原代码粘贴上去就可以运行了!!</P>
>//---------------------------------------------------------------------------</P>
>#include <vcl.h>$ {* R) H/ [4 Z4 x% m: ^- y
>//---------------------------------------------------------------------------5 V# a4 c1 }9 `* M4 O" L
>HGLRC hRC = NULL; // Permanent rendering context7 v! ~. D. I7 v6 `; |& ]7 d; B. L3 [
>bool keys[256]; // Array used for the keyboard routine# f; O" E8 H. A( a, q6 j5 L) x
>LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); // Declaration for WndProc</P>/ l$ e# M, ?, k- @ p0 ^7 r
>GLvoid ReSizeGLScene(GLsizei width, GLsizei height) // Resize and initialize the GL window
> glViewport(0, 0, width, height); // Reset the current viewport</P>
> glMatrixMode(GL_PROJECTION); // Select the projection matrix+ P* z0 f1 l0 N) L
> // Calculate the aspect ratio of the window* N) u; ~3 K' Z5 [. G
> glMatrixMode(GL_MODELVIEW); // Select the modelview matrix6 v& i5 D" @ V+ h
>int InitGL(GLvoid) // All setup for OpenGL goes here
>int DrawGLScene(GLvoid) // Here's where we do all the drawing0 P1 i: o* ?6 |5 |
>GLvoid KillGLWindow(GLvoid) // Properly kill the window
> if (hRC) // Do we have a rendering context?
> if (!wglDeleteContext(hRC)) // Are we able to delete the RC?$ j; K3 I3 c! l
> if (hDC && !ReleaseDC(hWnd,hDC)) // Are we able to release the DC
> if (hWnd && !DestroyWindow(hWnd)) // Are we able to destroy the window?$ v6 j1 j- \/ h$ C4 S/ ?- R
> if (!UnregisterClass("OpenGL",hInstance)) // Are we able to unregister class
>/* This Code Creates Our OpenGL Window. Parameters Are:
> fullscreen = fullscreenflag; // Set the global fullscreen flag</P>( k8 p1 E7 C2 r: w2 p# O
> hInstance = GetModuleHandle(NULL); // Grab an instance for our window
> if (!RegisterClass(&wc)) // Attempt to register the window class
> return false; // Return false/ ] [* z) ?, o/ ^1 Q4 \) x
> // Try to set selected mode and get results. NOTE: CDS_FULLSCREEN gets rid of start bar.
rogram will now close.","ERROR",MB_OK|MB_ICONSTOP);- N2 V; | a2 c( b, d( J
> if (fullscreen) // Are We Still In Fullscreen Mode?+ h* l! U7 t+ O9 p* I) l! Y/ N
> AdjustWindowRectEx(&WindowRect,dwStyle,false,dwExStyle); // Adjust window to true requested size</P>
>试验了,果然是黑屏的效果!</P>
>我也支持一篇</P><
>转贴:Win 95/NT下OpenGL编程原理 ----</P><
>科学计算可视化,计算机动画和虚拟现实是现在计算机图形学的三个热点。而这三个热点的核心都是三维真实感图形的绘制。由于OpenGL(OpenGraphicsLibrary)具有跨平台性、简便、高效、功能完善,目前已经成为了三维图形制作方法中事实上的工业标准。自从WindowsNT3.51在微机平台上支持OpenGL以后,现在微软公司在Windows95OSR2、WindowsNT4.0中连续性的提供OpenGL开发环境。VisualC++从4.2版本以后已经完全支持
>----用VC来编写OpenGL程序5 \' D4 }* l$ O/ w4 T$ `
reCreateWindow(CREATESTRUCT& cs)
reCreateWindow(cs); r5 D' _: C# G& r
FD_DRAW_TO_WINDOW |&&&&&&&&&&&&// support window
FD_SUPPORT_OPENGL |&&&&&&&&&&&&// support OpenGL
FD_TYPE_RGBA,&&&&&&&&&&&&&&&&&&// RGBA模式,不用调色板
FD_MAIN_PLANE,&&&&&&&&&&&&&&&&&// main layer
>你们都知道我在看OpenGL啊.</P>
| 欢迎光临 数学建模社区-数学中国 (http://www.madio.net/) | Powered by Discuz! X2.5 |