Page 1 of 6 123 ... LastLast
Results 1 to 10 of 51

Thread: DirectX GUI Controls

  1. #1

    DirectX GUI Controls

    hi there, im not certain this is the correct place to post this thread, but hopefully it is ops: lol

    anyways, i have recently started working with directx and delphi 7, i have created my device and window etc, now im having trouble starting to actually render lets say a dialog, ie a custom dialog, a square shape with a caption lol, i have no idea where to start or how todo it, i have searched for tutorials but i can't find any that are for beginning with such things....this including rendering custom buttons etc...

    if anyone can point me in the right direction or maybe a link to a few basic samples of direct gui implementation would be greatly appreciated.

    thanks in advance

    -Memphis

  2. #2

    DirectX GUI Controls

    If you are working with DirectX then you need to create your own visual components. i.e. buttons, edit fields. Not sure what you are making but a game tends to not have much in the way of gui so should take too make effort to create, and if you make in such a way that you can use the code for your other projects then even better.
    The views expressed on this programme are bloody good ones. - Fred Dagg

  3. #3

    DirectX GUI Controls

    I developed NashaENGINE which is a DirectX 9 game engine. It has a GUI framework. You can check out the demo (Sound+GUI Demo, search the forums).

    When you start to make your own directx based GUI framework, you'll need the following things.

    > You must be able to render fonts (see fontstudio, or clooties font header).
    > You must be able to render quads/rectangles. These can also be transparent if you want some cool effects.

    Then you write a GUI base class with methods like render, click, mousemove and update. Finally you implement some GUI classes that implement this base class. You just describe their behaviour and appearance in these functions.

    If you use DelphiX, i think this shouldn't be too hard. You can use a DirectDrawSurface for each dialog, and render the controls on it. Finally render the whole thing to the screen to make the dialog visible.

    Hope this helps.
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  4. #4

    DirectX GUI Controls

    hi, first off, thanks alot for replies

    ok i use some custom directx headers, i have began creating my gui framework, but the part i was stuck is actually creating a directx rendered frame, lets say for my dialog or button, however i will check your nashaEngine, thanks alot

    *edit*

    i've checked your example, and that is the sort of thing i am trying to accomplish, but i still have no idea how to draw the custom shape in directx lol, i have also just checked clootie headers, but they are very complicated for starting off with dx....

  5. #5

    DirectX GUI Controls

    You are using DelphiX which works at a higher level than a lib that's build from scratch (like my engine). I have some DelphiX experience so i might be able to give you some clues and how-to's. I understand that you have problems getting shapes like rectangles on the screen. This can indeed be complicated (in my case, when using raw DX), but with DelphiX i guess it's a lot easier.

    This is how i draw a rectangle using clooties headers:

    > Define a vertex format (e.g D3DVTX_XYZ or D3DVTX_DIFFUSE)
    > Create a Vertexbuffer and specify the defind vertex format
    > Lock the buffer and fill it with vertex data
    These vertices are the corners of triangles. I will pass 2 triangles which make up a rectangle.
    > UnLock the vertexbuffer
    > Enter the game loop and render the contents of the buffer in each frame.

    As you can imagine, things like ellipses and round-rects are a lot harder to do because you need more vertices and more math skills to get your shape right. For more info on this, you can check the tutorials that are downloadable from clooties page. Things like: setting up a vertexbuffer, render a texture, creating a render device etc are all covered.

    So, when you are using delphiX, you can use DXDraw1.Surface.Fill to fill a rectangle with a color. You can also draw rect's with DXDraw1.Surface.Canvas, but i guess you are not able to do blending. You can use more complex functions like ellipses and arc's though. Text can be done using Canvas.Textout.
    You should explore the routines that the canvas and the surface offer you. Take a close look at the DelphiX examples, and i'm sure you will be able to figure it out.

    If you have more specific problems, feel free to ask.

    EDIT: Never mind ops:
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  6. #6

    DirectX GUI Controls

    'You are using DelphiX'

    i do not use delphix, i use custom directx headers i have wrote, however, i think i get the idea of the vertex buffer, i will give that a shot, thanks

  7. #7

    DirectX GUI Controls

    Oops i can't read today

    Well... i hope you figure out how it all works.
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  8. #8

    DirectX GUI Controls

    ok i have another question related to this :-P

    would you say it is better to create vertrices for creating buttons or would it be nicer to use sprites ?

    thanks again

  9. #9

    DirectX GUI Controls

    You mean Vertexbuffers versus ID3DXSprite?

    Well, i have to admit that i don't have experience with ID3DXSprite. I always render my geometry using vertexbuffers, because i can make it more abstract and reuse code for 3d purposes which ID3DXSprite can't handle.

    I guess both are good options. Doing it using vertexbuffers takes some extra work, and problems might occur. But you can use the same code for rendering 3d things, and you have much control over the rendering process. I think that ID3DXSprite gives you enough flexibility to make a GUI, but i can't help you with it.
    Coders rule nr 1: Face ur bugz.. dont cage them with code, kill'em with ur cursor.

  10. #10

    DirectX GUI Controls

    hi i have decided to go with using vertices, so far i have designed a custom form, which i can place via...

    Code:
      TestDialog := TNemesisDialog.Create(5,35,150,250);
    like so:



    next thing i want todo is make buttons etc, but small question is, is there a special trick to detecting mouse over etc, when dealing with directx?

    at the moment i have jus wrote a small function todo the job

    [pascal]
    function TNemesisControl.TestHit(H, W: Integer): boolean;
    var
    m: TPoint;
    begin
    Result := True;
    GetCursorPos(m);
    ScreenToClient(hWindow, m);

    if (m.X < iPosX) or (m.X > iPosX + W) or (m.Y < iPosY) or (m.Y > iPosY + H) then Result := False;
    end;
    [/pascal]


    thanks in advance,

    -MM

Page 1 of 6 123 ... LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •