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

Author Topic: GL.GetString on SFML.NET  (Read 4506 times)

0 Members and 1 Guest are viewing this topic.

Kuinox

  • Newbie
  • *
  • Posts: 27
    • View Profile
GL.GetString on SFML.NET
« on: January 24, 2018, 07:38:44 pm »
Hi hi ! 
I'm using SFML.NET
I try to get the GPU Vendor name, using the examples on the github of the SFML.NET,  i did this:
Quote
MenuType choice = MenuType.Menu;
            Console.WriteLine("FullScreen Mode ? y/n");
            var answere = Console.ReadLine()?.ToLower();
            bool windowed = !(answere == "yes" || answere == "y");
            // Request a 24-bits depth buffer when creating the window
            ContextSettings contextSettings = new ContextSettings();
            contextSettings.DepthBits = 24;
            //Change true for window, false for fullscreen
            RenderWindow window;
            if (windowed)
            {
                window = new RenderWindow(VideoMode.FullscreenModes[2], "Vestige", Styles.Titlebar | Styles.Close);
            }
            else
            {
                window = new RenderWindow(VideoMode.FullscreenModes[0], "Vestige", Styles.Fullscreen);
            }
            Toolkit.Init();
            var context = new GraphicsContext(new ContextHandle(IntPtr.Zero), null);
            window.SetActive(true);
            Console.WriteLine("Vendor: " + GL.GetString(StringName.Version));
It throw: System.AccessViolationException on the GL.GetString, but i tried to do the same init that the one in the example.
Thanks ! 
EDIT: Only found now, he can't load the SDL2.dll , there was no SDL2.dll in the precompiled package Oo.
« Last Edit: January 24, 2018, 07:46:22 pm by Kuinox »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: GL.GetString on SFML.NET
« Reply #1 on: January 24, 2018, 08:56:02 pm »
Uhm SDL2.dll? This is the SFML forum not the SDL forum. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Kuinox

  • Newbie
  • *
  • Posts: 27
    • View Profile
Re: GL.GetString on SFML.NET
« Reply #2 on: January 24, 2018, 09:02:11 pm »
Yeah, i know, and i'm using SFML. This is my problem :D

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: GL.GetString on SFML.NET
« Reply #3 on: January 24, 2018, 09:04:54 pm »
GL.GetString is not an SFML function, so I'm really not sure what you're asking for here.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Kuinox

  • Newbie
  • *
  • Posts: 27
    • View Profile
Re: GL.GetString on SFML.NET
« Reply #4 on: January 24, 2018, 09:33:11 pm »
I'm trying to get the gpu vendor name. I'm using SFML, and i figured out i could get the vendor name with an OpenGL command, in this examples: https://github.com/SFML/SFML.Net/blob/master/examples/opengl/OpenGL.cs 
Because i'm using SFML.NET, the example use GL.FunctionName i simply found that there was a GL.GetString and i could ask for the vendor name. 
Also, the examples in the SFML.NET github doesnt work out of the box, you need to Add the references to a compiled libs, i don't know if it's intentional. 
EDIT: Okay, i can't even make the SFML.NET OpenGL working. 
I did something wrong in the references ?
« Last Edit: January 24, 2018, 10:03:49 pm by Kuinox »

Kuinox

  • Newbie
  • *
  • Posts: 27
    • View Profile
Re: GL.GetString on SFML.NET
« Reply #5 on: January 25, 2018, 12:25:29 am »
Couldnt make it work today, will try tomorrow, do you think there is an error in the examples ?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: GL.GetString on SFML.NET
« Reply #6 on: January 25, 2018, 12:56:32 am »
If you just want to figure out the OpenGL version used, you can also just get the ContextSettings from the RenderWindow and check the minor and major version.

As for using OpenGL in a .NET application. No idea really.

Seeing libsndfile in your project, makes me think that you're using an ancient SFML.NET version as libsndfile has been replaced quite a while back.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Kuinox

  • Newbie
  • *
  • Posts: 27
    • View Profile
Re: GL.GetString on SFML.NET
« Reply #7 on: January 25, 2018, 11:52:56 am »
So,
the lib is in the downlaod page of SFML.NET https://www.sfml-dev.org/download/sfml.net/
 
 
Also, i dont want the OpenGL version but the vendor name of the GPU, to help me figure out the problem on the other thread i did.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: GL.GetString on SFML.NET
« Reply #8 on: January 25, 2018, 12:20:02 pm »
Ah, yeah, we still haven't made a new release...
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Kuinox

  • Newbie
  • *
  • Posts: 27
    • View Profile
Re: GL.GetString on SFML.NET
« Reply #9 on: January 25, 2018, 01:45:06 pm »
Also, could you look at the examples in SFML.NET ? I couldn't make it work. I don't know what i need to do to make it work...

dabbertorres

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • website/blog
Re: GL.GetString on SFML.NET
« Reply #10 on: January 25, 2018, 05:21:38 pm »
SFML.NET is in the midst of an overhaul (see PR: https://github.com/SFML/SFML.Net/pull/143). Once that gets merged, I've been planning to do a run-thru/check-over of the examples and such (including compiling new binaries, finally).

As for being able to call glGetString, I'd do something like this with P/Invoke (Assuming Windows):
static class GL
{
    public enum PlatformInfo
    {
        Renderer = 0x1F01,
    }

    [DllImport("OpenGL32", EntryPoint = "glGetString", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi), SuppressUnmanagedCodeSecurity]
    private static extern unsafe byte* GetString(int name);

    public static string GetString(PlatformInfo pi)
    {
        IntPtr ptr;
        unsafe
        {
            byte* str = GetString((int)pi);
            ptr = new IntPtr(str);
        }
        return Marshal.PtrToStringAnsi(ptr);
    }
}

Kuinox

  • Newbie
  • *
  • Posts: 27
    • View Profile
Re: GL.GetString on SFML.NET
« Reply #11 on: January 25, 2018, 05:32:28 pm »
This is far ahead my level :D.   
So, the GL.GetString is actually not working ? 
The class you sended is a fix ? 
Thanks !

dabbertorres

  • Hero Member
  • *****
  • Posts: 505
    • View Profile
    • website/blog
Re: GL.GetString on SFML.NET
« Reply #12 on: January 25, 2018, 05:52:51 pm »
Theoretically it should work! I didn't have a chance to test it.

If it doesn't, report back with the errors and I'll fix it when I have the chance.

Kuinox

  • Newbie
  • *
  • Posts: 27
    • View Profile
Re: GL.GetString on SFML.NET
« Reply #13 on: January 26, 2018, 04:40:11 pm »
Thanks it work !
It solved partially problem i posted in another thread. Now i know the used GPU is the nvidia one, but, it make the intel usage increase.