PB4B4 : Change in internal 2DDrawing definitions ?

Just starting out? Need help? Post your questions and find answers here.
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3942
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

PB4B4 : Change in internal 2DDrawing definitions ?

Post by wilbert »

I'm trying to port my userlib (written in ASM) to PB4. It uses

extrn _PB_2DDrawing_CurrentDC
extrn _PB_Window_Current

When I try to compile an example I get an unresolved external symbol for these.
Aren't they available anymore ?
I did mention in the desc file that it needs the 2DDrawing lib.
El_Choni
TailBite Expert
TailBite Expert
Posts: 1007
Joined: Fri Apr 25, 2003 6:09 pm
Location: Spain

Post by El_Choni »

I don't know for the 2D library. I use this to get the current window, but you need, at least, to create a gadget list:

Code: Select all

!Extrn _PB_Object_GetThreadMemory@4

!Extrn _PB_Gadget_Globals

Procedure.l GetCurrentWindow()
  !push dword [_PB_Gadget_Globals]
  !call _PB_Object_GetThreadMemory@4
  !mov eax, [eax]
  ProcedureReturn
EndProcedure

If OpenWindow(0, 100, 200, 195, 260, #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget, "PureBasic Window")
  If CreateGadgetList(WindowID(0))
    Debug WindowID(0)
    Debug GetCurrentWindow()
    Repeat
      EventID = WaitWindowEvent()
      If EventID=#PB_Event_CloseWindow
        Quit = 1
      EndIf
    Until Quit = 1
  EndIf
EndIf
El_Choni
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3942
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Post by wilbert »

Unfortunately that doesn't solve my problem.

My lib has some custom drawing functions. In order for them to work the same way as the normal PB drawing functions I need a way for the lib to find the currentDC so it doesn't have to be specified each time a function is used. Using PB 3.9x it wasn't a problem. I don't know if the externals I need just aren't available anymore or that I have to change something in my desc file when recompiling for PB4.
S.M.
Enthusiast
Enthusiast
Posts: 118
Joined: Sat Apr 24, 2004 1:11 pm
Contact:

Post by S.M. »

This code should return the current DC:

Code: Select all

Procedure DrawingDC() 
!extrn _PB_2DDrawing_GlobalStructure 
!MOV EAX,[_PB_2DDrawing_GlobalStructure] 
ProcedureReturn 
Endprocedure
A few other variables:

Code: Select all

 ----------------------------------------------------------------------- 
  2DDrawing
  --------- 

  _PB_2DDrawing_GlobalStructure 
  _PB_2DDrawing_Globals 

  ; internal functions 
  _PB_2DDrawing_SwitchToDC@0 
  _PB_2DDrawing_SwitchToDC_THREAD@0 

  Structure DrawingInfoStruct 
    Type.l    ; Type of the DC 
    Window.l  ; Window associated to the DC (if any) 
    DC.l      ; DC (Display Device Context) 
    ReleaseProcedure.l ; Address to a procedure to release the DC when StopDrawing() is called 
    PixelBuffer.l      ; Address of the memory pixel buffer (DirectX) 
    Pitch.l            ; Bytes per line (DirectX) 
    Width.l 
    Height.l 
    Depth.l 
  EndStructure 

  ----------------------------------------------------------------------- 
  SimpleList
  ---------- 

  _PB_FreeSimpleLists@0 
  _PB_InitSimpleList@0 
  _PB_SimpleList_Add 
  _PB_SimpleList_AddAfter 
  _PB_SimpleList_Count 
  _PB_SimpleList_Heap 
  _PB_SimpleList_IsID 
  _PB_SimpleList_Remove 

  ----------------------------------------------------------------------- 
  Image
  ----- 
  _PB_Image_Globals 
  _PB_Image_Objects 
    
  Structure PB_Image 
    Bitmap.l     ; OS Bitmap pointer (HBITMAP) 
    Width.w      ; Width in pixel of the image 
    Height.w     ; Height in pixel of the image 
    Depth.w      ; Depth in bpp of the image 
    ColorArray.l ; Memory pointer on a color array for 256 colors pictures 
    unknown.w 
  EndStructure 

  ----------------------------------------------------------------------- 
  Object
  ------ 

  ; functions: 
  _PB_Object_Init@12 
  _PB_Object_FreeID@8 
  _PB_Object_EnumerateStart@4 
  _PB_Object_EnumerateNext@8 
  _PB_Object_IsObject@8 
  _PB_Object_GetObject@8 
  _PB_Object_GetOrAllocateID@8 ; returns a pointer to an entry (the ObjectsArea is extended, if needed) 

  _PB_Object_InitThreadMemory@12 
  _PB_Object_GetThreadMemory@4 

  ; Each object has the following structure: 
  Structure PB_Object 
    Size.l         ; Size of one entry in the ObjectsArea (in Bytes) 
    StepSize.l      ; The number of enties which are allocated at once 
    NumEntries.l   ; Current number of Entires 
    Unknown.l[4] 
    ObjectsArea.l  ; pointer to the first entry 
    Unknown2.l[2] 
  EndStructure 

  ; Example for allocating space for a Image: 
  Procedure IMAGE_GetOrAllocImageSpace(Image) 
    !extrn _PB_Image_Objects 
    !extrn _PB_Object_GetOrAllocateID@8 
    !Push dword[Esp+4] 
    !Push dword[_PB_Image_Objects] 
    !CALL _PB_Object_GetOrAllocateID@8 
    ProcedureReturn 
  EndProcedure 

  ----------------------------------------------------------------------- 
  Sprite
  ------ 
  
  _PB_Screen_Width            ; width of the current buffer selected with UseBuffer() 
  _PB_Screen_Height           ; height of the current buffer selected with UseBuffer() 
  _PB_Screen_Depth            ; depth (in bpp) of the current buffer selected with UseBuffer() 
  
  _PB_Screen_RealWidth        ; width of the back buffer 
  _PB_Screen_RealHeight       ; height of the back buffer 
  _PB_Screen_Window           ; ScreenID() (HWND) 
  _PB_Screen_Windowed 

  _PB_Screen_IsActive 
  _PB_Screen_WindowedYOffset 
  _PB_Screen_WindowedXOffset 
  _PB_Screen_AutoStretch 
  _PB_Screen_WindowedRightBorder 
  _PB_Screen_WindowedBottomBorder 
  _PB_Screen_ModesArray        ; pointer to an array of PB_ScreenMode elements 
  _PB_Screen_FlipBuffers 

  _PB_DirectX_CurrentDC      
  _PB_DirectX_FullScreenWindow  ; ScreenID() when full screen is used (HWND) 
  _PB_DirectX_PixelFormat   ; Pixel format (see DrawingBufferPixelFormat() ) of the current buffer selected with UseBuffer() 

  _PB_DirectX_PrimaryBuffer ; Directdraw visible buffer (IDirectDrawSurface7) 
  _PB_DirectX_BackBuffer    ; Directdraw back buffer (IDirectDrawSurface7) 
  
  _PB_DirectX_FrameRate     ; Frame rate set with SetFrameRate(FrameRate) 
  _PB_DirectX_RefreshRate   ; Refresh rate set with SetRefreshRate(RefreshRate) 

  _PB_DirectX_WindowedFrameRate 
  _PB_DirectX_WindowClipper           ; IDirectDrawClipper for windowed screen 
  _PB_DirectX_ActualRefreshRate 
  _PB_DirectX_PreciseTimerDelta 
  _PB_DirectX_PreciseTimerOldValue 
  _PB_DirectX_SaveAllSpritesSurfaces 

  _PB_Sprite_Objects 
  _PB_Sprite_CheckFXBuffer 
  _PB_Sprite_ColorKey 
  _PB_Sprite_CurrentDC 
  _PB_Sprite_BufferDC 
  _PB_Sprite_SpecialEffectMode 
  _PB_Sprite_AlphaBlueModifier 
  _PB_Sprite_AlphaGreenModifier 
  _PB_Sprite_AlphaRedModifier 
  _PB_Sprite_TranslucentLUT 

  _PB_Sprite_FillDrawingInfo 
  _PB_Sprite_SpriteInfo 
  _PB_Sprite_CurrentBitmapInfo 
  _PB_Sprite_FXBufferInfo      ; the pointer to a DDSURFACEDESC2 structure 
  _PB_Sprite_SpriteFX 
  _PB_Sprite_CurrentBitmap     ; DirectDrawSurface7 pointer of the current buffer (set with UseBuffer()) 
  _PB_Sprite_FXBuffer          ; DirectDrawSurface7 pointer which is used with StartSpecialFX()...StopSpecialFX() 
  _PB_Sprite_LimitFrameRate 
  _PB_Sprite_DEBUG_GetSurfaceData 

  _PB_Screen_V_Quit 
  _PB_Screen_V_FlipWindowedBuffers 
  _PB_Screen_V_FlipBuffers 
  _PB_Screen_V_GetDirectDraw7 
  _PB_Screen_V_GetBackBuffer 
  _PB_Screen_V_OpenScreen3D 

  ; Internal functions 
  _PB_Sprite_GetTrueRGBColor@12 
  _PB_Sprite_InitDirectXScreen@0 
  _PB_Sprite_CreateEmptySprite@20 
  _PB_Sprite_CleanUpAll@0 
  _PB_Sprite_SaveAllSpritesSurfaces@0 
  _PB_Sprite_RestoreAllSpritesSurfaces@0 
  _PB_Sprite_ReleaseScreenOutput@0 
  _PB_Sprite_SetPixelFormat@0 

  Structure PB_Sprite 
    Sprite.IDirectDrawSurface7       ; DirectDrawSurface7 pointer 
    Width.w       ; Current width of the sprite (could change if ClipSprite() is used) 
    Height.w      ; Current height of the sprite (could change if ClipSprite() is used) 
    Depth.w       ; depth of the file. (in bits)  
    Mode.w        ; Sprite mode, as described in LoadSprite() 
    FileName.l    ; Pointer on the filename, if any 
    RealWidth.w   ; Original width of the sprite when it was loaded 
    RealHeight.w  ; Original height of the sprite when it was loaded 
    ClipX.w       ; X offset if ClipSprite() 
    ClipY.w       ; Y offset if ClipSprite() 
  EndStructure 

  Structure PB_ScreenMode 
    ScreenModeWidth.w        ; Width of the Screen (in pixel) 
    ScreenModeHeight.w        ; Height of the Screen (in pixel) 
    ScreenModeDepth.w        ; Depth of the Screen (in bits per pixel) 
    ScreenModeRefreshRate.w  ; Refresh rate of the Screen (in Hz) 
  EndStructure 


  ; DirectDraw7 Structures: 
  Structure DDPIXELFORMAT 
    dwSize.l 
    dwFlags.l 
    dwFourCC.l 
    dwRGBBitCount.l 
    dwRBitMask.l 
    dwGBitMask.l 
    dwBBitMask.l 
    dwRGBAlphaBitMask.l 
  EndStructure 

  Structure DDCOLORKEY 
    dwColorSpaceLowValue.l 
    dwColorSpaceHighValue.l 
  EndStructure 

  Structure DDSCAPS2 
    dwCaps.l 
    dwCaps2.l 
    dwCaps3.l 
    dwCaps4.l 
  EndStructure 

  Structure DDSURFACEDESC2 
    dwSize.l 
    dwFlags.l 
    dwHeight.l 
    dwWidth.l 
    lPitch.l 
    dwBackBufferCount.l 
    dwRefreshRate.l 
    dwAlphaBitDepth.l 
    dwReserved.l 
    lpSurface.l 
    ddckCKDestOverlay.DDCOLORKEY 
    ddckCKDestBlt.DDCOLORKEY 
    ddckCKSrcOverlay.DDCOLORKEY 
    ddckCKSrcBlt.DDCOLORKEY 
    ddpfPixelFormat.DDPIXELFORMAT 
    ddsCaps.DDSCAPS2 
    dwTextureStage.l 
  EndStructure 

  ----------------------------------------------------------------------- 
  Sprite3D
  -------- 
  
  _PB_D3DBase               ; IDirect3D7 
  _PB_Direct3D_Device       ; IDirect3DDevice7 
  _PB_Direct3D_Start3DState ; contains 1 if Start3D() was successfully called (Start3D() creates the D3DDevice7) 
  _PB_3DViewPort       ; points to a D3DVIEWPORT7 structure 
  _PB_Sprite3D_Quality       ; the value set by Sprite3DQuality(Quality) 
  _PB_Sprite3D_Objects 

  Structure PB_Sprite3D 
    Texture.IDirectDrawSurface7 ; DirectDrawSurface7 
    Vertice.D3DTLVERTEX[4]      ; The 4 vertices for the rectangle sprite 
    Width.w         ; width set with ZoomSprite3D() 
    Height.w         ; height set with ZoomSprite3D() 
    unknown.l 
  EndStructure 

  ; Direct3D7 structures: 
  Structure D3DTLVERTEX 
      sx.f            ; X value of the vertex (in pixels) 
      sy.f            ; Y value of the vertex (in pixels) 
      sz.f 
      rhw.f         ; reciprocal of homogeneous w 
      color.l         ; diffuse color 
      specular.l      ; specular color 
      tu.f            ; horizontal texture coordinate of the vertex 
      tv.f            ; vertical texture coordinate of the vertex 
  EndStructure 

  Structure D3DVIEWPORT7 
    dwX.l 
    dwY.l 
    dwWidth.l 
    dwHeight.l 
    dvMinZ.f 
    dvMaxZ.f 
  EndStructure 

  ----------------------------------------------------------------------- 
  Sprite OpenGL Subsystem
  ----------------------- 

  _PB_Sprite_ObjectsNumber   ; number of entries in _PB_Sprite_ObjectsArea 
  _PB_Sprite_ObjectsArea        ; pointer to an array of PB_Sprite elements 

  _PB_Screen_RealWidth        ; width of the back buffer 
  _PB_Screen_RealHeight       ; height of the back buffer 
  _PB_Screen_Window           ; ScreenID() (HWND) 
  _PB_Screen_Windowed 
  _PB_Screen_Target 

  _PB_Screen_IsActive 
  _PB_Screen_WindowedYOffset 
  _PB_Screen_WindowedXOffset 
  _PB_Screen_AutoStretch 
  _PB_Screen_WindowedRightBorder 
  _PB_Screen_WindowedBottomBorder 

  _PB_DirectX_SaveAllSpritesSurfaces ; ? 

  _PB_Sprite_ColorKey 
  _PB_Sprite_SpecialEffectMode 

  ; Internal functions 
  _PB_Sprite_EnumerateAll 
  _PB_Sprite_FreeID 
  _PB_Sprite_GetObject 
  _PB_Sprite_GetOrAllocateID 
  _PB_Sprite_ListFirstElement 

  _PB_Sprite_CreateEmptySprite@20 
  _PB_Sprite_CleanUpAll@0 
  _PB_Sprite_SetPixelFormat@0 


  Structure PB_Sprite 
    Texture.l     ; SpriteID 
    Width.w       ; Current width of the sprite (could change if ClipSprite() is used) 
    Height.w      ; Current height of the sprite (could change if ClipSprite() is used) 
    Depth.w       ; depth of the file. (in bits)  
    Mode.w        ; Sprite mode, as described in LoadSprite() 
    FileName.l    ; Pointer on the filename, if any 
    RealWidth.w   ; Original width of the sprite when it was loaded 
    RealHeight.w  ; Original height of the sprite when it was loaded 
    ClipX.w       ; X offset if ClipSprite() 
    ClipY.w       ; Y offset if ClipSprite() 
  EndStructure 

  ----------------------------------------------------------------------- 
  Sprite3D OpenGL Subsytem
  ------------------------ 

  _PB_Direct3D_Device        ; contains everytime zero 
  _PB_Sprite3D_Quality        ; the value set by Sprite3DQuality(Quality) 
  _PB_Sprite3D_ObjectsNumber ; number of entries in _PB_Sprite3D_ObjectsArea 
  _PB_Sprite3D_ObjectsArea   ; pointer to an array of PB_Sprite3D elements 
  _PB_Sprite3D_CurrentDC 

  ; internal functions: 
  _PB_Sprite3D_FreeID 
  _PB_Sprite3D_GetObject 
  _PB_Sprite3D_GetOrAllocateID 
  _PB_Sprite3D_CurrentObject 
  _PB_Sprite3D_ListFirstElement 

  
  Structure GLVERTEX2D 
    X.f       ; X value of the vertex (in pixels) 
    Y.f         ; Y value of the vertex (in pixels) 
  EndStructure 

  Structure PB_Sprite3D 
    Texture.l              ; SpriteID ( the same as PeekL(IsSprite3D(#Sprite)) ) 
    Vertice.GLVERTEX2D[4]  ; The 4 vertices for the rectangle sprite 
    Width.w                ; width set with ZoomSprite3D() 
    Height.w              ; height set with ZoomSprite3D() 
    Unknown.l 
  EndStructure 
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3942
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Post by wilbert »

Thanks. That really helped :D

Do you know if there's also a way to get the DC of the current Window without the need of creating a gadgetlist like El Choni suggested ?

I tried if there was a similar way like _PB_Window_GlobalStructure but that didn't work. By the way, where did you find that information ? The information I see in the library descriptor file is still from 3.9x .
User avatar
eddy
Addict
Addict
Posts: 1479
Joined: Mon May 26, 2003 3:07 pm
Location: Nantes

Post by eddy »

nice
Imagewin10 x64 5.72 | IDE | PB plugin | Tools | Sprite | JSON | visual tool
Post Reply