Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


KamRandle

Member Since 14 Aug 2012
Offline Last Active Nov 15 2014 04:15 PM

#5120516 Supporting both DirectX & OpenGL

Posted by KamRandle on 01 January 2014 - 12:17 PM

Hello!  I re-writing my game engine from scratch and was trying to decide whether I should support DirectX & OpenGL or just DirectX?  I understand that OpenGL is cross-platform while DirectX is restricted to Windows & the Xbox.  I also have a couple more questions:

 

  1. I am developing on Windows using Visual Studio 2013 Ultimate.  If I were to implement OpenGL,  how would I build for different platforms? Example: If I wanted to build on maybe, Linux or Mac.  Would I have to build my project on that operating system?
  2. If I do develop for both API's, how should I setup my project? Should I create two separate projects? Or keep them both separated in one project using enums, and interfaces? Example: 
    enum NXAPIChoice
    {
        NXAPI_DirectX,
        NXAPI_OpenGL,
    }
    
    NXAPIChoice NXGame::DefaultAPI = NXAPIChoice::NXAPI_DirectX;
    
    void NXGame::FinalInitialize()
    {
        int sWidth = 0, sHeight = 0;
    			InitializeWindows(sWidth, sHeight);
    			SetupGPU(sWidth, sHeight);
    
    			//TODO: [HIGH PRIORITY] Initialize Input
    			//TODO: [HIGH PRIORITY] Initialize Audio
    
    			Initialize();
    
    			//TODO: [HIGH PRIORITY] Create & Start GameTime
    }
    
    void NXGame::SetupGPU(int width, int height)
    {
        //stuff...
        NXGPU::Initialize(DefaultAPI, width, height, ...other);
    }
    
    void NXGPU::Initialize(NXAPIChoice choice, int width, int height, ...other)
    {
        if (choice == NXAPIChoice::NXAPI_DirectX)
           InitializeDirect3D(width, height, D3D_FEATURE_LEVEL_11_0, ...other);
        else
           InitializeOpenGL(width, height, GL_VERSION, ...other)
    }
    

    Also if I were to develop for both, and I do have to compile my code on other platforms (linux or mac), will I be able to skip my DirectX code (assuming it would cause errors because DX is not available) and just compile GL code? Is it even worth adding support for both? Thanks! smile.png

[EDIT: Or perhaps, shall I finish my engine with DirectX first (creating empty methods for GL in the process) and just start working on GL support (fill in the empty methods) after DirectX is fully implemented?]




#4970368 [SlimDX] Drawing Texture

Posted by KamRandle on 16 August 2012 - 05:16 PM

I'm pretty advanced. I know a lot of c#. I've used XNA for about a few years and decided now it's time step up to DirectX. I'm trying to make a texture renderer class (I already made a simple screen system). Also, which one is better, SlimDX or SharpDX?


PARTNERS