Skip to main content
gamedev.net
🔒 Locked

multiplatform engine

Started by wh1sp3rik Sep 6, 2010 at 8:59 AM 2 replies 850+ views
Original Post
wh1sp3rik
wh1sp3rik
Hello,
I would like to see your opinions.

Let's say, I am doing an engine and i would like to support DirectX and OpenGL.
Every renderer is using different class, which are "incompatible". for example GL_MATRIX and D3DXMATRIX. there ale lots of similar classes like these.

I tried to make a framework, which encapsulate all renderers into "one" class but after few tests, i can see .. it's much slower. because I have custom MATRIX class . so i need to save data to my MATRIX class from GL_MATRIX or D3DXMATRIX and opposite way too.

I don't know, how professionals are doing it ?
1/ they are using this slow method
2/ they are using one framework, but lots of code for selecting right matrix for GL and DX, but what if i want to sell the engine, user has to use different matrix class for differet renderer. (or vector, color, whatever)
3/ they are using two frameworks and when they want to port it to another platform, they just use some preprocessor directives to use different renderer.
4/ any other idea

I would like to start and work on the right way of multi engine and make it fast as possible.

i will be happy to read your opinions, ideas, advices :) Thank you very much.
DirectX 11, C++
phresnel
phresnel
Personally I wouldn't expose the matrix coefficients and just provide methods like e.g. "rollRight(x)". That way you can also keep book of a cheap inverse, if you need it often (PBRT uses this approach). You can then compile-time-decide which one to use. Classes come in handy here.
Hodgman
Hodgman
#3 - your different grahpics frameworks are selected at compile time. You have two sets of classes, which provide the same functions (same interface) but are implemented differently - there's no virtual functions required.

Also, your graphical matrices often come from another system altogether - e.g. if your graphical object is controlled by a physics engine, you might get the matrix in the form of a btTransform, which you've got to convert into a D3DXMATRIX anyway.
Zakwayda
Zakwayda
Quote:
Every renderer is using different class, which are "incompatible". for example GL_MATRIX and D3DXMATRIX. there ale lots of similar classes like these.
Short answer to this question: use the same math library with both APIs. (There's no need to use a different math library for each, unless you're trying to take advantage of particular features or optimizations offered by one library or another or something like that.)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.