SFML community forums
Help => Graphics => Topic started by: Astrof on June 14, 2009, 05:58:47 am
-
I tried to do a simple test using SFML 2.0,
sf::RenderWindow Window(sf::VideoMode(800, 600, 32), "O hai");
sf::Shape Rect=sf::Shape::Rectangle(50,50,200,100,sf::Color::White);
// Start game loop
while (Window.IsOpened())
{
// Process events
sf::Event Event;
while (Window.GetEvent(Event))
{
// Close window : exit
if (Event.Type == sf::Event::Closed)
Window.Close();
}
// Clear the screen (fill it with black color)
Window.Clear();
Window.Draw(Rect);
// Display window contents on screen
Window.Display();
}
and I got an access violation exception (something to do with OpenGL state or something). I tried the code with the SVN trunk version and everything worked fine.
Basically my question is, How usable is SFML 2.0 / when should we be able to essentially "beta test" it?
-
Can you try revision 1136? Or disabling alpha-blending on the rect, with the current revision? If it helps, then what's your configuration (GPU, OS)?
Basically my question is, How usable is SFML 2.0 / when should we be able to essentially "beta test" it?
It is, I try to commit a new feature only when there's no major bug about it.
You are strongly encouraged to beta-test every new feature :)
-
If I set the blend mode to None it works perfectly. Also if I use a custom View it seems to work well.
The problem seems to be at this point:
switch (myBlendMode)
{
case Blend::Alpha :
GLCheck(glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ONE_MINUS_SRC_ALPHA));
break;
case Blend::Add :
GLCheck(glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE, GL_ONE, GL_ONE_MINUS_SRC_ALPHA));
break;
case Blend::Multiply :
GLCheck(glBlendFuncSeparate(GL_DST_COLOR, GL_ZERO, GL_ONE, GL_ONE_MINUS_SRC_ALPHA));
break;
default :
break;
}
But again if I use a custom view it works fine. Without a custom view only None seems to work.
I'm using revision 1139, OS is Windows 7, GPU is nvidia 800GTS.
EDIT: Okay, this is really weird, it works if I have sprites in the code somewhere (even if I don't draw them) but doesn't work if I edit an existing piece of code to match the change...
EDIT AGAIN: if I add:
sf::Image Image;
if(!Image.LoadFromFile("Ship.png"))
return 1;
to the code after I create the Rect, it works, I remove this piece of code and it breaks. I tried to see if putting any code would work (an empty for loop, a cout/cin statement, etc) but only using the Image does it somehow do something to make it work[/code]
-
Ok it seems to be what I was thinking about. Just a final test: can you try calling PostFx::CanUsePostFx() before drawing your shape?
-
Okay, I tried that and, just like using the image, if I put the code
std::cout<<sf::PostFX::CanUsePostFX()<<std::endl;
it works (and returns 1). If I comment out the code then it doesn't work. Could there be a setting that isn't set unless some (other) graphical command is called (like creating an Image or asking if PostFX is available)?
-
Absolutely.
Actually, I was aware of a potential problem with glBlendFuncSeparate and I was waiting for feedback. That was faster than I thought (I added the function yesterday) :)
The problem is that glBlendFuncSeparate is part of OpenGL 1.4. Unfortunately, on Windows the OpenGL headers are 1.1 so you have to use this function as an extension. But to use an extension, SFML first needs to have GLEW initialized ; that's what PostFx or Image do.
I've updated the code, it should work fine now.
-
Ah, yeah it works flawlessly now. Is there a way to update the headers?
-
No. The Windows implementation is 1.1 and it seems that it will never change.
-
Hmm that's stupid... ah well I guess using extensions still work. Thanks for fixing it so quickly!