在以下代码中,GL_INVALID_OPERATION
调用期间设置了glOrtho()
。我无法弄清楚为什么。你看到这些电话有什么问题吗?
#include <SDL2/SDL.h>
#include <GL/gl.h>
#include <iostream>
int main()
{
SDL_Init( 0 );
SDL_InitSubSystem( SDL_INIT_VIDEO );
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION, 1 );
SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION, 1 );
SDL_GL_SetAttribute( SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES );
SDL_GL_CreateContext
( SDL_CreateWindow
( "Test", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 1280, 768,
SDL_WINDOW_OPENGL ) );
glViewport( 0, 0, 1280, 768 );
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
std::cout << "No error: " << glGetError() << " ?= " << GL_NO_ERROR << '\n';
glOrtho( 0, 1280, 0, 768, -1, 0 );
std::cout << "Invalid operation: " << glGetError() << " ?= "
<< GL_INVALID_OPERATION << '\n';
return 0;
}
根据the documentation of glOrtho
,在glBegin()
和glEnd()
之间进行通话时会设置此错误,此处未调用此错误。在the documentation for GLES 1.1中,甚至没有记录此错误。
你知道发生了什么吗?