Create a Game Console

Started by
24 comments, last by Burnt_Fyr 13 years, 2 months ago
My application simply render a 3D model so I alredy have a little engine that allow me to draw objects and rotate them but I don't know how to set up an orthographic projection and the other steps. Maybe if you have a tutorial or you can post a really simple code example I will study it. At the moment, I load a .x file with DirectX 9 and i draw it on the screen...
Advertisement
Are you using the fixed-function pipeline or the programmable pipeline?
I would first say you a big "THANK YOU" for the help you are giving me, I'm a beginner of DirectX programming so sorry if my answers are stupids :) now, how could i see if I'm using the programmable pipeline or the fixed-pipeline? At the moment, I have only a 3D model loaded by a .x file and drawn on the screen, no textures or lights neither shaders
I'm a beginner of DirectX programming so sorry if my answers are stupids[/quote]
No worries - we all had to learn this stuff at one point or other :)

It sounds like you're using the fixed-function pipeline. With the D3D fixed-function pipeline, you set transforms using the SetTransform() function, which can be used to set the current world, view, and projection transforms. If you've got something basic up and running already, then you're probably already setting one or more of these.

For something like a console, you typically want to set the world and view transforms to identity, and set the projection transform to an orthographic projection. For the orthographic transform, you can use the actual screen dimensions, or set up a 'virtual space' for the console, whichever you prefer.

For creating said transform, check the DirectX math library documentation (the DX math library includes functions for creating orthographic projection transforms).

For examples, try searching the forums for e.g. 'gui orthographic'; this has been discussed quite a bit in the past, so you should be able to find some examples and/or references in previous threads.
For basic 2D rendering, including text, the D3DX part of the DX 9 library offers some functionality. You wanna look at ID3DXSprite, ID3DXFont and maybe ID3DXLine. Normally you don't even need to bother about transformations a lot, these objects will handle them automatically when used.
I really don't understand how could I draw 2D objects. Using sprites?

I really don't understand how could I draw 2D objects. Using sprites?


Just texture a rectangle (two triangles in DX I believe) black. Then use DX's text methods to type onto that rectangle.
ok but I have another question: I can draw the rectangle, draw the text, etc but how could I allow the user to type commands inside the console?

ok but I have another question: I can draw the rectangle, draw the text, etc but how could I allow the user to type commands inside the console?


You (essentially) get to write your own UI if you're not using an engine or something that makes it easier.

When the console is active, you'll need to capture the keyboard input from the windows message pump. WM_CHAR if I remember correctly is the message type for text input. That input will need to be handled in such a way that it effects what text is being rendered. You'll also likely need to get messages for the return key, and probably for the tilde (or whatever else you're using to toggle the console).
so what you are saying is that every keyboard button pressed must be wrote with DirectX on the console? Also, I drawn a really simple sprite for test but I need a texture, is this right? If so, how could I make the texture looking % transparent?

This topic is closed to new replies.

Advertisement