It is currently Sun Dec 15, 2019 12:10 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 14 posts ] 
Author Message
 Post subject: Flip Sprite Old school ;o)
PostPosted: Sat Oct 12, 2019 11:09 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Oct 31, 2004 10:54 am
Posts: 768
Location: France
no assembler
no complicated stuff about directX

an old-fashioned code like we do more of it
very simple

probably cross-platform
goodbye transformSprite :lol: :lol: :lol:

Quote:
since the following versions of Purebasic 5.11
this code Bug , if using a subsystem
or DirectX11
or OpenGL

it depends on the users.....

̷w̷h̷i̷l̷e̷ ̷i̷n̷ ̷P̷B̷ ̷5̷.̷1̷1̷ ̷i̷t̷ ̷w̷o̷r̷k̷s̷

rectification
even in version 5.11 it doesn't work with DirectX11





Code:


;***********************************************
;Titre  :*test_transforme_sprite perso
;Auteur  : Dobro
;Date  :12/10/2019
;Heure  :23:50:05
;Version Purebasic :  PureBasic 5.70 LTS (Windows - x86)
;Version de l'editeur :EPB PHOENIX V2.68
; Libairies necessaire : Aucune
;***********************************************


InitSprite()

Enumeration
      #win
      #sprite1
      #sprite2
EndEnumeration

; ********* My Super Procedures LOL  ****************
Declare Scan_Sprite(Num_sprite)
Declare Flip_H_Sprite(Num_sprite)
Declare Flip_V_Sprite(Num_sprite)
Declare Flip_VH_Sprite(Num_sprite)
; ****************************************************



ExamineDesktops()
EcranX=DesktopWidth(0)/2
EcranY=DesktopHeight(0)/2
If InitSprite() = 0 Or InitKeyboard() = 0 Or InitMouse() = 0
      MessageRequester("Erreur", "Impossible d'initialiser l'écran.")
      End
EndIf

OpenWindow(#win,1,1,Ecranx,Ecrany,"yoo Flip", #PB_Window_SystemMenu )
OpenwindowedScreen(WindowId(#win),1,1,EcranX,Ecrany,1,0,0)


; *************** pour l'exemple on creer un sprite fait de 2 box de 2 couleurs differentes ******************
;Sprite 1
CreateSprite(#sprite1,100,100)
StartDrawing(SpriteOutput(#Sprite1))
      box(1,1,64,64,rgb(255,255,0))
      Box(32,32,64,64,rgb(0,255,150))
StopDrawing()
;*******************************************************************************************************

Scan_Sprite(#sprite1)  ;  la premiere des procedures, permet de mettre le sprite en Tableau .... pis c'est les tableaux qu'on va manipuler pour fliper notre sprite
CopySprite(#sprite1,#sprite2)  ; garde une trace du sprite originale dans #sprite2

; boucle principale
Repeat
      Event = WaitWindowEvent(2)
      
      Select Event
      EndSelect
      
      
      ExamineKeyboard()
      
      DisplayTransparentSprite(#sprite2, 10,100)  ; le sprite des origines sans modification
            
      Flip_H_Sprite(#sprite1)  ; on fait un FLip Horizontale
      DisplayTransparentSprite(#sprite1, 10,250)       ; on affiche fierement le resultat
            
      Flip_V_Sprite(#sprite1)  ; on fait un Flip Vertical
      DisplayTransparentSprite(#sprite1, 10,400)      ; on affiche fierement le resulat
      
      Flip_VH_Sprite(#sprite1)  ; la on est fou , on fait carrement un flip Vertical ET horizontal roulement de tambour ....brbrbrbrbrbrbr  tiiiich  !
      DisplayTransparentSprite(#sprite1, 500,100)      ; on affiche le sprite qui ne c'est pas gamélé
      
      ; ici on va afficher le text pour les neuneu qu'aurai pas compris ..... ;o)
      StartDrawing(ScreenOutput())
            DrawText(100,150,"<--- Sprite1  original normal ")
            DrawText(100,300,"<--- Sprite2  flipé horizontalement ")
            DrawText(100,400,"<--- Sprite2  flipé verticalement ")
            DrawText(550,100,"<--- Sprite2  flipé verticalement et horizontalement ")
      StopDrawing()
      
      ;Affichage à l'écran  concretement
      FlipBuffers()
         
Until Event = #PB_Event_CloseWindow







;- **** Zone Procedure ************

Procedure Scan_Sprite(Num_sprite)
      ;By Dobro
      protected w
      Protected h
      w=SpriteWidth(Num_sprite)
      h=SpriteHeight(Num_sprite)
      Global Dim tab_spr(w,h)
      StartDrawing(SpriteOutput(Num_sprite))
            For y=0 to h-1
                  For x=0 to w-1
                        tab_spr(x,y)=point(x,y)   
                  Next x
            Next y
      StopDrawing()
EndProcedure




Procedure Flip_H_Sprite(Num_sprite)
      ;By Dobro
      w=SpriteWidth(Num_sprite)
      h=SpriteHeight(Num_sprite)
      StartDrawing(SpriteOutput(Num_sprite))
            For y=0 to h-1
                  For x= 0 to w-1
                        Plot(x,y,tab_spr(x,h-y))
                  Next x
            Next y      
      StopDrawing()
EndProcedure   


Procedure Flip_V_Sprite(Num_sprite)
      ;By Dobro
      w=SpriteWidth(Num_sprite)
      h=SpriteHeight(Num_sprite)
      StartDrawing(SpriteOutput(Num_sprite))
            For y=0 to h-1
                  For x=0 to w-1      
                        Plot(x,y,tab_spr(w-x,y))
                  Next x
            Next y      
      StopDrawing()
EndProcedure   


Procedure Flip_VH_Sprite(Num_sprite)
      ;By Dobro
      w=SpriteWidth(Num_sprite)
      h=SpriteHeight(Num_sprite)
      StartDrawing(SpriteOutput(Num_sprite))
            For y=0 to h-1
                  For x=0 to w-1      
                        Plot(x,y,tab_spr(w-x,h-y))
                  Next x
            Next y      
      StopDrawing()
EndProcedure   



_________________
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/


Last edited by dobro on Mon Oct 14, 2019 10:48 am, edited 5 times in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Flip Sprite Old school ;o)
PostPosted: Sun Oct 13, 2019 9:39 am 
Offline
User
User

Joined: Mon Jul 17, 2017 7:22 am
Posts: 68
Location: Cotswolds England
This post resulted in something that is of great concern to me. When I opened the post, Google immediately offered the option of using Google Translate. Which means that in the fraction of a second it took to open, in the background Google had ascertained that all of the text in the post was not English! Is there any part of the internet that Google is not monitoring? If it can access any posted item in a relatively small and esoteric forum so easily, how much else is it scanning and downloading from every single internet user? :evil:

Have to say, pretty far from happy about this intrusion. :x :x

_________________
If it's falling over......just remember the computer is never wrong!


Top
 Profile  
Reply with quote  
 Post subject: Re: Flip Sprite Old school ;o)
PostPosted: Sun Oct 13, 2019 10:15 am 
Offline
Addict
Addict
User avatar

Joined: Fri May 12, 2006 6:51 pm
Posts: 2068
Location: Germany
This must be due to your browser settings and google settings (If you have a Google Account)

_________________
My Projects ThreadToGUI / OOP-BaseClass / OOP-BaseClassDispatch / EventDesigner V3
PB v3.30 / v5.70 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace


Top
 Profile  
Reply with quote  
 Post subject: Re: Flip Sprite Old school ;o)
PostPosted: Sun Oct 13, 2019 10:20 am 
Offline
Enthusiast
Enthusiast

Joined: Thu Apr 18, 2019 8:17 am
Posts: 449
mk-soft wrote:
This must be due to your browser settings and google settings (If you have a Google Account)

Yep. I also have a logged-in Google account, but no offer of translation happens for me. Using Firefox. I know Chrome offers real-time translations, so I bet C876 is using Chrome (made by Google) for his browser.


Top
 Profile  
Reply with quote  
 Post subject: Re: Flip Sprite Old school ;o)
PostPosted: Sun Oct 13, 2019 11:46 am 
Offline
User
User

Joined: Mon Jul 17, 2017 7:22 am
Posts: 68
Location: Cotswolds England
Nope.....not using Chrome, never have. Don't have a Google Account. Actually use BRAVE on a Private Window for PureB. The only browsers I use are Brave, Epic & Firefox. Searching only use DuckDuckGo. Mind you don't Google own Firefox?
Could you have inadvertently clicked don't want to see the offer of Google Translate again? The fact is the unwanted offer came up :?

_________________
If it's falling over......just remember the computer is never wrong!


Top
 Profile  
Reply with quote  
 Post subject: Re: Flip Sprite Old school ;o)
PostPosted: Sun Oct 13, 2019 12:50 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu Apr 18, 2019 8:17 am
Posts: 449
C87 wrote:
don't Google own Firefox?

No, Google own Chrome. Firefox is owned by Mozilla.

C87 wrote:
Could you have inadvertently clicked don't want to see the offer of Google Translate again?

Again no, because Firefox doesn't offer translation natively (https://support.mozilla.org/en-US/kb/ho ... re-firefox). You'd need to install a translation extension.


Top
 Profile  
Reply with quote  
 Post subject: Re: Flip Sprite Old school ;o)
PostPosted: Sun Oct 13, 2019 1:36 pm 
Offline
Addict
Addict
User avatar

Joined: Fri May 12, 2006 6:51 pm
Posts: 2068
Location: Germany
@dobro

not running with OpenGL :(

_________________
My Projects ThreadToGUI / OOP-BaseClass / OOP-BaseClassDispatch / EventDesigner V3
PB v3.30 / v5.70 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace


Top
 Profile  
Reply with quote  
 Post subject: Re: Flip Sprite Old school ;o)
PostPosted: Sun Oct 13, 2019 1:46 pm 
Offline
Enthusiast
Enthusiast

Joined: Sat Feb 08, 2014 3:26 pm
Posts: 718
@C87
Maybe you inadvertently accepted a google toolbar?
(check with a tool like CCleaner Tools > Navigator Plug-in)

_________________
(English is not my native language, I use an online translator)
Windows 10 Family x64 + Linux (Slackware, Debian on Oracle VirtualBox 6.0) + Raspberry Pi


Top
 Profile  
Reply with quote  
 Post subject: Re: Flip Sprite Old school ;o)
PostPosted: Sun Oct 13, 2019 11:05 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Oct 31, 2004 10:54 am
Posts: 768
Location: France
mk-soft wrote:
@dobro

not running with OpenGL :(


works with Sous system openGL at home :)
I just added "ClearScreen($0)" after the Flipbuffer()


there is nothing particular in the code, just redraw a sprite using a array.

maybe not put a subsystem ?
at home it's when I use directX11 that it doesn't display anything

you have to ask Fred why
the use of a subsystem can prevent
the display of a simple sprite!
personally, I don't know

_________________
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/


Top
 Profile  
Reply with quote  
 Post subject: Re: Flip Sprite Old school ;o)
PostPosted: Mon Oct 14, 2019 8:35 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Oct 31, 2004 10:54 am
Posts: 768
Location: France
Thanks to C87 for polluting my topic ....
the moderators are on vacation ?

_________________
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/


Last edited by dobro on Mon Oct 14, 2019 10:51 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Flip Sprite Old school ;o)
PostPosted: Mon Oct 14, 2019 8:56 am 
Offline
Addict
Addict

Joined: Thu Aug 30, 2007 11:54 pm
Posts: 1165
Location: right here
ClearScreen() fixes the smearing with OpenGL. And you should process all events per main loop iteration. No problem here with multiple InitSprite() BTW.
Code:
Repeat
      Repeat
        Event = WaitWindowEvent(2)
       
        Select Event
          Case #PB_Event_CloseWindow
            quit = #True
        EndSelect
      Until Not Event()
   
      ClearScreen(0)
     
      [...]
         
Until quit


Top
 Profile  
Reply with quote  
 Post subject: Re: Flip Sprite Old school ;o) [Bug After Pb 5.11 !! ]
PostPosted: Mon Oct 14, 2019 9:01 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Oct 31, 2004 10:54 am
Posts: 768
Location: France
yes I know that ClearScreen() corrects the effect of blurrs
in OpenGL

dobro wrote:
works with Sous system openGL at home :)
I just added "ClearScreen($0)" after the Flipbuffer()


in PB 5.70
but the problem is that with the DirectX11 subsystem
in my house no sprites are displayed!!!



mk-soft has a problem with openGL!
I'm with DirectX11

ps: my system is in DirectX12 look here :
http://michel.dobro.free.fr/forum_gamopat/bug.gif


at the same time, I assume that if we don't specify anything, it must take the DirectX system present on the computer..... (at home DX12)
Just a guess, huh...

and when I put nothing, all works... so......

_________________
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/


Top
 Profile  
Reply with quote  
 Post subject: Re: Flip Sprite Old school ;o) [Bug After Pb 5.11 !! ]
PostPosted: Thu Oct 24, 2019 12:30 am 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2011 10:06 am
Posts: 800
Location: Denmark
@Dobro

There's no bug.
Ive changed your code a bit. It should work with DirectX11 and OpenGL now.

Code:
;***********************************************
;Titre  :*test_transforme_sprite perso
;Auteur  : Dobro
;Date  :12/10/2019
;Heure  :23:50:05
;Version Purebasic :  PureBasic 5.70 LTS (Windows - x86)
;Version de l'editeur :EPB PHOENIX V2.68
; Libairies necessaire : Aucune
;***********************************************


InitSprite()

Enumeration
  #win
  #sprite1
  #sprite2
EndEnumeration

; ********* My Super Procedures LOL  ****************
Declare Scan_Sprite(Num_sprite)
Declare Flip_H_Sprite(Num_sprite)
Declare Flip_V_Sprite(Num_sprite)
Declare Flip_VH_Sprite(Num_sprite)
; ****************************************************

Global Quit = #False

ExamineDesktops()
EcranX=DesktopWidth(0)/2
EcranY=DesktopHeight(0)/2
If InitSprite() = 0 Or InitKeyboard() = 0 Or InitMouse() = 0
  MessageRequester("Erreur", "Impossible d'initialiser l'écran.")
  End
EndIf

OpenWindow(#win,1,1,Ecranx,Ecrany,"yoo Flip", #PB_Window_SystemMenu )
OpenWindowedScreen(WindowID(#win),1,1,EcranX,Ecrany,1,0,0)


; *************** pour l'exemple on creer un sprite fait de 2 box de 2 couleurs differentes ******************
;Sprite 1
CreateSprite(#sprite1,100, 100, #PB_Sprite_AlphaBlending)
StartDrawing(SpriteOutput(#Sprite1))
DrawingMode(#PB_2DDrawing_AlphaBlend)
Box(1,1,64,64,RGBA(255,255,0, 255))
Box(32,32,64,64,RGBA(0,255,150, 255))
StopDrawing()
;*******************************************************************************************************

Scan_Sprite(#sprite1)  ;  la premiere des procedures, permet de mettre le sprite en Tableau .... pis c'est les tableaux qu'on va manipuler pour fliper notre sprite
CopySprite(#sprite1,#sprite2)  ; garde une trace du sprite originale dans #sprite2

; boucle principale
Repeat
  ClearScreen(0)
  Repeat
    Event = WindowEvent()
    If Event = #PB_Event_CloseWindow : Quit = #True : EndIf
  Until Event = 0 
 
  ExamineKeyboard()
 
  DisplayTransparentSprite(#sprite2, 10,100, 255)  ; le sprite des origines sans modification
 
  Flip_H_Sprite(#sprite1)  ; on fait un FLip Horizontale
  DisplayTransparentSprite(#sprite1, 10,250, 255)       ; on affiche fierement le resultat
 
  Flip_V_Sprite(#sprite1)  ; on fait un Flip Vertical
  DisplayTransparentSprite(#sprite1, 10,400, 255)      ; on affiche fierement le resulat
 
  Flip_VH_Sprite(#sprite1)  ; la on est fou , on fait carrement un flip Vertical ET horizontal roulement de tambour ....brbrbrbrbrbrbr  tiiiich  !
  DisplayTransparentSprite(#sprite1, 500,100, 255)      ; on affiche le sprite qui ne c'est pas gamélé
 
  ; ici on va afficher le text pour les neuneu qu'aurai pas compris ..... ;o)
  StartDrawing(ScreenOutput())
  DrawText(100,150,"<--- Sprite1  original normal ")
  DrawText(100,300,"<--- Sprite2  flipé horizontalement ")
  DrawText(100,400,"<--- Sprite2  flipé verticalement ")
  DrawText(550,100,"<--- Sprite2  flipé verticalement et horizontalement ")
  StopDrawing()
 
  ;Affichage à l'écran  concretement
  FlipBuffers()
 
Until Quit = #True

;- **** Zone Procedure ************

Procedure Scan_Sprite(Num_sprite)
  ;By Dobro
  Protected w
  Protected h
  Protected Color
  w=SpriteWidth(Num_sprite)
  h=SpriteHeight(Num_sprite)
  Global Dim tab_spr(w,h)
  StartDrawing(SpriteOutput(Num_sprite))
  DrawingMode(#PB_2DDrawing_AllChannels)
  For y=0 To h-1
    For x=0 To w-1
      Color = Point(x,y)
      tab_spr(x,y)= RGBA(Red(color), Green(color), Blue(color), 255)
    Next x
  Next y
  StopDrawing()
EndProcedure

Procedure Flip_H_Sprite(Num_sprite)
  ;By Dobro
  w=SpriteWidth(Num_sprite)
  h=SpriteHeight(Num_sprite)
  StartDrawing(SpriteOutput(Num_sprite))
  DrawingMode(#PB_2DDrawing_AlphaBlend)
  For y=0 To h-1
    For x= 0 To w-1
      Plot(x,y,tab_spr(x,h-y))
    Next x
  Next y     
  StopDrawing()
EndProcedure   


Procedure Flip_V_Sprite(Num_sprite)
  ;By Dobro
  w=SpriteWidth(Num_sprite)
  h=SpriteHeight(Num_sprite)
  StartDrawing(SpriteOutput(Num_sprite))
  DrawingMode(#PB_2DDrawing_AlphaBlend)
  For y=0 To h-1
    For x=0 To w-1     
      Plot(x,y,tab_spr(w-x,y))
    Next x
  Next y     
  StopDrawing()
EndProcedure   


Procedure Flip_VH_Sprite(Num_sprite)
  ;By Dobro
  w=SpriteWidth(Num_sprite)
  h=SpriteHeight(Num_sprite)
  StartDrawing(SpriteOutput(Num_sprite))
  DrawingMode(#PB_2DDrawing_AlphaBlend)
  For y=0 To h-1
    For x=0 To w-1     
      Plot(x,y,tab_spr(w-x,h-y))
    Next x
  Next y     
  StopDrawing()
EndProcedure   

_________________
“Tell me and I forget. Teach me and I remember. Involve me and I learn.”
— Benjamin Franklin
Current configurations: Windows 7/10, Intel 6800K, Gtx 970, 32 gb ram.


Top
 Profile  
Reply with quote  
 Post subject: Re: Flip Sprite Old school ;o)
PostPosted: Thu Nov 14, 2019 3:49 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Oct 31, 2004 10:54 am
Posts: 768
Location: France
Ok Thanks :)

_________________
Image
Windows 98/7/10 - PB 5.42
■ sites : http://michel.dobro.free.fr/


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye