我必须使用OpenGL数据类型(GLint,CLchar,...)的跨平台游戏吗? [英] Do I have to use the OpenGL data types (GLint, CLchar, ...) for a cross platform game?

查看:300
本文介绍了我必须使用OpenGL数据类型(GLint,CLchar,...)的跨平台游戏吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简短的问题。为什么OpenGL会为标准类型(如int,unsigned int,char等)提供自己的数据类型?

I have a short question. Why does OpenGL come with its own datatypes for standard types like int, unsigned int, char, and so on? And do I have to use them instead of the build in C++ datatypes?

例如,OpenGL等价于 unsigned int GLuint ,对于ac字符串,有 GLchar * ,而不是 char *

For example the OpenGL equivalent to unsigned int is GLuint and for a c string there is GLchar* instead of char*.

推荐答案


例如,OpenGL等价于 int GLuint

GLuint 不等同于 unsigned int GLuint 需要 大小为32位。总是大小为32位。 unsigned int 可能大小为32位。它可能是64位。你不知道,C不会告诉你( sizeof 之外)。

GLuint is not "equivalent" to unsigned int. GLuint is required to be 32 bits in size. It is always 32-bits in size. unsigned int might be 32-bits in size. It might be 64-bits. You don't know, and C isn't going to tell you (outside of sizeof).

将为每个平台定义数据类型,并且可以针对不同平台以不同方式定义它们。你使用它们是因为,即使它们的定义不同,它们总是会出现相同的大小。 OpenGL API期望和需要的大小。

These datatypes will be defined for each platform, and they may be defined differently for different platforms. You use them because, even if they are defined differently, they will always come out to the same sizes. The sizes that OpenGL APIs expect and require.

这篇关于我必须使用OpenGL数据类型(GLint,CLchar,...)的跨平台游戏吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆