• GL_INVALID_OPERATION in glEnd Killrazor

    I'm having problems drawing a simple sprite. When I draw:

    void CSprite2D::render()
                CHECKGL(glTexCoord2f(m_textureAreaStart.s,m_textureAreaStart.t)); // 0,0 by default
                CHECKGL(glTexCoord2f(m_textureAreaEnd.s,m_textureAreaStart.t)); // 1,0 by default
                CHECKGL(glVertex3i( m_position.x + m_dimensions.x, m_position.y, 0));   
                CHECKGL(glTexCoord2f(m_textureAreaEnd.s, m_textureAreaEnd.t)); // 1,1 by default
                CHECKGL(glVertex3i( m_position.x + m_dimensions.x, m_position.y + m_dimensions.y, 0));      
                CHECKGL(glTexCoord2f(m_textureAreaStart.s, m_textureAreaEnd.t));  // 0,1 by default
                CHECKGL(glVertex3i( m_position.x, m_position.y + m_dimensions.y,0));

    I'm always get an GL_INVALID_OPERATION in glEnd(). I suspect that error is not here, but I can't detect where may be. Actually, the output render seems ok. But I want to solve this situation before to catch a subtle bug tomorrow.

    Any idea of what could be

  • My guess is your CHECKGL macro is calling glGetError between a glBegin/glEnd, which is not one of the defined functions that can be called.

c++ opengl textures
Related questions and answers
  • ; outside that space, white is drawn. Here is my OpenGL init code... SDL_SetVideoMode(windowWidth, windowHeight, 16, SDL_HWSURFACE|SDL_GL_DOUBLEBUFFER|SDL_OPENGL); glClearColor(0, 0, 0, 0); glClearDepth(1.0f); glViewport(0, 0, windowWidth, windowHeight); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, windowWidth, windowHeight, 0, 1, -1); glMatrixMode(GL_MODELVIEW); glEnable(GL_TEXTURE_2D); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glLoadIdentity(); is my image loading function... SDL_Surface *loadImage (const char *filename, bool alpha = true) { SDL_Surface

  • ) glEnable (GL_BLEND); // Enable Blending ( NEW ) glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); // Set The Blend Mode ( NEW ) glPolygonMode (GL...); // Set The Color Of The Model ( NEW ) // ORIGINAL DRAWING CODE //Draw the model as an interpolation between the two frames glBegin(GL_TRIANGLES); for(int i = 0; i... ) glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); // Set The Blend Mode ( NEW ) glPolygonMode (GL_BACK, GL_LINE); // Draw Backfacing Polygons As Wireframes ( NEW

  • I'm using vertex array to draw 2d geometry, but I can't achieve smoothness. This is the code I'm using: glEnableClientState(GL_COLOR_ARRAY); glEnableClientState(GL_VERTEX_ARRAY); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); glColorPointer(4, GL_UNSIGNED_BYTE, 0, shared_colors); glVertexPointer(3, GL_FLOAT, 0, shared_vertex); glDrawArrays(GL_LINES, 0, shared_counter); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_COLOR_ARRAY); glDisable(GL_BLEND); Some advice?

  • (); glOrtho(0, Width, Height, 0, -1, 1); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); Just in-case, here's my image loading code, I think that perhaps this may be were the problem lies somehow... tile being rendered, but I'm getting a blurred mess :S. My rendering code: glBindTexture(GL_TEXTURE_2D, texture); float texscale = 1.0f / (float)tileWidth; sourceX = sourceX / (float)tileSheetWidth..., texscale + sourceY); glVertex2i(x, y + tileHeight); glEnd(); glLoadIdentity(); My initialization code for OpenGL: // Set the OpenGL state after creating the context with SDL_SetVideoMode glClearColor(0

  • ); glEnable(GL_BLEND); // enable read-only depth buffer glDepthMask(GL_FALSE); // set the blend function to what we use for transparency glBlendFunc(GL_SRC_ALPHA, GL_ONE); // set back to normal depth...i wanna walk to terrain... first i created the terrain void desenha_terreno(float px, float pz){ for (int z = 0; z < iwidth-1; z++) { glBegin(GL_TRIANGLE_STRIP); for (int x = 0; x <..., 1.0f); glVertex3f(terreno[x+1][z+1][0], terreno[x+1][z+1][1], terreno[x+1][z+1][2]); } glEnd(); } } I can move the camera with the functions: void keyboard (unsigned char key, int

  • _aspect = (float)win_width / (float)win_height; glViewport(0, 0, win_width, win_height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(90, win_aspect, 1, 100.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(0, 0, 30.0, 0, 0, 0, 0.0, 1.0, 0.0); glEnable(GL_DEPTH); glEnable(GL_DEPTH_TEST); glEnable(GL_COLOR_MATERIAL); glEnable(GL_NORMALIZE); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_LIGHT1); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glColor3f(0.0f, 0.0f, 0.0f); int vertexIndex = 0, normalIndex; glRotatef(90, 0, 1, 0); glPushMatrix(); for(int

  • (); // push 3 glTranslatef(0,0,height); // spherical texture generation // this piece of code doesn't work as I intended glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_T); GLUquadric *tub = gluNewQuadric(); gluQuadricTexture(tub, GL_TRUE); gluDisk(tub...I'm trying to map a brick texture on the edge of a fountain and I'm using gluDisk for that. How can I make the right coordinates for the disk? My code looks like this and I have only found a function

  • with DevIL, and glGetString(GL_VENDOR) is returning "NVidia Corporation". Any ideas? I'm sorry to be dumping all the code, but I've got absolutely no idea at all what is doing it. I'm very new..._GL_ALPHA_SIZE, 8); SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_HWSURFACE | SDL_OPENGL); glEnable(GL_TEXTURE_2D); const GLubyte * Vendor = glGetString(GL_VENDOR); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // Clear the background of our window to red glMatrixMode (GL_PROJECTION); glLoadIdentity (); glOrtho(0, XSIZE, YSIZE, 0, 0, 1

  • for post fboSetup = true; } Here is the render code: //start rendering to FBO if(postFlag&&fboSetup) { glBindFramebuffer(GL_FRAMEBUFFER, fboHandle); } glUseProgram(programHandle...(mats.mvHandle,1,GL_FALSE,glm::value_ptr(mats.modelViewMatrix)); //bind to vertex array object glBindVertexArray(vaoHandle); //render scene glDrawArrays(GL_TRIANGLES, 0, 240*3 ); //do post-processing...); glDrawArrays(GL_TRIANGLES, 0, 6); glBindTexture(GL_TEXTURE_2D, 0); } Tried everything I can think of or find in a FBO tutorial or have read about. I don't get any errors and it returns as complete

Data information