>这是NENE的OPENGL的框架CB原代码,是黑屏的效果,最简单的。OPENGL我才开始学,很多不懂的,希望和大家交流,共同进步,我会把我的资料和大家共享的!</P>1 I4 a7 X* _3 q: O- O$ K- X
>首先在CB下建立一个CONSOLE的程序,然后把CONSOLE APPLICATION的勾去掉即可。然后再把以下的原代码粘贴上去就可以运行了!!</P>9 _/ ?5 Q. A9 l% P1 j8 n( E
>//---------------------------------------------------------------------------</P>
>#include <vcl.h>8 u8 P8 U# C1 v% q8 h
>//---------------------------------------------------------------------------7 h5 @3 N# t4 j3 t
>HGLRC hRC = NULL; // Permanent rendering context3 \' j( E) c/ ~5 E z5 R. |2 Y2 |6 u
>bool keys[256]; // Array used for the keyboard routine; W6 r- \3 K3 Y
>LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); // Declaration for WndProc</P>
>GLvoid ReSizeGLScene(GLsizei width, GLsizei height) // Resize and initialize the GL window
> glViewport(0, 0, width, height); // Reset the current viewport</P>+ }, Z" g! P: c
> glMatrixMode(GL_PROJECTION); // Select the projection matrix, ~) s. B. w/ Z1 c3 v% {0 \3 X& f
> // Calculate the aspect ratio of the window
> glMatrixMode(GL_MODELVIEW); // Select the modelview matrix1 v, ]: \ U2 s6 Y$ h" x
>int InitGL(GLvoid) // All setup for OpenGL goes here( h( Z" ?& R( j' e$ r
>int DrawGLScene(GLvoid) // Here's where we do all the drawing6 Q- {, l& P' n( H. a5 r
>GLvoid KillGLWindow(GLvoid) // Properly kill the window6 ] v( n% I. r7 E1 ^
> if (hRC) // Do we have a rendering context?
> if (!wglDeleteContext(hRC)) // Are we able to delete the RC?+ f$ r0 K+ }. P: m4 w% k4 \& w9 T
> if (hDC && !ReleaseDC(hWnd,hDC)) // Are we able to release the DC
> if (hWnd && !DestroyWindow(hWnd)) // Are we able to destroy the window?
> if (!UnregisterClass("OpenGL",hInstance)) // Are we able to unregister class+ I; z( R/ Y: p! J
>/* This Code Creates Our OpenGL Window. Parameters Are:
> fullscreen = fullscreenflag; // Set the global fullscreen flag</P>
> hInstance = GetModuleHandle(NULL); // Grab an instance for our window
> if (!RegisterClass(&wc)) // Attempt to register the window class; w6 X( o- O9 k- |
> return false; // Return false
> // 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);
> if (fullscreen) // Are We Still In Fullscreen Mode?
> 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版本以后已经完全支持9 v5 l6 t8 K- O {
>----用VC来编写OpenGL程序+ U2 _# n3 O, q3 ~! p% J
reCreateWindow(CREATESTRUCT& cs) 2 i/ S; n% B9 [7 a8 o& Z$ H: X
reCreateWindow(cs);& y& ~0 o- _5 j2 R/ W# V9 a
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 |