游戏开发论坛

 找回密码
 立即注册
搜索
12
返回列表 发新帖
楼主: aznazn

如何在指定窗口实现OpenGL?

[复制链接]

20

主题

86

帖子

91

积分

注册会员

Rank: 2

积分
91
发表于 2005-4-22 00:47:00 | 显示全部楼层

MSDN中有一篇教程

先用OGL画到临时建的DIB上,再把DIB的图片画到HDC上,注意这时候的OGL设置为单缓冲就可以了.

1

主题

12

帖子

14

积分

新手上路

Rank: 1

积分
14
 楼主| 发表于 2005-4-28 01:17:00 | 显示全部楼层

Re:如何在指定窗口实现OpenGL?

终于有人指点了
谢谢大虾指点!
我去试验一下看看!
:)

1

主题

12

帖子

14

积分

新手上路

Rank: 1

积分
14
 楼主| 发表于 2005-4-28 01:45:00 | 显示全部楼层

Re:如何在指定窗口实现OpenGL?

不懂得如何画在DIB上面,我学到的OGL要先建立一个DC跟RC的连接!
11楼的朋友能不能具体指点一下呢?

20

主题

86

帖子

91

积分

注册会员

Rank: 2

积分
91
发表于 2005-4-28 09:29:00 | 显示全部楼层

Re: 如何在指定窗口实现OpenGL?

具体内容我自己也没实现过,只是在MSDN中看过.我把MSDN中的文章和例子放上来吧.

sf_200542892932.rar

234.79 KB, 下载次数:

20

主题

86

帖子

91

积分

注册会员

Rank: 2

积分
91
发表于 2005-4-28 10:44:00 | 显示全部楼层

Re:如何在指定窗口实现OpenGL?

我试了一把,和想像中的一样,此方法不支持硬件加速,速度很慢.看来用处不大.

1

主题

12

帖子

14

积分

新手上路

Rank: 1

积分
14
 楼主| 发表于 2005-4-28 22:34:00 | 显示全部楼层

Re:如何在指定窗口实现OpenGL?

哎~~~看来要恶补英语了~~
我是英盲啊~~~
看看词霸能不能帮点忙!

可怜我啊~~~

20

主题

86

帖子

91

积分

注册会员

Rank: 2

积分
91
发表于 2005-4-30 11:59:00 | 显示全部楼层

Re:如何在指定窗口实现OpenGL?

可能还有一种高速的技术可以实现,就是使用离屏渲染扩展功能.

20

主题

86

帖子

91

积分

注册会员

Rank: 2

积分
91
发表于 2005-4-30 12:04:00 | 显示全部楼层

Re:如何在指定窗口实现OpenGL?

Off-screen Rendering Using Pixel Buffers

The samples below demonstrate how to create dynamic textures through off-screen rendering. The off-screen rendering step is accomplished using a pbuffer, which is created through a combination of OpenGL's WGL_ARB_pbuffer, and WGL_ARB_pixel_format extensions. The second step of dynamic texture creation varies between the versions. Please see the implementation notes below for further information.

Version #1 - The dynamic texture is created by reading the pixel data out of the pbuffer with glReadPixels and then loading it into our texture with a regular call to glTexImage2D. This is by far the slowest way to create dynamic textures from a pbuffer.

Version #2 - In this version, we use wglShareLists to help out dynamic texture creation by sharing the window's rendering context with the pbuffer's context. With the two contexts sharing the same display list and texture space, we can simply load the texture with pixel data by calling glCopyTexSubImage2D. This is obviously faster than version #1, if you're willing to share contexts.

Version #3 - For our last version, we actually add a third extension, WGL_ARB_render_texture, and as the name implies, the extension basically lets us render directly to our dynamic texture. If the hardware supports it, this is the fastest method of creating dynamic textures from a pbuffer.

Relevant Keywords: WGL_ARB_pbuffer, WGL_ARB_pixel_format, WGL_ARB_render_texture, wglCreatePbufferARB, wglGetPbufferDCARB, wglReleasePbufferDCARB, wglDestroyPbufferARB, wglQueryPbufferARB, wglGetPixelFormatAttribivARB, wglGetPixelFormatAttribfvARB, wglChoosePixelFormatARB, wglBindTexImageARB, wglReleaseTexImageARB, wglSetPbufferAttribARB, wglGetExtensionsStringARB, wglGetProcAddress, glGenTextures, glBindTexture, glTexParameteri, glTexImage2D, glReadPixels, glCopyTexSubImage2D, WGL_SUPPORT_OPENGL_ARB, WGL_DRAW_TO_PBUFFER_ARB, WGL_BIND_TO_TEXTURE_RGBA_ARB, WGL_RED_BITS_ARB, WGL_GREEN_BITS_ARB, WGL_BLUE_BITS_ARB, WGL_ALPHA_BITS_ARB, WGL_DEPTH_BITS_ARB, WGL_DOUBLE_BUFFER_ARB, WGL_TEXTURE_FORMAT_ARB, WGL_TEXTURE_RGBA_ARB, WGL_TEXTURE_2D_ARB, WGL_PBUFFER_WIDTH_ARB, PFNWGLCREATEPBUFFERARBPROC, PFNWGLGETPBUFFERDCARBPROC, PFNWGLRELEASEPBUFFERDCARBPROC, PFNWGLDESTROYPBUFFERARBPROC, PFNWGLQUERYPBUFFERARBPROC, PFNWGLGETPIXELFORMATATTRIBIVARBPROC, PFNWGLGETPIXELFORMATATTRIBFVARBPROC, PFNWGLCHOOSEPIXELFORMATARBPROC, PFNWGLBINDTEXIMAGEARBPROC, PFNWGLRELEASETEXIMAGEARBPROC, and PFNWGLSETPBUFFERATTRIBARBPROC.

20

主题

86

帖子

91

积分

注册会员

Rank: 2

积分
91
发表于 2005-4-30 12:07:00 | 显示全部楼层

Re: 如何在指定窗口实现OpenGL?

上段文字中的例子1

sf_20054301277.zip

47.7 KB, 下载次数:

1

主题

12

帖子

14

积分

新手上路

Rank: 1

积分
14
 楼主| 发表于 2005-5-1 00:46:00 | 显示全部楼层

Re:如何在指定窗口实现OpenGL?

E文E文
你咋就这么头疼啊?
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-12-25 13:46

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表