Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/144.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何在opengl中使用纹理?(无效操作错误:1282)_C++_Opengl_Textures - Fatal编程技术网

C++ 如何在opengl中使用纹理?(无效操作错误:1282)

C++ 如何在opengl中使用纹理?(无效操作错误:1282),c++,opengl,textures,C++,Opengl,Textures,我是opengl新手,目前正在尝试处理纹理。每当调用glTextureParameteri()时,我总是收到错误1282(无效操作)。据我所知,每一个资源都是以同样的方式编写的。这就是给我带来麻烦的代码片段 ImageLoader image("res/Textures/test.bmp"); GLuint texture; glGenTextures(1, &texture); glBindTexture(GL_TEXTU

我是opengl新手,目前正在尝试处理纹理。每当调用glTextureParameteri()时,我总是收到错误1282(无效操作)。据我所知,每一个资源都是以同样的方式编写的。这就是给我带来麻烦的代码片段

        ImageLoader image("res/Textures/test.bmp");
        GLuint texture;
        glGenTextures(1, &texture);
        glBindTexture(GL_TEXTURE_2D, texture);
        glTextureParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
        glTextureParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image.getWidth(), image.getHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, image.getPixels());
        glBindTexture(GL_TEXTURE_2D, 0);

错误代码显示在带有glTextureParameteri()的行上。我这样做的方式有什么无效/错误?

函数的第一个参数是纹理句柄,而不是纹理目标。您使用的参数似乎用于
glTexParameter
函数。这两个函数不同,因此您可以使用另一个函数或更改参数。

仅从OpenGL4.5开始列出此函数。您正在运行此程序的系统是否支持它?@VTT是。我有一个最近更新的gtx 1060,我刚刚检查了一下,我写的程序正在opengl4.6.0中运行,我刚刚检查了旧的函数glTexParameteri(),这看起来确实有效