3 Replies - 847 Views - Last Post: 12 October 2012 - 09:28 AM Rate Topic: -----

#1 lukeme99  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 85
  • Joined: 15-March 11

DirectX Based Game On A Mac? How Did Valve Do It?

Posted 10 October 2012 - 01:26 PM

Hi,

How would you get a DirectX based game to work nativley on a mac? For example, CS:GO, that uses DirectX's full capabilities, but yet this game is still compatible on a mac, so how would you get this clearly mac-unfriendly app to work on a mac?

This question isnt something that would directly affect me, as my games programing is curently only Win based (mainly because of this ongoing GL vs DX debate)

Thanks,
L99

Is This A Good Question/Topic? 0
  • +

Replies To: DirectX Based Game On A Mac? How Did Valve Do It?

#2 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 1
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: DirectX Based Game On A Mac? How Did Valve Do It?

Posted 10 October 2012 - 02:49 PM

It's likely that on a Windows platform the code makes calls to a DirectX layer, but on the Mac calls are made to another layer that clearly can't be DirectX.

Google 'cross platform game development'.

This post has been edited by ButchDean: 10 October 2012 - 02:50 PM

Was This Post Helpful? 0
  • +
  • -

#3 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 1009
  • View blog
  • Posts: 4,199
  • Joined: 14-February 08

Re: DirectX Based Game On A Mac? How Did Valve Do It?

Posted 12 October 2012 - 05:03 AM

They could quite easily (and probably did) have a graphics renderer interface

class IGraphicsRenderer
{
public:
      virtual bool InitGraphics() = 0;
      virtual void RenderScene() = 0;
};



class DXRenderer extends IGraphicsRenderer
{
public:
     bool InitGraphics();
     void RenderScene();
};



class GLRenderer extends IGraphicsRenderer
{
public:
     bool InitGraphics();
     void RenderScene();
};



Then it's simply a case of creating the correct renderer at runtime (a config file) or compile time:

int main()
{
    IGraphicsRenderer* pRenderer = new GLRenderer();
    pRenderer->InitGraphics();

    while(running) // this doesn't care about the type
    {
          pRenderer->RenderScene();
    }
    return 0;
}



Of course this is a very rudimentary example, but you get the idea :)
Was This Post Helpful? 1
  • +
  • -

#4 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 1
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: DirectX Based Game On A Mac? How Did Valve Do It?

Posted 12 October 2012 - 09:28 AM

Another option would be to write interface/wrapper code rather than the example you have given. In such a case you specify overrides externally to the game engine as part of a library.

(Edited to clarify.)

This post has been edited by ButchDean: 12 October 2012 - 05:36 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1