GDI SubSystem

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Melissa
User
User
Posts: 71
Joined: Tue Sep 22, 2009 3:13 pm

GDI SubSystem

Post by Melissa »

...Well, judging by all compatibility problems with new 2D Drawing library, it seems that PB really needs some possibility to revert it into good/old GDI-based one. So why not just another subsystem for such purposes instead of forcing people to struggle helplessly with lots of new problems ? Very nice and simple solution, if you ask me....

P.S. Compiler option would be OK too.
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Re: GDI SubSystem

Post by Rings »

PB isn't Windows only.....
SPAMINATOR NR.1
User avatar
Melissa
User
User
Posts: 71
Joined: Tue Sep 22, 2009 3:13 pm

Re: GDI SubSystem

Post by Melissa »

So what ? We already have 2 DX-based subsystems. They aren't very multiplatform too, you know...
eriansa
Enthusiast
Enthusiast
Posts: 277
Joined: Wed Mar 17, 2004 12:31 am
Contact:

Re: GDI SubSystem

Post by eriansa »

Melissa wrote:...Well, judging by all compatibility problems with new 2D Drawing library, it seems that PB really needs some possibility to revert it into good/old GDI-based one. So why not just another subsystem for such purposes instead of forcing people to struggle helplessly with lots of new problems ? Very nice and simple solution, if you ask me....

P.S. Compiler option would be OK too.
Exactly what I was thinking! Let's wait and see.... :wink:
Thorium
Addict
Addict
Posts: 1305
Joined: Sat Aug 15, 2009 6:59 pm

Re: GDI SubSystem

Post by Thorium »

The new 2D drawing lib is still in beta stage and you want to have a GDI subsystem because the new drawing lib is not stable?

I say: Just let the devs fix the new lib.
User avatar
Melissa
User
User
Posts: 71
Joined: Tue Sep 22, 2009 3:13 pm

Re: GDI SubSystem

Post by Melissa »

The new 2D drawing lib is still in beta stage and you want to have a GDI subsystem because the new drawing lib is not stable?
Not only this: there are still some handy code which uses interaction with GDI, and (honestly) I liked doing such things myself.

Code: Select all

I say: Just let the devs fix the new lib.
Well, think about DX9. Recalling it ? Was it in usable state when they released PB 4.20 ?
User avatar
Olliv
Enthusiast
Enthusiast
Posts: 542
Joined: Tue Sep 22, 2009 10:41 pm

Re: GDI SubSystem

Post by Olliv »

Hello Melissa,

You don't have to use GDI.

Ollivier

Code: Select all

DisableDebugger
Structure LW ; Cf Procédures >> Alphablending >> Layered Window

    WindowID.L                  ; Handle du DC de la fenêtre translucide (WindowID)
    *ptWnd                      ;#Pointe vers une structure POINT (Position de la fenêtre, 0 = inchangée)
    *szWnd                      ;#Pointe vers une structure SIZE (Taille de la fenêtre, 0 = inchangée)
    hdcAIm.L                    ; Handle du DC source (Image Alpha)
    *ptAIm                      ;#Pointe vers une structure POINT
    crKey.L                     ; Couleur clé (transparence)
    *Blend                      ;#Pointe vers la structure BLENDFUNCTION (fBlend plus bas)
    *AImArea                    ;#Pointe vers 1 struc RECT spécifiant la zone à copier depuis le DC source
    X.L                         ; Coordonnées X de la fenêtre
    Y.L                         ; Coordonnées Y de la fenêtre
    W.L                         ; Largeur de la fenêtre
    H.L                         ; Hauteur de la fenêtre
    XA.L                        ; Coordonnées X dans l'image
    YA.L                        ; Coordonnées Y dans l'image
    fBlend.L                    ; Fonction Blend (toujours $01FF0000)
    X1.L                        ; Vista
    Y1.L                        ; Vista
    X2.L                        ; Vista
    Y2.L                        ; Vista
    Window.L                    ; n° de fenêtre
    ImageID.L                   ; ID de l'image
   
    VX.F
    VY.F
    AA.F
    V.F
    Flip.L
   
EndStructure


Procedure LayeredWindow(Window.L, Stat.L)

    Protected NewFlag.L = GetWindowLong_(WindowID(Window), #GWL_EXSTYLE) | (#WS_EX_LAYERED * Stat)
   
    SetWindowLong_(WindowID(Window), #GWL_EXSTYLE, NewFlag)

EndProcedure


Procedure OpenLW(*LW.LW, X, Y, ImageID)

    Protected Bmp.BITMAP
    Protected PosiSrc.POINT

    With *LW
        \ImageID = ImageID
        GetObject_(\ImageID, SizeOf(BITMAP), @Bmp)
        \W = Bmp\BmWidth
        \H = Bmp\BmHeight
        \Window = OpenWindow(-1, X, Y, W, H, "", $90000000)
        \WindowID = WindowID(\Window)
        If \Window
            StickyWindow(\Window, 1)
            LayeredWindow(\Window, 1)
            \hdcAIm = CreateCompatibleDC_(StartDrawing(WindowOutput(\Window) ) )
                SelectObject_(\hdcAIm, \ImageID)     
                Blend.L = $1FF0000
                Result.L = UpdateLayeredWindow_(\WindowID, 0, 0, @\W, \HdcAIm, PosiSrc, 0, @Blend, 2)
            StopDrawing()
            DeleteDC_(\hdcAIm)
            HideWindow(\Window, 0)
        EndIf     
        If Result = 0: CloseWindow(\Window): EndIf
    EndWith
       
    ProcedureReturn Result

EndProcedure

InitSprite()
InitSprite3D()
InitKeyboard()
OpenWindow(0, 0, 0, 1024, 768, "", $90000000)
OpenWindowedScreen(WindowID(0), 0, 0, 1024, 768, 0, 0, 0)
CreateSprite(0, 4, 4, #PB_Sprite_Texture)
StartDrawing(SpriteOutput(0) )
Box(0, 1, 2, 2, #White)
Box(2, 1, 2, 2, #Blue)
StopDrawing()
CreateSprite3D(0, 0)
Sprite3DQuality(1)
Distance.F = 256.0
Thickness.F = 8.0
;Repeat
   Delay(1)
   ClearScreen(0)
   If Start3D()
      Sprite3DBlendingMode(3, 9)
      Angle.F = 0
      For A = 0 To 360 Step 10
     
         cx.F = 256
         cy.F = 256

         Angle = A * #PI / 180.0 + AngleR.F
     
         ix.F = Cos(Angle)
         iy.F = Sin(Angle)
         jx.F = Cos(Angle + #PI / 2.0)
         jy.F = Sin(Angle + #PI / 2.0)

         ex1.F = 0.0
         ey1.F = 0.0 - Thickness
         ex2.F = Distance
         ey2.F = 0.0 - Thickness
         ex3.F = Distance
         ey3.F = Thickness
         ex4.F = 0.0
         ey4.F = Thickness
     
         gx1.F = ex1 * ix + ey1 * iy
         gy1.F = ex1 * jx + ey1 * jy
         gx2.F = ex2 * ix + ey2 * iy
         gy2.F = ex2 * jx + ey2 * jy
         gx3.F = ex3 * ix + ey3 * iy
         gy3.F = ex3 * jx + ey3 * jy
         gx4.F = ex4 * ix + ey4 * iy
         gy4.F = ex4 * jx + ey4 * jy
         DisplaySprite3D(0, 0, 0)
         TransformSprite3D(0, cx+gx1, cy+gy1, cx+gx2, cy+gy2, cx+gx3, cy+gy3, cx+gx4, cy+gy4)     
      Next
      Stop3D()
   EndIf
   ExamineKeyboard()
   If KeyboardPushed(#PB_Key_Left): AngleR = (AngleR + 0.005): EndIf
   If KeyboardPushed(#PB_Key_Right): AngleR = (AngleR - 0.005): EndIf
   FlipBuffers()
   *X = AllocateMemory(1024 * 768 * 4 + 8)
   PokeL(*X, 1024)
   PokeL(*X + 4, 768)
   If StartDrawing(ScreenOutput())
      Buffer      = DrawingBuffer()             ; Get the start address of the screen buffer
      Pitch       = DrawingBufferPitch()        ; Get the length (in byte) took by one horizontal line
      PixelFormat = DrawingBufferPixelFormat()  ; Get the pixel format.
   *Ecran = Buffer
   *Start = *X + 8

   Qty = 1024 * 768
   ! mov esi, [p_Ecran]
   ! mov edi, [p_Start]
   ! mov ecx, [v_Qty]

Transfert:
   ! lodsd
   ! mov edx, eax
   ! xor ebx,ebx

   ! cmp bl, dl
   ! ja l_ici0
   ! mov bl, dl
ici0:
   ! shr edx, 8

   ! cmp bl, dl
   ! ja l_ici1
   ! mov bl, dl
ici1:
   ! shr edx, 8

   ! cmp bl, dl
   ! ja l_ici2
   ! mov bl, dl
ici2:
   ! shl ebx, 24
   ! or  eax, ebx
   ! stosd
   ! loop l_transfert
   
   ;   CopyMemory(*Ecran, *Start, 1024 * 768 * 4)
      StopDrawing()
   EndIf
   AlphaImage.L = CreateBitmap_(1024, 768, 1, 32, *X + 8)
;   OpenWindow(10, 100, 100, 512, 512, "Lissage", $CF0001)
   ULW.LW
   OpenLW(ULW, 100, 100, AlphaImage)
   ;ImageGadget(0, 0, 0, 1024, 768, AlphaImage)
;   HideWindow(0, 1)
   ;Repeat
   ;   Delay(1)
   ;Until WindowEvent() = 16
   Delay(8000)
;Until KeyboardPushed(#PB_Key_Escape)
CloseScreen()
CloseWindow(0)
End
User avatar
Melissa
User
User
Posts: 71
Joined: Tue Sep 22, 2009 3:13 pm

Re: GDI SubSystem

Post by Melissa »

...What if I don't want to use 3D Sprites (making ordinary windowed utility f.e.) ?
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: GDI SubSystem

Post by netmaestro »

Well, think about DX9. Recalling it ? Was it in usable state when they released PB 4.20 ?
I can see why that might influence your thinking, but that one isn't a representative sample. The original library wasn't written by the team. It was a special case where they acquired a library that was already in use by some PureBasic users and they decided to make it native. They knew there were bugs in it but rather than spend months trying to identify them all themselves, they released it as an alternative subsystem and let it have a good workout by the userbase. During this, the dx7 version was still native and if you didn't want to use the dx9 subsystem, you didn't have to.

The current case with 2ddrawing is completely different. They designed and wrote it themselves, it is replacing what was there before, and you can believe that when 4.40 goes gold, it will be solid. It already is firming up nicely.

Tell me this, and answer honestly: has a frog ever lied to you? :wink:
BERESHEIT
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: GDI SubSystem

Post by freak »

I don't see where the big problem is with the new library. Most of the problems with it are simply because people mix in API calls in a way that is no longer supported.
quidquid Latine dictum sit altum videtur
User avatar
Olliv
Enthusiast
Enthusiast
Posts: 542
Joined: Tue Sep 22, 2009 10:41 pm

Re: GDI SubSystem

Post by Olliv »

Melissa wrote:...What if I don't want to use 3D Sprites (making ordinary windowed utility f.e.) ?
Do what you want to do. I didn't understand you anywhere... I give you a stable code, that's all...

Ollivier
Post Reply