Rechtecke unter DirectX



  • User-- schrieb:

    GDI und Direct3D sind ziemlich inkompatibel zueinander warum sollte man sich also so quälen, wenn es nen einfacher Aufruf von DrawPrimitiveUP tut und vor allem das Rechteck verändert sich ja mit jeder Bewegung der Maus.

    Kein Ahnung, warum denn?

    Bye, TGGC (Das Eine, welches ist.)



  • For DirectDraw programmers moving to Direct3D 8, I've pointed out that the first question is usually "Where's the blit function?" We've covered that topic, but the second question, almost as common, is "How do I get GDI functions to work?" In DirectX 7, programmers could get the GDI DC (Device context) handle and then use Win32 GDI commands directly on the surface. While GDI is generally slow, in many situations (particularly where execution speed is not a big issue) GDI provides very robust functions that handle a lot of graphic basics, saving programmers from much of the effort of creating routines from scratch. If nothing else, GDI routines could be used during prototype development, to be replaced by custom optimized routines later on. With Direct3D 8, that option is gone. It is no longer possible to "legally" get a DC handle to the primary surface, and so GDI commands to the screen are not possible. There are two possible solutions to this. First, you can create an off-screen bitmap surface with the CreateCompatibleDC/ CreateCompatibleBitmap() combination, do your GDI commands to this bitmap, and then copy the bitmap data to a texture that you can then draw to the screen. Second, you can replace the GDI commands with new custom versions.

    Quelle

    Das Workaround find ich dann doch etwas umständlicher als nen einfacher Aufruf von DrawPrimitiveUP



  • Ich hab das mal ausprobiert mit dem DC der Surface holen...
    Also mit Rectangle geht das sowieso nicht weil alles zwischen den Kanten des Rechtecks weiß bzw irgendeine Farbe annimmt!
    Also hab ich mal MoveToEx und LineTo probiert aber das problem ist dass das alles nicht so ganz funktioniert...
    Ich werd weiter damit rumprobieren, anscheinend is das ja das Einzige was funktionieren würde (?)

    Ich beschäftige mich erst seid kurzem mit Direct3D und das

    zeichne einfach mit einem D3DPT_LINESTRIP und den 4 punkten des rechtecks selbiges aus vertices mit D3DFVF_XYZRHW (also bereits transformierte koordinaten, da kannst du sogar gleich die mauskoordinaten nehmen) auf den schirm.
    die farbe lässt sich über ein material machen.

    sagt mir leider nicht viel

    Kennt ihr ne andere Möglichkeit?



  • Ich kenn das Andere "In der Doku nachschauen". Da steht sowas nämlich alles drin.

    Bye, TGGC (Das Eine, welches ist.)



  • Nur so aus Interresse wie weit bist du mit deinem Spiel?



  • Bis jetzt kann man Karten laden.
    Panzer erstellen, markieren, an einen Punkt schicken oder einen gegnerischen Panzer angreifen.
    Grafisch funktioniert auch alles.
    Nur das mit dem Markieren fehlt.

    Das Problem ist bei der GetDC Variante, dass wenn ich mit Rectangle oder dgl das Rechteck zeichne, dass ja der Rest (wenn ich es in eine zweite Surface zeichne, die ich dann über die anderen drüber lege) mit dem Schwarz( weil das ja tranparentes Schwarz wird wenn ich es beim Erstellen angebe) überlagert wird und im Endeffekt nichts außer dem Markierungsrechteck angezeigt wird!

    Das mit dem D3DPT_LINESTRIP hab ich mir angesehen aber leider keine Beispiele gefunden. und nur mit den Definitionen .. kann ich leider wenig anfangen


Anmelden zum Antworten