Modifying TeapotWarsView

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • Modifying TeapotWarsView

      Goal:
      I'm trying to do something simple, but already feel lost... My goal is to add a health and ammo meter to the HUD. I would like this have a small Icon (of a bullet / of a cross) and a number next to it.

      Question:
      I'm currently looking for some references about DXUT and DXUTgui. Anyone know a good resource?

      Question:
      Does DXUT gui have a control in which you can specify a bitmap?
      Answer:
      Ok I found that DXUTgui screen elements have a method setTexture which takes a texture index... and DXUTgui resourcemanager has a method addTexture which takes a filename...

      Question:
      but where oh where in the application layer or some layer can I call addTexture? Where is the resourcemanager object instanciated?
      Answer:
      Ok the resourcemanager is a friend of DXUTdialogs which you can get a pointer to with .getManager() yipee.

      Question:
      Now apparently the texture filename string used with addTexture is suppose to be a LPCWSTR... um whats that? And if I put the texture file in the media folder, what would the path look like to load it?

      I was considering using .getManger()->addTexture inside TeapotWarsUI::TeapotWarsUI()
      however it looks like the resourcemanager has already been created elsewhere, so it might make more sense to do it wherever that is,

      Question:
      wheres the resourcemanager instanciated/initialized?
      Answer:
      Ahha, in GameCode.cpp, looks like its just using the default constructor, so if I wanted to load all the textures in one place I could probably do it in the UI constructor as I was thinking.

      Question:
      Whats the difference between TeapotWarsGame and TeapotWarsApp ?

      The post was edited 8 times, last by JamesFord ().

    • Well I've delved into the DXUTgui a little bit...

      I got a .dds plugin for photoshop and made 2 new textures, for the health and ammo HUD icons.

      Now I see within DXUTgui there are functions for creating each type of control (static, listbox, radio, etc). And I will probably create two new ones: 1 for health, 1 for ammo. However, wouldnt it be nice if I could just create a "generic" control, then set the size and texture? Since I'm not really planning on having lots of health/ammo controls all over the place. Is this possible?

      Well I've made some good progress understanding the DXUTgui. What i'll need to do is derive a new type of control which will contain a texture and an integer and define the render function for it, then I can define two new enumerated control types for the health / ammo (since this seems to be how I can later access them and modify their integer values), and then I should be ready to add the new controls to the HUD/screen

      BTW. It was very helpful to do all the tinkering with the DXUTgui in its own project rather than having to recompile/sort through the whole teapotwars, and the DX sample browser just happend to have a GUI sample project!

      The post was edited 4 times, last by JamesFord ().

    • Will Not Render

      I defined a new control, defined its default values, and added one to the sample gui, but for some reason it is not showing up (getting redered?)

      Apparently the texture IS getting assigned to element0 in my customControl but, its color value is not getting what should be the default value of 255,255,255,255, its just 0,0,0,0, which means when it is passed to drawSprite, it is ignored.

      HOWEVER, I disabled the check and it still isnt getting drawn.. I have no clue, been looking at this for 5 hrs. I did a breakpoint in DXUTCustomCtrl::Render(..) and stepped through it all, it looks to me like it SHOULD be rendered to the screen, but yet its not.
    • Well even though after disabling the "check" it was still trying to draw the texture with color 0,0,0,0, which was needless to say, not visible. So I had to initialize it, which i was able to figure out how to do,
      control > element0 > Init(D3DXCOLOR(255,255,255,255), ditto, ditto)

      The Init function needs 3 colors, not sure why, but it just does ! I think it has to do with the color for different GUI states, but since this control doesnt have any states, they are all the same.