GUI Window

Started by
10 comments, last by CGame 17 years, 4 months ago
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

You didn't come into this world. You came out of it, like a wave from the ocean. You are not a stranger here. -Alan Watts

Advertisement
You would achieve this by using another language not Direct x, try VB or something as that would quickly give you the window effect.
<a href="http://www.chronoxdesign.co.uk>Join Chronox Design, you will live much longer trust us ;)
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
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.

You didn't come into this world. You came out of it, like a wave from the ocean. You are not a stranger here. -Alan Watts

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.
But lets say I want to have a GUI constantly visible even when im playing a game, how would I have the GUI in another window, & how do i draw to it.

You didn't come into this world. You came out of it, like a wave from the ocean. You are not a stranger here. -Alan Watts

Ok hold on,

Do you mean a Windows WIN32 style GUI, or an in-game GUI as seen in counterstrike etc etc?
Quote:Original post by VanillaSnake21
i want to display a window before the game starts


My mistake, sorry about giving you wrong advice :'(

<a href="http://www.chronoxdesign.co.uk>Join Chronox Design, you will live much longer trust us ;)
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.
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
http://www.vectorstudios.nethttp://engine.vectorstudios.net

This topic is closed to new replies.

Advertisement