It is currently Sat Jan 19, 2019 1:10 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: TransformSprite - OpenGL
PostPosted: Sun Mar 13, 2016 8:26 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Jan 10, 2008 1:30 pm
Posts: 1181
Location: Germany, Glienicke
There is a problem with TransformSprite under OpenGL and/or Linux.
The transformation (or the vertices) is incorrect:
Code:
Procedure SpriteTransformation(Sprite.i, X.f, Y.f, Width.f, Height.f, Angle.f)
   Protected Cos.f = Cos(Radian(Angle))
   Protected Sin.f = Sin(Radian(Angle))
   TransformSprite(Sprite, X*Cos-Y*Sin, X*Sin+Y*Cos, (X+Width)*Cos-Y*Sin, (X+Width)*Sin+Y*Cos, (X+Width)*Cos-(Y+Height)*Sin, (X+Width)*Sin+(Y+Height)*Cos, X*Cos-(Y+Height)*Sin, X*Sin+(Y+Height)*Cos)
EndProcedure

InitSprite()

Enumeration
   #Window
   #Sprite
   #Font
EndEnumeration

LoadFont(#Font, "Arial", 24)

OpenWindow(#Window, 0, 0, 800, 600, "ScreenTitle", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(#Window), 0, 0, WindowWidth(#Window), WindowHeight(#Window), 0, 0, 0)

CreateSprite(#Sprite, 200, 50)
If StartDrawing(SpriteOutput(#Sprite))
   DrawingFont(FontID(#Font))
   Box(0, 0, OutputWidth(), OutputHeight(), $808080)
   DrawingMode(#PB_2DDrawing_Transparent)
   DrawText(0, 0, "Pure Basic", $FFFFFF)
   StopDrawing()
EndIf

Repeat
   
   Repeat
      
      Select WindowEvent()
         Case #PB_Event_CloseWindow
            End
         Case #Null
            Break
      EndSelect
      
   ForEver
   
   ClearScreen(0)
   
   SpriteTransformation(#Sprite, 0, 0, 200, 50, ElapsedMilliseconds()/10)
   DisplaySprite(#Sprite, 200, 100)
   
   SpriteTransformation(#Sprite, -100, -25, 200, 50, ElapsedMilliseconds()/10)
   DisplaySprite(#Sprite, 400, 100)
   
   SpriteTransformation(#Sprite, -100, -25, 100, 25, ElapsedMilliseconds()/10)
   DisplaySprite(#Sprite, 600, 100)
   
   FlipBuffers()
   
ForEver


Here are an other link with a code example for TransformSprite, which dosn't work on OpenGL/Linux:
http://www.purebasic.fr/german/viewtopic.php?f=8&t=27127

_________________
ImageImage


Top
 Profile  
Reply with quote  
 Post subject: Re: TransformSprite - OpenGL
PostPosted: Tue Mar 15, 2016 9:18 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Thu Apr 07, 2011 1:14 pm
Posts: 243
Location: 3 arks
Same bad result here (PB 5.42 LTS 64), on windows8, with openGl as subsytem.

It's ok for me with directX9 and directX 11.


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

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 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