>这是NENE的OPENGL的框架CB原代码,是黑屏的效果,最简单的。OPENGL我才开始学,很多不懂的,希望和大家交流,共同进步,我会把我的资料和大家共享的!</P>% m+ k, ^( {1 y3 {& [' Z5 S5 Y
>首先在CB下建立一个CONSOLE的程序,然后把CONSOLE APPLICATION的勾去掉即可。然后再把以下的原代码粘贴上去就可以运行了!!</P>, j- G# @: {0 W0 B
>//---------------------------------------------------------------------------</P>
>#include <vcl.h>& g; G( a% N* s. d
>//---------------------------------------------------------------------------
>HGLRC hRC = NULL; // Permanent rendering context
>bool keys[256]; // Array used for the keyboard routine
>LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); // Declaration for WndProc</P>3 q3 g6 q# Y4 ^, h( @
>GLvoid ReSizeGLScene(GLsizei width, GLsizei height) // Resize and initialize the GL window/ S4 T* Z2 ]( ]+ `) V' G- b
> glViewport(0, 0, width, height); // Reset the current viewport</P>2 F$ q1 s) ]" X+ f/ b, h
> glMatrixMode(GL_PROJECTION); // Select the projection matrix
> // Calculate the aspect ratio of the window# I, r8 }) a0 @% P; T$ P
> glMatrixMode(GL_MODELVIEW); // Select the modelview matrix
>int InitGL(GLvoid) // All setup for OpenGL goes here
>int DrawGLScene(GLvoid) // Here's where we do all the drawing
>GLvoid KillGLWindow(GLvoid) // Properly kill the window
> if (hRC) // Do we have a rendering context?. a7 h* X* N( [, X2 p
> if (!wglDeleteContext(hRC)) // Are we able to delete the RC?! @) Z' z* D' z8 E& Z
> if (hDC && !ReleaseDC(hWnd,hDC)) // Are we able to release the DC
> if (hWnd && !DestroyWindow(hWnd)) // Are we able to destroy the window?' p5 e7 Q5 v4 R* N
> if (!UnregisterClass("OpenGL",hInstance)) // Are we able to unregister class& y) h; s! u( z& [% l
>/* This Code Creates Our OpenGL Window. Parameters Are: Y7 M g3 \, F; R2 U9 R' u
> 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 class5 {2 J( i/ W" v% Y7 N) P* ^" m
> return false; // Return false0 l0 }0 e+ l! J9 E4 O) r, r
> // 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?# D3 s$ k6 h2 w4 F# d
> AdjustWindowRectEx(&WindowRect,dwStyle,false,dwExStyle); // Adjust window to true requested size</P>1 o! F: \6 B" [( ?7 [* v! O
>试验了,果然是黑屏的效果!</P>
>我也支持一篇</P><
>转贴:Win 95/NT下OpenGL编程原理 ----</P><
>科学计算可视化,计算机动画和虚拟现实是现在计算机图形学的三个热点。而这三个热点的核心都是三维真实感图形的绘制。由于OpenGL(OpenGraphicsLibrary)具有跨平台性、简便、高效、功能完善,目前已经成为了三维图形制作方法中事实上的工业标准。自从WindowsNT3.51在微机平台上支持OpenGL以后,现在微软公司在Windows95OSR2、WindowsNT4.0中连续性的提供OpenGL开发环境。VisualC++从4.2版本以后已经完全支持
>----用VC来编写OpenGL程序
reCreateWindow(CREATESTRUCT& cs) . Q! N B$ M2 r1 c, {/ m: f
reCreateWindow(cs);
FD_DRAW_TO_WINDOW |&&&&&&&&&&&&// support window
FD_SUPPORT_OPENGL |&&&&&&&&&&&&// support OpenGL
FD_TYPE_RGBA,&&&&&&&&&&&&&&&&&&// RGBA模式,不用调色板- X3 @( U4 N6 K+ |3 r! s6 D
FD_MAIN_PLANE,&&&&&&&&&&&&&&&&&// main layer0 c. h! k9 ^1 W, S8 k6 G1 o
>你们都知道我在看OpenGL啊.</P>
| 欢迎光临 数学建模社区-数学中国 (http://www.madio.net/) | Powered by Discuz! X2.5 |