Sign in to follow this  
VanillaSnake21

GUI Window

Recommended Posts

VanillaSnake21    175
Hi, I have a game working, but i want to display a window before the game starts that lets you select things such as New Game, Options, Load, etc, so 1. How do I create 2 wondows that both use D3D (how do I switch in which window I want to draw) and 2. How do I make buttons that look nice (not the standart Window buttons, maybe animated buttons) Thnx

Share this post


Link to post
Share on other sites
dave    2187
Quote:
Original post by Godlikeman
You would achieve this by using another language not Direct x, try VB or something as that would quickly give you the window effect.


No.

He means in-game, like menu systems and stuff.

For this you have several options:

1) Write a GUI system yourself, lots of hard work :/.
2) Use Direct3Ds GUI system. I've heard that it isn't so great though.
3) Use a 3rd party library. I'm in the early stages of writing one of these, there are already a few out there though so do a google search.

I advise option 3.

Dave

Share this post


Link to post
Share on other sites
VanillaSnake21    175
Is it really that complex? All I want to do is when I start my game, lets say im playing it in windowed mode and hit escape another window opens up. I can open up a second window but I dont know how to draw to the second window with Direct3D. And after I can draw to It i can just use surfaces as buttons, and I can animate the textures or something. The key thing is getting D3D to be used in 2 windows at once.

Share this post


Link to post
Share on other sites
dave    2187
It isnt complicated but to do it well takes time. If you just want a 'button for now' then hack something together by all means but it won't serve you well in the long run.

You will be rendering your GUI in the same window as your game is running.

Share this post


Link to post
Share on other sites
Xrystal    320
Sounds like what you want are two win32 windows of which one displays DirectX running and one with win32 controls.

Having 2 separately running DX Windows however may take some doing but I am sure there is a way to get the main loop updating both windows in turn.

Share this post


Link to post
Share on other sites
royteusink    132
Creating a button is not that hard to program.

This is what you can try:

1) Draw a sprite of an button texture
2) Calculate cursor position
3) When the cursor intersect the sprite, change the sprite-texture. When cursor is out the region change the texture back to normal
4) Detect mouse up and down events, when the cursor is in the region and the mousebutton is down, at the same time, when the cursor is still inside the region and is up then the click event is started, When do nothing and change the texture to normal.

Well it is not perfect what i'm telling here, but it works. You have to improve it a little bit

* For animated buttons search for animated sprites.


To switch between a menu and your game, just create a switch in your loop with beginscene and endscene

for example:

switch(menu)
{
case "menu":
BeginScene();
dodrawings
EndScene();
break;
case "game":
BeginScene();
dodrawings
EndScene();
break;
}

gr roy

Share this post


Link to post
Share on other sites
VanillaSnake21    175
Thnx for the advice roy, u said i should switch between game and menu in my main loop, but how can I make it so that D3D is drawing to two windows at once?
What I need is two windows that both use D3D and are running simultaneously. I don't want to use Win32 controls in my Menu window.

Share this post


Link to post
Share on other sites
CGame    123
If you just want to present a scene (your GUI) in another window then check the DX SDK for the Present-function. The third argument is the HWND (handle to the window)
"Pointer to a destination window whose client area is taken as the target for this presentation"

If you pass the handle of your second window, then it will present the backbuffer to that window.
Just switch between the game and GUI window, rendering different 'scene's'.

Hope this helped.

CGame

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this