- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我发现以下代码及其许多变体产生非空内存地址时,我感到非常惊讶。我尝试的变化包括:
glXGetProcAddressARB
而不是 glXGetProcAddress
. glfwGetProcAddress
.#include <GL/glx.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
void *ptr;
ptr = glXGetProcAddress((const GLubyte *)"glottis");
printf("ptr: %x\n", ptr);
return 0;
}
-lGL
编译(和
-lglfw
需要时)并且没有警告或错误。
0
的唯一途径输出,
NULL
指针,是通过询问名称不以
gl
开头的函数的地址,例如
manny
.
glottis
和
manny
应该同样不存在,我原以为两者都会产生
NULL
指针。
glXGetProcAddress
文档。
Notes
A NULL pointer is returned if function requested is not suported in the implementation being queried.
GLU functions are not queryable due to the fact that the library may not be loaded at the time of the query.
最佳答案
好吧,从正确性的角度来看,您观察到的行为是合规的。您不能断定非 NULL
glXGetProcAddress
的返回值(或其他)暗示该功能存在或可以使用。您必须始终查询扩展字符串。尝试获取扩展字符串未宣传的函数的函数指针(或上下文的核心 GL 版本暗示它的存在)在概念上将是未定义的行为。
您确实引用了 reference page on glXGetProcAddress
.不幸的是,这些引用页面是出了名的不精确、不完整,有时甚至是完全错误的。在这种情况下,措辞至少是不幸的。
我通常建议使用官方规范来查找此类详细信息。在这种情况下,GLX 1.4 specification将是相关文件。第 3.3.12 节“获取扩展函数指针”说明了有关 glXGetProcAddress
的内容(强调我的):
A return value of
NULL
indicates that the specified function does not exist for the implementation.A non-
NULL
return value forglXGetProcAddress
does not guarantee that an extension function is actually supported at runtime. The client must also queryglGetString(GL_EXTENSIONS)
orglXQueryExtensionsString
to determine if an extension is supported by a particular context. [...]
glXGetProcAddress
may be queried for all of the following functions:
- All GL and GLX extension functions supported by the implementation (whether those extensions are supported by the current context or not).
- All core (non-extension) functions in GL and GLX from version 1.0 up to and including the versions of those specifications supported by the implementation, as determined by
glGetString(GL_VERSION)
andglXQueryVersion
queries.
gl
开始的查询函数动态生成一些 stub 。 .
/src/mapi/glapi/glapi_getproc.c
揭示功能
_glapi_get_proc_address()
这样做:
/**
* Return pointer to the named function. If the function name isn't found
* in the name of static functions, try generating a new API entrypoint on
* the fly with assembly language.
*/
_glapi_proc
_glapi_get_proc_address(const char *funcName)
{
_glapi_proc func;
struct _glapi_function * entry;
init_glapi_relocs_once();
#ifdef MANGLE
/* skip the prefix on the name */
if (funcName[1] != 'g' || funcName[2] != 'l')
return NULL;
#else
if (funcName[0] != 'g' || funcName[1] != 'l')
return NULL;
#endif
/* search extension functions first */
func = get_extension_proc_address(funcName);
if (func)
return func;
/* search static functions */
func = get_static_proc_address(funcName);
if (func)
return func;
/* generate entrypoint, dispatch offset must be filled in by the driver */
entry = add_function_name(funcName);
if (entry == NULL)
return NULL;
return entry->dispatch_stub;
}
gl
前缀,如果函数未知,它会动态地为它创建一个 stub 。稍后,当加载硬件后端驱动程序时,它可能会注册 gl 函数,并且 stub 代码会将调用转发给驱动程序(如果它提供了实现)。
关于opengl - glXGetProcAddress 为以 "gl"开头的任何 procName 返回非空值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35118628/
2种参数:尺寸和价格。目前,我只能单击选择/突出显示尺寸列中的一个,也只能单击选择/突出显示价格列中的一个,而不会影响另一个列中的一个。 当我点击尺寸时,会添加一个 URL 参数“#size=4”。单
在css命名约定中,有什么原因,一些object最好以前缀o-和component开头> 以 c- 开头? 我知道 o- 代表 object 而 c- 代表 component,但为什么不呢?难道我们
这就很迷惑了,一下子,下面的代码就不行了。尝试让我的 Android 很好地显示网页已经显示的内容: HttpClient httpclient = new DefaultHttpClient();
我正在将我的网站发布到我无法控制的 IIS 服务器,我想从代码隐藏中了解它的 URL 是否以“http”或“https”开头。 首先,我在本地尝试了这两种解决方案,都返回了正确的值(“http”):
如果我运行: sbin/start-dfs.sh 然后它实际上并没有启动一个名称节点尽管打印: Starting namenodes on [0.0.0.0] 0.0.0.0: starting na
我正在开发一个包含一些数组的模块。现在我的数组包含: $omearray = array ( '#title' = 'title', 0 = array ( 'another array',
对于 PMD,我希望有一个规则来警告我那些以 my 开头的丑陋变量。 这意味着我必须接受所有不以my开头的变量。 所以,我需要一个正则表达式(re),其行为如下: re.match('myVar')
出于某种奇怪的原因,当我尝试使用 URLConnection 获取网页源时,我在输出中得到“null”。有人可以解释一下吗? 我的方法: public String getPageSource()
如何批量检查某个字符串(记录文本文件中的行)是否以特定单词开头? 我知道如何检查句子/行(字符串)中是否存在单词(子字符串),但我如何检查天气是否以这个词开头? 谢谢:) 最佳答案 这可以通过 FIN
我有一个列表,其中包含多个网址和一些字符串,例如#skipsideNav、#content。我正在从这些字符串中分离出 url if link.startswith('/'): local_u
我有以下 html 标记: 我想选择类 bubble bubble_white 和 bubble bubble_black。我正在考虑下面的代码,但它不起作用: $(".bubbl
我有一个用于文件名验证的正则表达式。在这里: /^[0-9a-zA-Z\^\&\'\@\{\}\[\]\,\$\=\!\-\#\(\)\.\%\+\~\_; ]+$/ 如何更改它以检查文件名不是以
我正在构建一个自动填充函数,它接受一个字符串输入并返回一个字符串建议列表。 Sequelize 的 iLike:query返回出现查询字符串的每个字符串。我想支持查询是前缀的字符串。例如当query=
我首先知道这可能是有史以来看起来最糟糕的正则表达式,但这里是。 我有这个正则表达式 (?:http://)?(?:www.)?youtu(?:be)?.(?:[a-z]){2,3}(?:[a-z/?=
尝试读取文件并根据行创建字典,跳过以#符号开头的行 文件示例: param1=val1 # here is comment 我的功能: def readFromFile(name): conf
我的程序正在读取文本文件并根据文本执行操作。但是文本的第一行是有问题的。显然它以“”开头。这弄乱了我的 startsWith() 检查。 为了理解这个问题,我使用了这段代码: System.ou
我的印象是变量名只能以字母和 _ 开头,但是在测试时,我还发现变量名可以以 $ 开头,如下所示: 代码 #include int main() { int myvar=13; int
我试过这个... Dim myMatches As String() = System.Text.RegularExpressions.Regex.Split(postRow.Item("Post")
开头
我正在使用CKEditor,默认情况下在内容的开头添加了。 即使将enterMode设置为,它也只会影响Enter键的作用,并保留开始的。 我遇到的问题是,如果文本以标记开头,它将围绕它包装,并且图像
我有一个List ,其中有五个字符串: abc def ghi jkl mno 我还有另一个字符串“pq”,我需要知道列表中的每个字符串是否都不以“pq”开头-我将如何使用LINQ(.NET 4.0)
我是一名优秀的程序员,十分优秀!