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

Author Topic: SFML 2.0 Drawing doesn't work  (Read 4324 times)

0 Members and 1 Guest are viewing this topic.

Astrof

  • Full Member
  • ***
  • Posts: 135
    • View Profile
SFML 2.0 Drawing doesn't work
« on: June 14, 2009, 05:58:47 am »
I tried to do a simple test using SFML 2.0,
Code: [Select]

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?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
SFML 2.0 Drawing doesn't work
« Reply #1 on: June 14, 2009, 08:03:07 am »
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)?

Quote
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 :)
Laurent Gomila - SFML developer

Astrof

  • Full Member
  • ***
  • Posts: 135
    • View Profile
SFML 2.0 Drawing doesn't work
« Reply #2 on: June 14, 2009, 08:19:51 am »
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:
Code: [Select]

 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:
Code: [Select]

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]

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
SFML 2.0 Drawing doesn't work
« Reply #3 on: June 14, 2009, 08:31:32 am »
Ok it seems to be what I was thinking about. Just a final test: can you try calling PostFx::CanUsePostFx() before drawing your shape?
Laurent Gomila - SFML developer

Astrof

  • Full Member
  • ***
  • Posts: 135
    • View Profile
SFML 2.0 Drawing doesn't work
« Reply #4 on: June 14, 2009, 08:38:43 am »
Okay, I tried that and, just like using the image, if I put the code
Code: [Select]
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)?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
SFML 2.0 Drawing doesn't work
« Reply #5 on: June 14, 2009, 08:47:23 am »
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.
Laurent Gomila - SFML developer

Astrof

  • Full Member
  • ***
  • Posts: 135
    • View Profile
SFML 2.0 Drawing doesn't work
« Reply #6 on: June 14, 2009, 08:59:57 am »
Ah, yeah it works flawlessly now.  Is there a way to update the headers?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
SFML 2.0 Drawing doesn't work
« Reply #7 on: June 14, 2009, 12:44:58 pm »
No. The Windows implementation is 1.1 and it seems that it will never change.
Laurent Gomila - SFML developer

Astrof

  • Full Member
  • ***
  • Posts: 135
    • View Profile
SFML 2.0 Drawing doesn't work
« Reply #8 on: June 14, 2009, 07:59:56 pm »
Hmm that's stupid... ah well I guess using extensions still work.  Thanks for fixing it so quickly!