STL and a few questions about Win32 and DirectX

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
User avatar
codinitup
Posts: 112
Joined: June 27th, 2012, 7:43 am

STL and a few questions about Win32 and DirectX

Post by codinitup » December 10th, 2012, 1:18 am

Hey Chili and others! I was wondering if you have covered the STL (standard template library) in any of your videos yet? I was doing some looking around and from what I can see, it looks like it can be avoided completely.Now correct me if I'm wrong, but it seems like many of the advanced features don't come into play very much in C++ because they can be accomplished in other ways. I havn't done too much research on them, and I'm probobly missing some information here, but arent templates just used to stop the repetitive nature of copying and pasting code to do a task? according to http://www.cplusplus.com/doc/tutorial/templates/ their definition is

"Function templates are special functions that can operate with generic types. This allows us to create a function template whose functionality can be adapted to more than one type or class without repeating the entire code for each type."
But if you havn't covered them than are you going to any time soon, or are they more of a complex topic than you wan't to cover at this point?

My next question is where did you learn all of your knowledge of DirectX and Win32? I've tried to learn both so I can create my own framework and go from there, but with little results on the DirectX part. Mostly due to the part that I can't find any good tutorials or websites that cover ONLY 2D. I don't really need 3D, I have unity for that haha. The Win32 is a different story though, most of it is just common logic because the way that the functions for creating windows and all that other crap are just common logic to read, and can be easily found with google if the wording for it doesn't quite make sense.

My 3rd and final question is how does the DirectX become incorperated into the Win32 program; or where does it go inside of the program in an optimal spot that it can create a window and have it work well with no errors. I most likely phrased that wrong, so I'll just take you through what i wan't to do so somebody can give me some pointers on where to start (not do the work for me, just some good resources that relate to the topic).

Step 1: Create a window that has a New Game,Load Game,and Save Game button

Step 2 (and the place where I am getting confused) : Allow the user to press either new game or load game and start the DirectX processes. I don't really want them running until the user selects a game option, and then load the game content to the screen. Most games have a customized menu that used different color schemes than the "windows theme" See example 1 below...
But I wan't to just use the windows style buttons (see example 2 below) and THEN load the graphics for the game. Is that possible to do, or am I just making it more complicated than it really needs to be, or does it not really matter. I don't want the compiler to be using the memory if the program doesn't need to be using it at that time (if that makes sence) and vise versa, when the game is running in the graphics or actual game portion, delete the memory being allocated for the window screen. I know it's possible to do with regular variables (new and delete keywords) but can it be done with Win32?

Step 3: Load Game

Step 4: If the game is lost they can save the game and then return to the menu screen and use the process from step 2 to keep the game at an optimal speed.

Thanks for reading all that, if you really don't know than even ideas or guesses are still greatly appreciated!
Attachments
MidGameMenu.jpg
This is the other type of color type scheme I mentioned
MidGameMenu.jpg (74.88 KiB) Viewed 2250 times
mainadvanced.jpg
this is the "windows tpye theme" I was talking about
mainadvanced.jpg (20.8 KiB) Viewed 2250 times
MOOOOOO

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: STL and a few questions about Win32 and DirectX

Post by chili » December 10th, 2012, 12:30 pm

Ummm...

One: I will be using STL stuff through the course of the current tutorial arc (platformer). It's not really that hard to use templates. It can be kinda tricky to write template classes though.

Two: I forget. I should mention that if you want to do hardware-accelerated 2D in direct3d it helps a lot if you know about how 3D works, since it will be going through the 3D pipeline. You should download a sample solution that uses d3dxsprite and see if you can figure that out.

Three: I don't understand the question :S
Chili

User avatar
codinitup
Posts: 112
Joined: June 27th, 2012, 7:43 am

Re: STL and a few questions about Win32 and DirectX

Post by codinitup » December 11th, 2012, 6:57 am

Well thanks for the advice on the first 2, let me rephrase the third one...
If I have a game running and I don't want unnecessary Win32 things running in the background, how can I write the code so that only the bare minimum amount of memory will be used to accomplish a task.
Example: If I have a menu (title screen) for the start of the game, and I want that to resemble more of a .NET kind of look (The default buttons you can drag to a window in a windows form application), but I don't want that to be using the allocated amount of memory for the actual "graphics" or game portion, how can I write the code so that it destroy's the windows code for the title screen and uses the memory from the title screen to allow the game to run faster.

I know it's hard to understand and it's a complicated question, but I guess in general I am trying to ask if there is a correct way to program a game so that the Win32 and the DirectX work as efficently as possible together. Or are they not really linked in the way that I think they are?
MOOOOOO

indus
Posts: 35
Joined: November 7th, 2012, 12:35 am

Re: STL and a few questions about Win32 and DirectX

Post by indus » December 11th, 2012, 9:10 am

You are allocating memory for objects you create in the game dynamically.This means when it is needed. For example you start the game and create an instance of Player and 50 instances of Enemy so you need to allocate memory for those 51 objects. Each time the player kills an enemy you call delete which invokes the destructor of an object and frees up the used memory so that it can be used again. Than at some point the player kills all the enemies and reaches the Boss. At this time you create an instance of Boss and allocate memory for it. Not at the beginning of the game.

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

Re: STL and a few questions about Win32 and DirectX

Post by chili » December 16th, 2012, 2:11 pm

Generally freeing up memory like that won't make your game run any faster. Also, when you start programming using dynamic memory allocation and classes, this stuff will fall into place naturally.
Chili

Post Reply