Remaking the engine with opengl and sdl2

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Remaking the engine with opengl and sdl2

      Has anyone tried to change the application layer to run from sdl2 wrapper? It's much simpler than winapi and can make the whole thing portable. It cuts down the time needed to make the application layer work, quite a + in writing an engine imho.

      The big part is changing the rendering subsystem that uses opengl. Apart from converting the coordinate system and texture coordinates, there's a lot more to change. The model loading scheme, is assimp worth it? Apart from having to write shaders anew, opengl doesn't use the dx effects structure, making it a shaderish mess, anyone got a good way around that?
      So, has anyone tried to implement opengl render next to directx one, or just plainly replace it? Any suggestions on how to start?
    • Hey,

      I have somewhat a similar implementation to what you are describing, I'll list it in points

      - Eliminating the Win32 API isn't actually a big deal, my Win32 window creation & message loop is a very small file, about 300 lines, where the X11 line is similar 300-400 lines. I find the small footprint of these implementations is well justified as it is very light weight, and gives you a lot of control, where SDL is a little heavy for my tastes. That being said, my first implementation of an engine based on GCC used SDL just fine, with no issues.

      - All versions of my engine (iterations on past mistakes) have used OpenGL for the rendering, with no issues at all. I have also separated my rendering code into another library which abstracts the rendering details, for the most part you work with high level objects like 'Meshes', 'Materials', 'Lights', etc. Behind the scenes these all use abstracted classes such as 'CGpuBuffer' which in OpenGL contains the functionality, and the object handle to an OpenGL vertex buffer. This could easily wrap the same D3D equivellent and allow for a swapping of the graphics API.

      - As for model loading, Assimp is 'ok', it does handle quite a few formats and if you get the latest Git version it also supports FBX files, however I should note that it is quite heavy, and has some quirks with certain formats (can't remember exactly). Because of this I have opted for using my own intermediary format which allows for metadata ie. events in animations to be dispatched, which I convert to with an external tool, this could also easily be imported on the fly from FBX or Colladae into the in-memory format without an intermediary file (.mesh for me).

      - OpenGL has GLFX which is interesting but I don't personally use, I personally find OpenGL shaders very nice to use, which I interface to with my material format which allows for the plugging in of uniforms either from the .material file, or from the material class code side. GLSL is nice, it's just different from what you may be used to with DX effects.

      Let me know if you need any additional explanations, or help with specific areas as well.
      PC - Custom Built
      CPU: 3rd Gen. Intel i7 3770 3.4Ghz
      GPU: ATI Radeon HD 7959 3GB
      RAM: 16GB

      Laptop - Alienware M17x
      CPU: 3rd Gen. Intel i7 - Ivy Bridge
      GPU: NVIDIA GeForce GTX 660M - 2GB GDDR5
      RAM: 8GB Dual Channel DDR3 @ 1600mhz

      The post was edited 2 times, last by mholley519 ().

    • Hello, i'm still reading a bit to catch up with the new C++11/14 standards, so i haven't done much, but am about to start changing it once i learn a bit more about the sdl2 wrapper.

      I presume removing winapi isn't such a big deal, the problem comes with the functions that are tied to it, like buttons and other gui elements, i presume sdl has it's own variant to cover those?

      Are you using the same memory pooling as is described in the book. Ah, as for graphical apis, i'm thinking of only having opengl, but i guess your method works the same, while allowing to have both.
      As for shaders, i think using #ifdef for permutations is a better solution than GLFX.
      I also think that assimp might have a big overhead, but it might faster to include that than to write a whole input anew.

      Also, has anyone tried using luajit, for lua binding? Is it better/faster?

      Another question, has anyone taken a look at other architectures, like the book "Game engine architecture, (second edition)" or has tried to take a look at quake source code (all of the quakes are open source now, and their udp multiplayer with prediction looks almost like a necessity). There's also valve source code leaked somewhere, they also have an interesting multiplayer model. I just wanna know if there's big disparity in their source structure, i realize this code is really good for starting out, but i don't want to miss out on improving on later. Just trying to gather things for the "big picture",

      but i digress, mholley519 what other libraries did you use with opengl, i presume glm, anything else?

      The post was edited 1 time, last by Wolkec ().

    • - SDL Does not have it's own GUI built in, however there are plugins for it, although I would opt for something more robust which I will mention in the libraries I use.
      - I don't use any memory pools either than the standard, once I need it I'll bring it in though.
      - I only have an OpenGL implementation of my render system interface, but I didn't want to completely block out the possability of different API's. Also the ifdefs in your code are fine, this is known as an Ubershader (it has other names as well) and it is perfectly fine, I like OpenGL's linking of modules though which I use instead.
      - Assimp is perfectly fine, and if you are just starting is much better than wasting your time on model loading code.
      - We use LuaJIT at work with LuaPlus for C++ binding, if you are interested you are going to need to get LuaPlus from GitHub and use the 'NextGen' branch, as this supports multiple versions of Lua as well as LuaJIT, we gained a decent amount of speed from LuaJIT (taking our scripting cost from somewhat noticeable to not even registering in our profile). Definitely use this, whether it is for the faster interpreter or even better the JIT compiler.
      - I have the book Game Engine Architecture 1st edition, it is a really good book but I found that it doesn't offer a complete picture the same as GCC, but I somewhat use it as a GCC expansion pack so to speak.

      I have several of my own libraries that tie in more 3rd party libraries

      Leaf, device input
      - DirectInput
      - Win32 API
      - X11
      - etc..

      Glitz, graphics engine
      - OpenGL with GLEW for extension management
      - Win32 & X11 for windowing
      - ASSIMP was used in my last iteration but I am opting for my own Colladae loader this time.
      - STB Image library, this is a very small image loading library written for games, I am unsure of it's support and it also has issues with several image types so I am likely going to replace this library as well.

      Gamut, "Game Utility" library
      - GLM for math, this is used all over the place
      - FastDelegate for delegates
      - JSON-Cpp which I use for data, I previously used TinyXML2 however I have been slowly enjoying JSON more and more lately (especially as it is our data format of choice at work).

      Lumberjack Engine, my main game engine which ties in all the other libraries
      - Awesomium for GUI, this is a great graphics library, giving all of the abilities of the Chromium framework.
      - Bullet for physics
      - FMOD for audio, this has proven to be VERY nice and well worth the price
      - LuaJIT & LuaPlus These are both nice to use and fast, one of the downfalls Rez mentioned in the book is no longer an issue as the modifications to the core library (mainly the 'FastRef' system) have been implemented in Lua and are phased out of LuaPlus.

      These are only some suggestions from what I use, but you should choose what works for your project as well as make sure not to take on too much at once, start out with some more basic libraries for instance use some SDL Audio, GUI plugins to speed things up for you.
      PC - Custom Built
      CPU: 3rd Gen. Intel i7 3770 3.4Ghz
      GPU: ATI Radeon HD 7959 3GB
      RAM: 16GB

      Laptop - Alienware M17x
      CPU: 3rd Gen. Intel i7 - Ivy Bridge
      GPU: NVIDIA GeForce GTX 660M - 2GB GDDR5
      RAM: 8GB Dual Channel DDR3 @ 1600mhz

      The post was edited 1 time, last by mholley519 ().