Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: GL_INVALID_ENUM in renderwindow.cpp  (Read 11506 times)

0 Members and 2 Guests are viewing this topic.

tno

  • Newbie
  • *
  • Posts: 9
    • View Profile
GL_INVALID_ENUM in renderwindow.cpp
« on: April 25, 2008, 12:07:32 am »
Hi there,

we are two guys working for the first time with SFML.

After we have implemented some stuff to our upcoming game (in OpenGL), we've got an mysterious error that we can't narrow down.
Quote

An internal OpenGL call failed in renderwindow.cpp (234) : GL_INVALID_ENUM, an unacceptable value has been specified for an enumerated argument.


U can see where it appears. We checked the line at the SRC of SFML and dont unterstand why we get it there. The only thing we know now is that the light class, which we have implemented, might cause the error.

Someone else maybe has got this error and can help us?

We would appreciate any help, thx!

-tno

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
GL_INVALID_ENUM in renderwindow.cpp
« Reply #1 on: April 25, 2008, 02:56:34 am »
Can you show that line 234 ? Or at least tell us which version of SFML you're using ?
Laurent Gomila - SFML developer

dreimalbla

  • Newbie
  • *
  • Posts: 6
    • View Profile
GL_INVALID_ENUM in renderwindow.cpp
« Reply #2 on: April 25, 2008, 03:26:43 am »
hi,
we're using version 1.2

void RenderWindow::OnDisplay()
{
// Find which buffers we must clearGLbitfield ClearBits = GL_COLOR_BUFFER_BIT;
if (GetDepthBits() > 0) ClearBits |= GL_DEPTH_BUFFER_BIT;
if (GetStencilBits() > 0) ClearBits |= GL_STENCIL_BUFFER_BIT;
// Clear the color/depth/stencil buffers for next frame
line 234 --> GLCheck(glClearColor(myBackgroundColor.r / 255.f,
myBackgroundColor.g / 255.f,
myBackgroundColor.b / 255.f,
myBackgroundColor.a / 255.f));
GLCheck(glClear(ClearBits));
}

thanks for your help

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
GL_INVALID_ENUM in renderwindow.cpp
« Reply #3 on: April 25, 2008, 05:59:30 am »
GL_INVALID_ENUM returned by glClearColor ? That's weird...

Can you also show the part of your code which generates this error ?
Laurent Gomila - SFML developer

dreimalbla

  • Newbie
  • *
  • Posts: 6
    • View Profile
GL_INVALID_ENUM in renderwindow.cpp
« Reply #4 on: April 25, 2008, 08:09:15 pm »
That's the problem. We can not specify where the error occurs. We've disabled our light class and now the error occurs after closing the window, but only when closing it with a mouse-click on the X at the right top corner. It doesn't occur when pressing "Esc".


Code: [Select]
while (appWindow::Instance().getEvent(Event))
    {
        // Close window : exit
        if (Event.Type == sf::Event::Closed)
            running = false;

        // Escape key : exit
        if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
       running = false;
    }


In Debug Mode it seems to happen before he gets to the first IF.??

tno

  • Newbie
  • *
  • Posts: 9
    • View Profile
GL_INVALID_ENUM in renderwindow.cpp
« Reply #5 on: April 26, 2008, 05:30:53 pm »
again here some news:

We have a main class, a render class and a AppWindow class (this class we did make on purpose because we need access from some other classes too).

In the main class we call "AppWindow Init" which executes this code:
Code: [Select]
App.Create(sf::VideoMode(width, height), "Title"/*, sf::Style::Fullscreen*/);
App.SetCursorPosition(getWidth()/2, getHeight()/2);

and next in the main class again the Render.initGL function is called which executes some GL Stuff like Depth_Test, Lighting and Texture enable, Smooth Shading, etc... and also this 2 lines:
Code: [Select]
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glEnable(GL_PERSPECTIVE_CORRECTION_HINT);


If we now disable the 2 lines with comments then the INVALID Error disappears, we dont know why but maybe this gives you an idea, Laurent?

A Screenshot of the Error:



-tno

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
GL_INVALID_ENUM in renderwindow.cpp
« Reply #6 on: April 26, 2008, 05:58:30 pm »
Absolutely no idea. This stuff still doesn't make any sense to me.
Laurent Gomila - SFML developer

tno

  • Newbie
  • *
  • Posts: 9
    • View Profile
GL_INVALID_ENUM in renderwindow.cpp
« Reply #7 on: April 26, 2008, 06:25:51 pm »
damn.

But i was searching a lil bit in the forum and found the same problem in another thread but the solution isn't described ... :(

I will write him a PM to post his solution.

Hope he sees that.

http://www.sfml-dev.org/forum/viewtopic.php?t=195

So long, tno

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
GL_INVALID_ENUM in renderwindow.cpp
« Reply #8 on: April 26, 2008, 06:41:09 pm »
Let us know if you get any reply :P
Laurent Gomila - SFML developer

tno

  • Newbie
  • *
  • Posts: 9
    • View Profile
GL_INVALID_ENUM in renderwindow.cpp
« Reply #9 on: April 26, 2008, 07:07:52 pm »
Shoot!!!

I think i have figured out what caused the error by myself and thankfully to the tutorial at SFML Website, which i haven't read until now.

http://www.sfml-dev.org/tutorials/window-opengl.php

Instead of using a
Code: [Select]
RenderWindow i am now using a
Code: [Select]
Window in the Code.

The following include :
Code: [Select]
#include <SFML/Graphics.hpp>
is replaced by those includes:
Code: [Select]
#include <SFML/Window.hpp>
#include <GL/gl.h>
#include <GL/glu.h>


I didn't see it all this time!!


Hope this here helps anyone else who CAN'T READ the tutorials right!! :(

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
GL_INVALID_ENUM in renderwindow.cpp
« Reply #10 on: April 26, 2008, 07:31:09 pm »
So the problem is not solved, it's just that you are no longer using the graphics part of SFML, which contains the error ;)
Laurent Gomila - SFML developer

tno

  • Newbie
  • *
  • Posts: 9
    • View Profile
GL_INVALID_ENUM in renderwindow.cpp
« Reply #11 on: April 26, 2008, 07:47:08 pm »
hmmm ....thats right, but we are using only openGL stuff to draw so therefor it is clear that this wouldn't work fine with the graphics package... or, do i missunderstand sth here?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
GL_INVALID_ENUM in renderwindow.cpp
« Reply #12 on: April 26, 2008, 08:26:45 pm »
The graphics package is designed to be able to be mixed with external OpenGL code. In your case using sf::Window is cleaner, but sf::RenderWindow is supposed to work as well.
Laurent Gomila - SFML developer

Redien

  • Newbie
  • *
  • Posts: 30
    • View Profile
GL_INVALID_ENUM in renderwindow.cpp
« Reply #13 on: April 27, 2008, 01:58:36 am »
The source of the GL_INVALID_ENUM error was probably this line of code:

Code: [Select]
glEnable(GL_PERSPECTIVE_CORRECTION_HINT);

glEnable does not define any GL_PERSPECTIVE_CORRECTION_HINT enum and thus generates the error. http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/enable.html

And that would explain why commenting out those lines removed the error. ;)

MrDoomMaster

  • Newbie
  • *
  • Posts: 26
    • View Profile
GL_INVALID_ENUM in renderwindow.cpp
« Reply #14 on: April 27, 2008, 05:40:22 am »
@tno

Please do not spam random people through PM's and direct them to your threads for help. This is not appropriate behavior.

 

anything