Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

kulik

API or non-API independent

This topic is 5137 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

I want to write game engine. I am thinking if API independency is necessary. It could be very messy. And probably slower because of proc pointers. What would you suggest? I have a lot of experience with OpenGL, less with DirectX.

Share this post


Link to post
Share on other sites
Advertisement
You have to ask yourself a few questions - who do you expect to be using this engine? Is it for you to learn things from or will it be a commerical product?

If the first is true, you don''t have to care about API independence. If it''s the latter, then you probably do.

My Manta-X engine is API independent, but at present there''s only a D3D renderer written - there may not ever be a OGL renderer completed. The reason for me doing this is simple, API independence forces you to boil down your public interface to the bare neccessity. This is good practice in OOP design, where the public interface is what is seen by the world - without it I probably would have gotten lazy and ill-defined the interface (much like a few of my internal classes...). It also gives me a well defined and self-contained object that I can use to plug Direct-X rendering into any application with a few (simpler) calls.

Putting it simply, it''s a good way to think, even if you don''t use write separate renderers.

Share this post


Link to post
Share on other sites
do you want to develope for multiple platforms ?
if yes, then go api independant or only openGL
if you only are developing for windows then use either openGL or directX but doing both really isnt gonna do much for you.

so I would just stick to what you know (either openGL or DirectX). However, making API independant code is a good learning experience. I did it once, decided it really wasnt worth all the extra effort and dropped it.

"A soldier is a part of the 1% of the population that keeps the other 99% free" - Lt. Colonel Todd, 1/38th Infantry, Ft. Benning, GA

Share this post


Link to post
Share on other sites
think you''ve answered your own question.
i started doing something like this once, but couldn''t be bothered in the end.
if you now opengl then stick with that, unless you really, really want to learn directx.

is it that you want the game engine to be able to render through either opengl or directx interchangably?

Share this post


Link to post
Share on other sites
It will be game engine. But OGL work good on nVidia cards, slower on ATIs. I want to have it cross-platform. Do you think I have to use drivers or polymorphic/derived classes?? Driver = DLL or SO

Share this post


Link to post
Share on other sites
In a realistic setting (i.e. not benchmarking) I have never noticed a difference between the speeds of opengl and directx - my favourite example being IL-2 Sturmovivk which i think runs better in ogl than directx (and that''s on an ati card).
if, by cross-platform you mean windows/linux/mac os, then i''d go with ogl and forget directx.
i did a game that runs on windows and linux once, the only differnce between the two projects was the app entry point and message handling - all the guts were identical ''cos i used ogl for graphics and openal for sound. Winner''s Dinners!!

Share this post


Link to post
Share on other sites
quote:
Original post by kulik
It will be game engine. But OGL work good on nVidia cards, slower on ATIs.


I doubt the difference is so big as to be a deciding factor. Any slowness will come from your code.

quote:
I want to have it cross-platform.


If you want cross platform go with OpenGL.

quote:
Do you think I have to use drivers or polymorphic/derived classes??


Those two aren''t even comparable. It''s like fishing about architecture.

quote:
Driver = DLL or SO


Er... you''ll be linking with libraries. And you can do what you want with the rest of your code.

Share this post


Link to post
Share on other sites
THX. Do you think its better to load a driver (DLL - WIN32, SO - LINUX) or have all renderers in core library. I thought about some kind of class that would load procs from driver during run-time.
Wouldnt it be slower cause of proc pointers??

Share this post


Link to post
Share on other sites
test it.

it probably will be negligible compared to the running time of the rest of your application.

Share this post


Link to post
Share on other sites
Any game of any significance will spend ~10% of the time doing API-specific calls, and less than 1% of the code will be API specific.

A DLL-based approach isn''t strictly speaking necessary, since there really are only 2 API''s to consider. You could just have 2 base renderer classes, and decide which one to use during run time.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!