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

Author Topic: OpenTK and SFML  (Read 5537 times)

0 Members and 1 Guest are viewing this topic.

Chris12

  • Newbie
  • *
  • Posts: 20
    • View Profile
OpenTK and SFML
« on: November 11, 2012, 11:50:42 pm »
Hi there. Got SFML working with OpenTK.
I understand that me messing with the openGL context will disturb SFML in its functionality.
Thats why one should use PushGLStates / PopGLStates.
I read the tutorial and the documentation, but somehow it's still not 100% clear to me.

I have a few questions.

1.) Should I enclose my code with Push/PopGlStates, or should I enclode the SFML drawing code with it?
Is there even a difference?

2.) When should ResetGlStates be used? Can it replace the above functions?

3.) Is this the correct way to make openTK aware of SFML: ?

static void Main(string[] args)
                {
                        RenderWindow = new RenderWindow(new SFML.Window.VideoMode(800, 450), "Title", SFML.Window.Styles.Close);

                        var wi = OpenTK.Platform.Utilities.CreateWindowsWindowInfo(RenderWindow.SystemHandle);
                        var ctx = new OpenTK.Graphics.GraphicsContext(OpenTK.Graphics.GraphicsMode.Default, wi);
                        ctx.MakeCurrent(wi);
                        ctx.LoadAll();

                        ...
                }
 

Isn't there a way to get the GlContext from the "RenderWindow" class directly??
« Last Edit: November 12, 2012, 12:39:16 am by Chris12 »

eigenbom

  • Full Member
  • ***
  • Posts: 228
    • View Profile
Re: OpenTK and SFML
« Reply #1 on: November 12, 2012, 05:52:42 am »
1. I would keep SFML's state as the default, which means surrounding your Tk graphics calls with a push/pop.
2. Never used it, but as you should always push/pop you'll probably never need it


Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: OpenTK and SFML
« Reply #2 on: November 12, 2012, 08:07:07 am »
Quote
1.) Should I enclose my code with Push/PopGlStates, or should I enclode the SFML drawing code with it?
Is there even a difference?

2.) When should ResetGlStates be used? Can it replace the above functions?
Everything is explained in the API documentation. If SFML.Net's doc is not up-to-date/complete, look at SFML's doc.

Quote
Isn't there a way to get the GlContext from the "RenderWindow" class directly??
No. But in C++ (with WGL/GLX/AGL) there's a function to get the current context. I don't know if you can access this kind of function in .Net, and if you can make something useful of the returned low-level context.
Laurent Gomila - SFML developer