OpenGL 视频 RAM 限制

发布于 2024-08-28 08:19:46 字数 137 浏览 1 评论 0原文

我一直在尝试制作一个跨平台的2D网络游戏,我的地图是由瓷砖组成的。 我渲染图块的图块集相当巨大。 我想知道如何禁用硬件渲染,或者至少使其更强大。 因此,我想知道视频内存的基本限制是什么,据我所知,Direct3D 有纹理大小限制(我指的不是二次纹理大小的幂)。

I have been trying to make a Cross-platform 2D Online Game, and my maps are made of tiles.
My tileset, which I render the tiles from, is quite huge.
I wanted to know how can I disable hardware rendering, or at least making it more capable.
Hence, I wanted to know what are the basic limits of the video ram, as far as I know, Direct3D has a texture size limits (by that I don't mean the power-of-two texture sizes).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

柳絮泡泡 2024-09-04 08:19:46

如果您想使用软件渲染器,请链接到 Mesa

您可以使用这些方法来估计最大纹理大小

21.130 我的设备将渲染硬件加速的纹理贴图的最大尺寸是多少?

良好的 OpenGL 实现将尽可能使用硬件加速进行渲染。然而,该实现可以自由地不渲染硬件加速。 OpenGL 不提供机制来确保应用程序正在使用硬件加速,也不提供查询应用程序是否正在使用硬件加速的机制。考虑到这些信息,以下内容可能仍然有用:

您可以通过以下调用获取您的实现支持的最大纹理大小的估计:

GLint texSize;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &texSize);

如果您的纹理未进行硬件加速,但仍在 GL_MAX_TEXTURE_SIZE 返回的大小限制内,则它仍应正确渲染。

这只是一个估计,因为 glGet*() 函数不知道您将用于任何给定纹理的格式、内部格式、类型和其他参数。 OpenGL 1.1 及更高版本通过允许纹理代理解决了这个问题。

这是使用纹理代理的示例:

glTexImage2D(GL_PROXY_TEXTURE_2D,级别,internalFormat,宽度,高度,边框,格式,类型,NULL);

请注意,像素参数为 NULL,因为当目标参数为 GL_PROXY_TEXTURE_2D 时,OpenGL 不会加载纹理元素数据。相反,OpenGL 仅考虑它是否可以容纳指定大小和描述的纹理。如果无法容纳指定的纹理,则纹理的宽度和高度值将设置为零。进行纹理代理调用后,您需要按如下方式查询这些值:

GLint 宽度;
glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &宽度);

如果(宽度==0){
   /* 不能使用该纹理 */
}

If you want to use a software renderer, link against Mesa.

You can get an estimate of the maximum texture size using these methods:

21.130 What's the maximum size texture map my device will render hardware accelerated?

A good OpenGL implementation will render with hardware acceleration whenever possible. However, the implementation is free to not render hardware accelerated. OpenGL doesn't provide a mechanism to ensure that an application is using hardware acceleration, nor to query that it's using hardware acceleration. With this information in mind, the following may still be useful:

You can obtain an estimate of the maximum texture size your implementation supports with the following call:

GLint texSize;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &texSize);

If your texture isn't hardware accelerated, but still within the size restrictions returned by GL_MAX_TEXTURE_SIZE, it should still render correctly.

This is only an estimate, because the glGet*() function doesn't know what format, internalformat, type, and other parameters you'll be using for any given texture. OpenGL 1.1 and greater solves this problem by allowing texture proxy.

Here's an example of using texture proxy:

glTexImage2D(GL_PROXY_TEXTURE_2D, level, internalFormat, width, height, border, format, type, NULL);

Note the pixels parameter is NULL, because OpenGL doesn't load texel data when the target parameter is GL_PROXY_TEXTURE_2D. Instead, OpenGL merely considers whether it can accommodate a texture of the specified size and description. If the specified texture can't be accommodated, the width and height texture values will be set to zero. After making a texture proxy call, you'll want to query these values as follows:

GLint width;
glGetTexLevelParameteriv(GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &width);

if (width==0) {
   /* Can't use that texture */
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文