It is currently Sat May 25, 2013 6:40 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: Drawing Sprites
PostPosted: Wed Apr 11, 2012 5:26 am 
Offline
Enthusiast
Enthusiast

Joined: Mon Oct 24, 2005 1:05 pm
Posts: 386
Why do all three calls to StartDrawing() return errors? I am using OpenGL on Windows 7.

Code:
result = InitSprite()
If result = 0
  MessageRequester("Error", "Sprites not initialized.")
  End
EndIf

OpenWindow(1, 0, 100, 640, 400, "")
OpenWindowedScreen(WindowID(1), 0, 0, WindowWidth(1), WindowHeight(1), 0, 0, 0)

result = CreateSprite(1, 10, 33)

If result = 0
  MessageRequester("Error", "Sprite not created.")
  End
EndIf

StartDrawing(SpriteOutput(1))
;StartDrawing(SpriteOutput(SpriteID(1)))
;StartDrawing(SpriteID(1))

Delay(5000)

StopDrawing()
CloseWindow(1)

End


Last edited by chris319 on Wed Apr 11, 2012 3:15 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Drawing Sprites
PostPosted: Wed Apr 11, 2012 6:08 am 
Offline
Addict
Addict
User avatar

Joined: Thu Jun 24, 2004 2:44 pm
Posts: 4715
Location: Berlin - Germany
Remove the Delay and add: Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow

_________________
PureBasic 5.11 | Windows 7 SP1 (x64) | Mageia 3 (x64) | RealSource

The use of EnableExplicit is free of charge and avoids errors.


Top
 Profile  
 
 Post subject: Re: Drawing Sprites
PostPosted: Wed Apr 11, 2012 3:14 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon Oct 24, 2005 1:05 pm
Posts: 386
ts-soft wrote:
Remove the Delay and add: Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow

Same error: "The specified output is NULL (0 value)." The call to StartDrawing() fails so it's not even getting to the call to Delay().


Top
 Profile  
 
 Post subject: Re: Drawing Sprites
PostPosted: Wed Apr 11, 2012 6:17 pm 
Offline
Addict
Addict

Joined: Fri Oct 23, 2009 2:33 am
Posts: 2865
Location: Wales, UK
With Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow, works fine here on WinXP 32bit, PB4.60
Compiler sub-system set to OpenGL.

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
 
 Post subject: Re: Drawing Sprites
PostPosted: Wed Apr 11, 2012 6:34 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon Oct 24, 2005 1:05 pm
Posts: 386
IdeasVacuum wrote:
With Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow, works fine here on WinXP 32bit, PB4.60
Compiler sub-system set to OpenGL.

Maybe it's a Windows 7 thing?


Top
 Profile  
 
 Post subject: Re: Drawing Sprites
PostPosted: Wed Apr 11, 2012 6:36 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Jun 24, 2004 2:44 pm
Posts: 4715
Location: Berlin - Germany
chris319 wrote:
Maybe it's a Windows 7 thing?

No, works fine on my Win7. I think, it is a driver problem on your PC.

_________________
PureBasic 5.11 | Windows 7 SP1 (x64) | Mageia 3 (x64) | RealSource

The use of EnableExplicit is free of charge and avoids errors.


Top
 Profile  
 
 Post subject: Re: Drawing Sprites
PostPosted: Wed Apr 11, 2012 8:35 pm 
Offline
User
User

Joined: Sat May 24, 2008 8:51 pm
Posts: 26
Location: U.S.
Hi Chris ... See if this works

Code:
result = InitSprite()
If result = 0
  MessageRequester("Error", "Sprites not initialized.")
  End
EndIf

event = 0

OpenWindow(1, 0, 100, 640, 400, "")
OpenWindowedScreen(WindowID(1), 0, 0, WindowWidth(1), WindowHeight(1), 0, 0, 0)

result = CreateSprite(1, 10, 33)

If result = 0
  MessageRequester("Error", "Sprite not created.")
  End
EndIf

; Lets take the sprite we created and print an "H" on it
StartDrawing(SpriteOutput(result))
  DrawText(0,0,"H")
StopDrawing()
;StartDrawing(SpriteOutput(SpriteID(1)))
;StartDrawing(SpriteID(1))

Repeat
  event = WaitWindowEvent(1)
 
  ClearScreen(RGB(0,0,0))
  DisplaySprite(result,50,50)
 
  FlipBuffers()
Until event = #PB_Event_CloseWindow

;Delay(5000)

End


Sorry but I can only test on Windows XP. The StartDrawing() StopDrawing() command allows you to "draw" on the sprite in real time. If you are trying to load an existing image as a sprite then you wouldn't do the StartDrawing() StopDrawing() stuff to display it.


Top
 Profile  
 
 Post subject: Re: Drawing Sprites
PostPosted: Wed Apr 11, 2012 8:56 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Thu Mar 24, 2011 12:40 am
Posts: 155
Location: Iowa, USA
@bmon
if you are going to use 'result' like this:
Code:
StartDrawing(SpriteOutput(result))

and this:
Code:
DisplaySprite(result,50,50)

then you must use 'PB_Any' like this when you create the sprite:
Code:
result = CreateSprite(#PB_Any, 10, 33)


This works for me on Win. XP.
Code:
result = InitSprite()
If result = 0
  MessageRequester("Error", "Sprites not initialized.")
  End
EndIf

event = 0

OpenWindow(1, 0, 100, 640, 400, "")
OpenWindowedScreen(WindowID(1), 0, 0, WindowWidth(1), WindowHeight(1), 0, 0, 0)

result = CreateSprite(#PB_Any, 10, 33)

If result = 0
  MessageRequester("Error", "Sprite not created.")
  End
EndIf

; Lets take the sprite we created and print an "H" on it
StartDrawing(SpriteOutput(result))
  DrawText(0,0,"H")
StopDrawing()

Repeat
  event = WaitWindowEvent(1)
 
  ClearScreen(RGB(0,0,0))
  DisplaySprite(result,50,50)
 
  FlipBuffers()
Until event = #PB_Event_CloseWindow

;Delay(5000)

End

B.P.


Top
 Profile  
 
 Post subject: Re: Drawing Sprites
PostPosted: Wed Apr 11, 2012 9:15 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon Oct 24, 2005 1:05 pm
Posts: 386
Tried the fixes, still getting an error on StartDrawing().

A driver problem?


Top
 Profile  
 
 Post subject: Re: Drawing Sprites
PostPosted: Wed Apr 11, 2012 9:25 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Apr 27, 2003 8:12 am
Posts: 1620
Location: USA
chris319 wrote:
Tried the fixes, still getting an error on StartDrawing().

A driver problem?

Check out what graphics card you have and update to the latest driver if you can. ;)

_________________
AMD 64 4000+ / 1GB PC2700 / WIN XP Home SP3 / Nvidia GT220 x16 512MB / M-Audio Revolution 5.1
Macbook Air 11.6" - 2010 / OS X 10.8

http://www.posemotion.com
http://www.flashpulse.com


Top
 Profile  
 
 Post subject: Re: Drawing Sprites
PostPosted: Thu Apr 12, 2012 4:18 am 
Offline
User
User

Joined: Sat May 24, 2008 8:51 pm
Posts: 26
Location: U.S.
Thanks B.P. ... Yep, it was a silly mistake on my part. :oops:

Chris ... Sorry that things still aren't working on your end. I hope it turns out to be something simple to correct ...


Top
 Profile  
 
 Post subject: Re: Drawing Sprites
PostPosted: Fri Apr 13, 2012 6:57 am 
Offline
Enthusiast
Enthusiast

Joined: Mon Oct 24, 2005 1:05 pm
Posts: 386
I'm going to try to get transparent images working instead of sprites.


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

All times are UTC + 1 hour


Who is online

Users browsing this forum: Exabot [Bot] and 7 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