Jump to content

  • Log In with Google      Sign In   
  • Create Account


Is it possible to create your own graphics API?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
15 replies to this topic

#1 SteveDeFacto   Banned   -  Reputation: 109

Like
0Likes
Like

Posted 06 February 2011 - 03:41 PM

Basically I'm wondering if there is a way to write your own API like DirectX or OpenGL? I've been wondering this just because it would be an interesting idea. If it is possible would you be able to use the same code between graphics cards manufactured by different companies?

Sponsor:

#2 KulSeran   Members   -  Reputation: 2344

Like
0Likes
Like

Posted 06 February 2011 - 03:52 PM

Basically I'm wondering if there is a way to write your own API like DirectX or OpenGL? I've been wondering this just because it would be an interesting idea. If it is possible would you be able to use the same code between graphics cards manufactured by different companies?

Sure, anything is possible. You could download the source for the ATI open-source driver for Ubuntu and see how they interface with the hardware. You likely would not reuse much if any code between card manufacturers, and will have large difference between different chipsets by the same manufacturer.

#3 SteveDeFacto   Banned   -  Reputation: 109

Like
0Likes
Like

Posted 06 February 2011 - 04:00 PM


Basically I'm wondering if there is a way to write your own API like DirectX or OpenGL? I've been wondering this just because it would be an interesting idea. If it is possible would you be able to use the same code between graphics cards manufactured by different companies?

Sure, anything is possible. You could download the source for the ATI open-source driver for Ubuntu and see how they interface with the hardware. You likely would not reuse much if any code between card manufacturers, and will have large difference between different chipsets by the same manufacturer.


I thought Ubuntu uses OpenGL?

#4 Antheus   Members   -  Reputation: 2397

Like
0Likes
Like

Posted 06 February 2011 - 04:00 PM

Basically I'm wondering if there is a way to write your own API like DirectX or OpenGL?

Yes, it's done by anyone who takes Computer Graphics 2xx. They are just a bunch of user friendly helper functions over the basic graphics pipeline. Lots of bells and whistles, but the core concept hasn't changed in 40 years.

The reason DX and OGL are used is because they are standardized interface to highly proprietary hardware, implemented by hardware vendors.

If it is possible would you be able to use the same code between graphics cards manufactured by different companies?

Yes - map your API to DX or OGL. It's how every engine does it.

Talking to hardware directly, especially to degree done by vendor-provided drivers is impossible, since those details are one most heavily guarded trade secrets in computing industry today. There is no shared code beyond the basic PCI or AGP or whatever interface is used. The API is responsible for sending whatever bus commands the card will understand (or however this layer works these days).


Alternatively, create your own graphics card. It's not as silly as it sounds. You need a signal generator, framebuffer and something that talks to interface. It will not be a killer GPU, but it will be a graphics card.

Heck, with price of hardware today, put Linux on it and use one of existing rasterization libraries. Use a SS2 CPU, dish out for a GDDR5 stick and it will even do 4-way concurrency with lightning fast memory access. A bit more, and you're on a good, albeit inefficient way towards a perfectly passable graphics card.

#5 SteveDeFacto   Banned   -  Reputation: 109

Like
0Likes
Like

Posted 06 February 2011 - 04:06 PM

So does directx and opengl talk to a driver which in turn talks to the video card or do they talk directly to the video card?

#6 nobodynews   Crossbones+   -  Reputation: 1816

Like
1Likes
Like

Posted 06 February 2011 - 04:20 PM

Let me answer your question with a question: if DirectX and OpenGl talked directly to the video card why would you need to download video card drivers?

C++: A Dialog | C++0x Features: Part1 (lambdas, auto, static_assert) , Part 2 (rvalue references) , Part 3 (decltype) | Write Games | Fix Your Timestep!


#7 KulSeran   Members   -  Reputation: 2344

Like
0Likes
Like

Posted 06 February 2011 - 04:26 PM

So does directx and opengl talk to a driver which in turn talks to the video card or do they talk directly to the video card?

DirectX and OpenGL both have a bunch of "user mode" code that gets run when you call the API functions. On windows, in the case of DirectX, that is all provided in the DirectX runtimes. In the case of OpenGL, the runtimes usually come with the graphics drivers. The graphics driver takes care of all the "kernel mode" stuff that talks to the actual hardware.

Sorry if my first answer wasn't on track. Not sure what part you were interesting in reimplementing. You could also look at the Mesa OpenGL implementation, as it provides a software only graphics API with no hardware drivers.

#8 SteveDeFacto   Banned   -  Reputation: 109

Like
0Likes
Like

Posted 06 February 2011 - 05:38 PM


So does directx and opengl talk to a driver which in turn talks to the video card or do they talk directly to the video card?

DirectX and OpenGL both have a bunch of "user mode" code that gets run when you call the API functions. On windows, in the case of DirectX, that is all provided in the DirectX runtimes. In the case of OpenGL, the runtimes usually come with the graphics drivers. The graphics driver takes care of all the "kernel mode" stuff that talks to the actual hardware.

Sorry if my first answer wasn't on track. Not sure what part you were interesting in reimplementing. You could also look at the Mesa OpenGL implementation, as it provides a software only graphics API with no hardware drivers.


Do the drivers have a standard interface? Or does directx and opengl have code for each driver?

#9 dublindan   Members   -  Reputation: 457

Like
0Likes
Like

Posted 06 February 2011 - 10:54 PM

More like each driver has code specific to the different graphics library.

I imagine it's layered, something like this:
  • User code, calls OpenGL or DirectX function, which lives in opengl.dll or whatever (this DLL is probably installed as part of the driver)
  • OpenGL or DirectX function is implemented by the driver, which call the graphics card
  • Graphics card renders your image
It is very possible that the driver contains another layer between 3 and 4, which is common to all graphics library, which the OpenGL/DirectX calls get translated to. This would make sense because it would allow the driver to share code between DirectX and OpenGL, but I don't know if any of the dirvers do this in real life or not.
So, DirectX and OpenGL define the API - that is, the interface between you and the driver. You get access to the API through the OS's dynamic library mechanism (DLL on Windows, Shared Objects on Linux). The driver implements the API in the appropriate DLL's (opengl32.dll, dx.dll etc) or SO's. These dynamic libraries may or may not call other code as needed (eg, if the OS requires drivers to live in kernel space or if there is shared code, then the DLL's would probably be thin wrappers which call the real code).

So to answer your question more directly: The drivers have a standard interface: the OpenGL and DirectX API's. Behind those interfaces they can do whatever they want, including translating one grpahics library to another or both to some intermediary common format. OpenGL and DirectX themselves do not know about what drivers may exist for them or how they are implemented internally, as this is very much tied to the specific graphics card architecture.

#10 BeerNutts   Crossbones+   -  Reputation: 2762

Like
0Likes
Like

Posted 07 February 2011 - 09:25 AM

This probably isn't what you're looking for, but many years ago, while writing code using Borland Turbo-C, i made a "FXengine" API, which handled all my graphics functions (back then, it would call either the Turbo-C API, or some assembly code that accessed vidro memory).

When I ported some old games to Windows, I kept the FXengine API, and wrote to DirectX under it. Later, I also ported it to SDL.

So, I'm still using my "own" graphics API, but it's simply calling another high-layer API set, and it made porting my code much easier.
My Gamedev Journal: 2D Game Making, the Easy Way

---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)

#11 Fiddler   Members   -  Reputation: 804

Like
1Likes
Like

Posted 08 February 2011 - 04:18 PM

Talking to hardware directly, especially to degree done by vendor-provided drivers is impossible, since those details are one most heavily guarded trade secrets in computing industry today.


While I agree with the essence of your post, this part is quite wrong. 2 out of the 3 major GPU manufacturers release hardware specifications today. This includes hardware registers, instruction sets, CRTC setup, engine/memory clocking and almost everything else necessary to create a high-performance 3d driver for that hardware. In fact, open-source drivers now exist that, in some cases, surpass the official drivers in performance and capabilities.

(In case anyone is wondering, the two manufacturers who release specifications are AMD and Intel. The one that doesn't is Nvidia but its hardware has been reverse-engineered to the extent that a 3d driver is possible).

Back on topic: if you wish to construct a brand new graphics API, check the open-source graphics stack on Linux (Search for "Gallium3d" and "Mesa3d"). It is built in such a way that it is possible to layer new APIs with full hardware acceleration on top and people have been using it to accelerate OpenVG, OpenCL, OpenGL ES, OpenGL, Direct3D and video decoding APIs. This is actually very cool: not only is all the source code available for studying, its developers also tend to be very helpful.


Your only other option is to layer your API on top of D3D/OpenGL, which is going to be suboptimal up to a point.


[OpenTK: C# OpenGL 4.4, OpenGL ES 3.0 and OpenAL 1.1. Now with Linux/KMS support!]


#12 Zahlman   Moderators   -  Reputation: 1682

Like
0Likes
Like

Posted 09 February 2011 - 04:21 AM

(In case anyone is wondering, the two manufacturers who release specifications are AMD and Intel. The one that doesn't is Nvidia but its hardware has been reverse-engineered to the extent that a 3d driver is possible).


o_O Did something happen while I was not paying attention, such that AMD and Intel are now major GPU manufacturers, but ATI isn't?

#13 Hinch   Members   -  Reputation: 240

Like
0Likes
Like

Posted 09 February 2011 - 06:00 AM

o_O Did something happen while I was not paying attention, such that AMD and Intel are now major GPU manufacturers, but ATI isn't?


Well AMD bought ATI, and Intel sold millions of motherboards with crappy embedded graphics hardware. Welcome to the future! :)

#14 DarkRonin   Members   -  Reputation: 604

Like
0Likes
Like

Posted 12 February 2011 - 01:19 AM

@Zahlman - Yes, something did happen whil you were not paying attention.

AMD is ATI or rather ATI is no more..

#15 AndyEsser   GDNet+   -  Reputation: 383

Like
0Likes
Like

Posted 12 February 2011 - 05:28 AM

How did that manage to pass you by?

#16 Fiddler   Members   -  Reputation: 804

Like
0Likes
Like

Posted 12 February 2011 - 05:04 PM

Even if you've somehow missed the media fallout these past few years, there's that little hint where http://www.ati.com redirects to http://www.amd.com ...

[OpenTK: C# OpenGL 4.4, OpenGL ES 3.0 and OpenAL 1.1. Now with Linux/KMS support!]





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS