giawa / opengl4csharp

OpenGL 4 Bindings (partially based on OpenTK) for C#
Other
232 stars 61 forks source link

Adding Windows code to Gl class #59

Closed ghost closed 4 years ago

ghost commented 4 years ago

I want to add WGL/GDI/User32 code to the Gl class, separated by a conditional symbol, ISWINDOWS, so that you can create an OpenGL window without having to use someone else's context. Inside of OpenGL.Platform or the OpenGL.Constructs folder, we could add a default Win32 context window. Other people would have to add GLX/CGL for Mac/Linux support, as I don't have a Mac or Linux system to test it on.

What do you think of me adding it and making a pull request? I want to see what you guy's think of it before I take the effort to write it.

giawa commented 4 years ago

I'll let @TheAIBot check in as well, but I'll talk a bit about a mistake I think I made with this code, and my thoughts on what could/should be done in the future regarding it. I think it was a mistake for me to include the OpenGL.Platform code in the same repo as OpenGL. I think each namespace should have had its own repo, allowing someone to only bring in the parts of OpenGL they wanted. I'm curious if other people would agree with me on this. Is it common to have multiple dlls generated by the same repo? Perhaps it isn't an issue at all.

I see this repo as being a way to have simple to use (and safe) bindings to modern OpenGL 4+, and the Platform code was only there to help someone get up and running easily with SDL. Adding more WGL/etc code will further move the codebase towards something other than a simple OpenGL library. So my knee jerk reaction is to suggest that we create a new repo for this type of code, and then link to it from the README of opengl4csharp.

However, this is very much an open dialogue. I'm not 100% sure what the right answer is. I've seen some OpenGL libraries contain everything and the kitchen sink (which I sort of don't want to do, but maybe we need to swing that way). Let me know what you think.

ghost commented 4 years ago

I'll let @TheAIBot check in as well, but I'll talk a bit about a mistake I think I made with this code, and my thoughts on what could/should be done in the future regarding it. I think it was a mistake for me to include the OpenGL.Platform code in the same repo as OpenGL. I think each namespace should have had its own repo, allowing someone to only bring in the parts of OpenGL they wanted. I'm curious if other people would agree with me on this. Is it common to have multiple dlls generated by the same repo? Perhaps it isn't an issue at all.

I see this repo as being a way to have simple to use (and safe) bindings to modern OpenGL 4+, and the Platform code was only there to help someone get up and running easily with SDL. Adding more WGL/etc code will further move the codebase towards something other than a simple OpenGL library. So my knee jerk reaction is to suggest that we create a new repo for this type of code, and then link to it from the README of opengl4csharp.

However, this is very much an open dialogue. I'm not 100% sure what the right answer is. I've seen some OpenGL libraries contain everything and the kitchen sink (which I sort of don't want to do, but maybe we need to swing that way). Let me know what you think.

Since OS-specific code like that is so commonly used, I don't think it would move the codebase towards something other than a simple OpenGL library, and I think it would be better to integrate it into the same repository, even though it would not hurt to make another repository for it. I am fine with it either way, but I would prefer it in one repository and DLL, since this type of code is used so much. Also, I agree with moving OpenGL.Platform into it's own repository, as it is labeled as an 'extension' of the main library, and OpenGL.UI is in it's own repository.

TheAIBot commented 4 years ago

WGL/GDI/User32

Honestly i don't know much about these and why one would use them over something like SDL. Window handling stuff is really not my forte.

I see this repo as being a way to have simple to use (and safe) bindings to modern OpenGL 4+

I really agree with this. The main reason that i am using this project is because it's easy to setup and use.

The fact that you only have to write(taken from the readme)

using OpenGL;
using OpenGL.Platform;
using System;

namespace OpenGLTest
{
    class Program
    {
        static void Main(string[] args)
        {
            OpenGL.Platform.Window.CreateWindow("OpenGL", 1280, 720);

            while (OpenGL.Platform.Window.Open)
            {
                OpenGL.Platform.Window.HandleEvents();
                OnRenderFrame();
            }
        }
        static void OnRenderFrame()
        {
            // do OpenGL draw stuff here
        }
    }
}

before you can write OpenGL code is a really awesome thing. Personally i don't want to chose which window manager i use, i just want it to be easy to use.

I am not saying that there shouldn't be other options but if we do it then we should preserve the simple, easy, crossplatform option that the project currently has.

ghost commented 4 years ago

WGL/GDI/User32

Honestly i don't know much about these and why one would use them over something like SDL. Window handling stuff is really not my forte.

I see this repo as being a way to have simple to use (and safe) bindings to modern OpenGL 4+

I really agree with this. The main reason that i am using this project is because it's easy to setup and use.

The fact that you only have to write(taken from the readme)

using OpenGL;
using OpenGL.Platform;
using System;

namespace OpenGLTest
{
  class Program
  {
      static void Main(string[] args)
      {
          OpenGL.Platform.Window.CreateWindow("OpenGL", 1280, 720);

          while (OpenGL.Platform.Window.Open)
          {
              OpenGL.Platform.Window.HandleEvents();
              OnRenderFrame();
          }
      }
      static void OnRenderFrame()
      {
          // do OpenGL draw stuff here
      }
  }
}

before you can write OpenGL code is a really awesome thing. Personally i don't want to chose which window manager i use, i just want it to be easy to use.

I am not saying that there shouldn't be other options but if we do it then we should preserve the simple, easy, crossplatform option that the project currently has.

I am adding three symbols: ISWINDOWS, ISMACOS, and ISLINUX. If one of these is set to true, then the WGL/GLX/CGL code will be enabled and visible to the user. Currently, my currently written code will only add WGL, but I plan to later add GLX/CGL. This will not complicate existing code, you can still use other pre-built contexts, and you will be able to make any context cross-platform. I think it should be added into the main project, as it is a useful/commonly used feature, it will not interfere with any other code, and it will keep the library cross-platform.

ghost commented 4 years ago

I'll let @TheAIBot check in as well, but I'll talk a bit about a mistake I think I made with this code, and my thoughts on what could/should be done in the future regarding it. I think it was a mistake for me to include the OpenGL.Platform code in the same repo as OpenGL. I think each namespace should have had its own repo, allowing someone to only bring in the parts of OpenGL they wanted. I'm curious if other people would agree with me on this. Is it common to have multiple dlls generated by the same repo? Perhaps it isn't an issue at all.

I see this repo as being a way to have simple to use (and safe) bindings to modern OpenGL 4+, and the Platform code was only there to help someone get up and running easily with SDL. Adding more WGL/etc code will further move the codebase towards something other than a simple OpenGL library. So my knee jerk reaction is to suggest that we create a new repo for this type of code, and then link to it from the README of opengl4csharp.

However, this is very much an open dialogue. I'm not 100% sure what the right answer is. I've seen some OpenGL libraries contain everything and the kitchen sink (which I sort of don't want to do, but maybe we need to swing that way). Let me know what you think.

Well, if you think it should be in a different repository, create a new repository so I can push my code to it.

giawa commented 4 years ago

I think what would make sense is for you to create your own public repository and host the code there. Once the library has been built up and you are happy with it (and if there is particular integration with this OpenGL library) you could submit a PR to include a link to it from the README. That way people can find libraries that are compatible with (and can extend) the opengl4csharp library. What do you both think of something like this?

ghost commented 4 years ago

I think what would make sense is for you to create your own public repository and host the code there. Once the library has been built up and you are happy with it (and if there is particular integration with this OpenGL library) you could submit a PR to include a link to it from the README. That way people can find libraries that are compatible with (and can extend) the opengl4csharp library. What do you both think of something like this?

That'll work, i'll go work on it.