Jump to content
  • Advertisement
Sign in to follow this  
lukacho999

OpenGL Can I write graphics library from 0 with C++ like OpenGL and DirectX?

This topic is 2283 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Can I write my own graphics library from 0 with C++ like OpenGL and DirectX? Or are they Hardware supported and it's impossible to create new graphics library?

Share this post


Link to post
Share on other sites
Advertisement
You *can* write your own 3D API, but unless you get a hardware vendor to write a driver for your API then it will be useless. In the case of D3D Microsoft provides some functionality in the base runtime library, but the real guts are in the driver which implements the D3D spec and actually communicates with the hardware. In the case of OpenGL there's only a spec, and pretty much everything is implemented by the hardware vendor.

Share this post


Link to post
Share on other sites
Yeah, unless you write a custom driver for your specific card you won't be able to do anything, and trust me, getting detailed specifications for recent cards so you can write your own drivers is pretty much impossible (I've tried), and writing a driver in itself really is not something you'd want to do

Share this post


Link to post
Share on other sites
In theory, Gallium3D would allow you to create your own drivers to support hardware acceleration for your own API on multiple operating systems and hardware.

Share this post


Link to post
Share on other sites
It's important to realise here that neither OpenGL nor D3D are "graphics libraries". They don't actually implement graphics functionality themselves, that's implemented by the driver and hardware. What OpenGL and D3D provide is a means for your program to talk to the driver and hardware.

Share this post


Link to post
Share on other sites
you could for sure write a software-only version of your library, in the next step you could try to use opencl/cuda to get some hardware acceleration.
Tho, it's less fun than it sounds, most of the work would probably be writing some shader compiler (unless that's fun for you :D ).

Share this post


Link to post
Share on other sites
Like everyone's said, technically, it is possible. You could figure out how your driver communicates with the DirectX or OpenGL and write your own API to handle the driver calls, but it's largely pointless, because it would be a MASSIVE project, and I can guarantee your code would be a worse library than either OpenGL or DirectX

Share this post


Link to post
Share on other sites
I read a thread a long time ago about creating a custom graphics API with OpenCL. While this would no doubt work, it would not be as quick as the hardware implemented APIs, because some operations have dedicated hardware, like the texture samplers/filters. You would have to replicate these in OpenCL code, which would run on the general purpose cores and likely be slower.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!