Jump to content
  • Advertisement
Sign in to follow this  
Galo

OpenGL Gui design with DX?

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

Hey there, maybe a Noob quest but... I was wondernig, is it posible to have GUI element designed in directX to implement in a OpenGL-Game or program ? Let's say i have my game window, and on right click i want a dropdown list with neat functions, i design this in DirectX but my gamewindow is OGL, is this posible ? Cheers, Galo

Share this post


Link to post
Share on other sites
Advertisement
It's possible but probably not viable.

(Horrible) Ways you could do it:

Get DirectX to render its output to a memory location or file and then get OpenGL to read that output onto a quad and display it.

Probably a few other ways you could do it.

Why don't you just do it in OpenGL? Porting between the two shouldn't be hard if you've designed it using OOP.

TechDude

Share this post


Link to post
Share on other sites
OpenGL and DirectX are _very_ hard to get to work together. If you really want to do that (which you probably don't) you'd probably have to go for Synex's way.

But as he already stated - just don't. Stick to one API. The differences are merely a matter of taste (after all they do the same thing).

Cheers,
Alex

Share this post


Link to post
Share on other sites
Hmmm, but the thing is, im planning on programming the GUI with directX, and the viewport OpenGL, IMHO this would be an advantage in the feauture.

And beceause i wan't to have my own cool looking interface instead of microsoft's boring buttuns and menu's, DirectX could do the job and it would take a lot of weight of the OpenGL's shoulders then if i would program the GUI in OpenGL as well.

Then also i considered GDI+, but this only works on WIN2000/XP, and maybe in the near feauture i want to run my application on a different platform, as MacOS or Linux.

But i also haven't found out wheter DirectX workx on other platforms, it still is MS.

Does it ?

Share this post


Link to post
Share on other sites
First off DirectX is only MS Windows - tho someone has come up with a version for MacOS (http://www.coderus.com/17Apr2002.pdf)

I think people are a little unclear on what you are trying to accomplish here. If you are talking about designing a Windows style GUI for a game, you'll have to write it in whatever graphics API you are programming the game. Therefore, if you are using OpenGL for you game, use OpenGL for your GUI.

GUI rendering is very simple, as often you are only dealing with 2D objects. Just pop a quad up on the screen, with a 'window' texture or a 'button' texture or a 'whatever' texture, add some event handling code and all of a sudden you have a GUI!

One of the new versions of DirectX (Summer 2004 release?) has some built-in GUI controls. Are these what you are refering to? If so, and you really really want to use them simply write the whole application in DirectX.

Share this post


Link to post
Share on other sites
Hmm, but what do people use for there GUI's then, i mean to make em all work on multiple platforms ?

Share this post


Link to post
Share on other sites
Quote:
Original post by Galo
Hmm, but what do people use for there GUI's then, i mean to make em all work on multiple platforms ?



They do that by abstracting away the graphics API. OR they just use OpenGL since that's already pltaform independant.

By abstracting away the graphcis API, you can use almost any underlying api at runtime. For a very small example, here:


class IGraphics
{
public:
virtual bool Init() = 0;
virtual bool Destroy() = 0;
virtual bool Begin() = 0;
virtual bool End() = 0;
virtual bool Clear() = 0;
virtual bool Flip() = 0;
};



That would be you're base class for any given graphics implementation. Then that would be implemented by using OpenGL and Direct3D, so you'd have a D3DGraphics class and an OGLGraphics class somewhere, which bother derive from IGraphics. These are usually hidden away inside a DLL. So then after you create your OGLGraphics.dll and D3DGraphics.dll, from your main program, you load either the ogl or the d3d dlls at run time, and get the internal class, and use the IGraphics as your interface pointer. The methods will be the same, but the implementation details will be different and hidden away insiide the individual dlls.

There was an article somewhere on here if I recall on make an API independant renderer. Search the Article section.

Share this post


Link to post
Share on other sites
Quote:
Original post by Galo
DirectX could do the job and it would take a lot of weight of the OpenGL's shoulders then if i would program the GUI in OpenGL as well.


It sounds like you want to removed to work of drawing the GUI from OpenGL to make it faster?

If so that wont work because it still your computer underneath that has to do everything. If you did set it up so DX would render the gui and OpenGL would draw your game Open GL would have to do less but it would also have less computing power (as some will be given to DX and i guess with the overheads of two Graphics APIs running at the same time it could be slower.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by IFooBar
Quote:
Original post by Galo
Hmm, but what do people use for there GUI's then, i mean to make em all work on multiple platforms ?



They do that by abstracting away the graphics API. OR they just use OpenGL since that's already pltaform independant.

By abstracting away the graphcis API, you can use almost any underlying api at runtime. For a very small example, here:

*** Source Snippet Removed ***

That would be you're base class for any given graphics implementation. Then that would be implemented by using OpenGL and Direct3D, so you'd have a D3DGraphics class and an OGLGraphics class somewhere, which bother derive from IGraphics. These are usually hidden away inside a DLL. So then after you create your OGLGraphics.dll and D3DGraphics.dll, from your main program, you load either the ogl or the d3d dlls at run time, and get the internal class, and use the IGraphics as your interface pointer. The methods will be the same, but the implementation details will be different and hidden away insiide the individual dlls.

There was an article somewhere on here if I recall on make an API independant renderer. Search the Article section.


Thanks, im gonna search the articles immideatly but as one sayd before, writing it in OGL makes it Platform independent.

Quote:

It sounds like you want to removed to work of drawing the GUI from OpenGL to make it faster?

If so that wont work because it still your computer underneath that has to do everything. If you did set it up so DX would render the gui and OpenGL would draw your game Open GL would have to do less but it would also have less computing power (as some will be given to DX and i guess with the overheads of two Graphics APIs running at the same time it could be slower.


Erm, you could be right about that though :-) whoops....
Well, i think i'll write the whole application in OGL, why not ?

Thanks for all the input guys, youve been realy helpfull

Cheers,
Galo

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!