Page 1 of 4
WndProc?
Posted: Wed Jan 21, 2009 10:47 pm
by marksibly
Hi,
I'm trying to create a custom Wndproc for a window - the code looks like this:
Code: Select all
Procedure WinCallback( hwnd,msg,wp,lp )
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
OpenWindow( 0,32,32,640,480,"Blitz3D Window",#PB_Window_SystemMenu )
SetWindowCallback( @WinCallback,0 )
Repeat
Select WindowEvent()
Case #PB_Event_CloseWindow
End
EndSelect
ForEver
However, this just 'hourglasses' and eventually does a 'window not responding'...
If I remove SetWindowCallback, it works as expected, so am I missing something in WinCallback?
Bye!
Mark
Posted: Wed Jan 21, 2009 10:49 pm
by srod
Posted: Wed Jan 21, 2009 10:52 pm
by marksibly
Thanks!
(ps: this forum doesn't work too well in Chrome...)
Posted: Wed Jan 21, 2009 10:53 pm
by srod
marksibly wrote:Thanks!
(ps: this forum doesn't work too well in Chrome...)
Then don't use Chrome!

Posted: Wed Jan 21, 2009 11:13 pm
by netmaestro
Mark Sibly...? I find it hard to believe that a coder of Mark's advanced skills would ask a question of this nature, so may I assume you aren't him? If not, why use his name for a nick

Posted: Wed Jan 21, 2009 11:19 pm
by Fluid Byte
Mark Sibly? Wtf? This is some kind of bad joke?
For those of you who don't know ...
Mark Sibly is the lead developer of Blitz Basic!
Just a coincidence? Hard to believe ...
Posted: Wed Jan 21, 2009 11:28 pm
by marksibly
Hi,
Yep it's me - fearlessly asking stupid questions if it'll save me a bit of time! And, the missing '()' from the function wasn't exactly *obvious* (IMHO).
Anyway, I'm just working on Blitz3DSDK's 'render direct to hwnd' code and have it going quite nicely now:
Code: Select all
IncludeFile "../include/blitz3dsdk.pbi"
Global suspended=0
Procedure WinCallback( hwnd,msg,wparam,lparam )
Select msg
Case #WM_PAINT ;A reasonably sane place to validate graphics...
Select bbValidateGraphics()
Case 0
;graphics are unavailable
;(eg: another app has gone fullscreen)
suspended=1
Case -1
;graphics are *borked*
;(eg: desktop resolution has changed in windowed mode)
Print( "FATAL GRAPHICS PROBLEM" )
End
Default
;>0, graphics are OK.
;(returned value is number of times graphics have been 'restored').
If suspended
;this refreshes graphics if app is suspended
;(just keeps window 'clean' when bits are revealed - not really necessary in fullscreen)
bbFlip( 0 )
EndIf
EndSelect
Case #WM_ERASEBKGND
; ProcedureReturn 1
Case #WM_ACTIVATEAPP
If wparam
suspended=0
Else
suspended=1
EndIf
Case #WM_CLOSE
End
EndSelect
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
OpenWindow( 0,32,32,640,480,"Blitz3D Window",#PB_Window_SystemMenu|#PB_Window_ScreenCentered )
SetWindowCallback( @WinCallback(),0 )
bbBeginBlitz3DEx( WindowID( 0 ),0 )
;bbGraphics3D( 640,480,32,1 )
bbGraphics3D( 640,480,0,2 )
;Create a brush
tex=bbCreateTexture( 64,64 )
bbScaleTexture( tex,0.125,0.125 )
bbSetBuffer( bbTextureBuffer( tex ) )
bbColor( 64,192,255 )
bbRect( 32,0,32,32 )
bbRect( 0,32,32,32 )
bbColor( 255,255,255 )
bbRect( 0,0,32,32 )
bbRect( 32,32,32,32 )
bbSetBuffer( bbBackBuffer() )
bbColor( 255,255,255 )
brush=bbCreateBrush()
bbBrushTexture( brush,tex,0,0 )
;Create a camera
camera=bbCreateCamera()
bbCameraClsColor( camera,128,0,255 )
bbPositionEntity( camera,0,0,-6 )
;Create a light
light=bbCreateLight()
bbTurnEntity( light,45,45,0 )
;Create a cube
cube=bbCreateCube()
bbPaintEntity( cube,brush )
Repeat
Repeat
While suspended
WaitWindowEvent()
Wend
While WindowEvent()
Wend
Until Not suspended
;App is up and running!
bbTurnEntity( cube,0,3,0 )
bbUpdateWorld()
bbRenderWorld()
bbFlip( 1 )
ForEver
Only one question:
With WM_ERASEBKGND, you're meant to return '1' if window was erased. However, I'm not returning values to Win32 but to PB (correct?), so how can I do this?
It doesn't really matter, it all runs sweetly without WM_ERAASEBKGND handling, I'm just curious really...
Posted: Wed Jan 21, 2009 11:30 pm
by netmaestro
Firstly, WELCOME!!! Great to have someone of your stature aboard, truly!
I'm not returning values to Win32 but to PB (correct?)
Because you're returning the value from a callback, it is being returned to Win32, never fear.
Posted: Wed Jan 21, 2009 11:32 pm
by Kaeru Gaman
<offtopic>
marksibly wrote:Yep it's me - fearlessly asking stupid questions if it'll save me a bit of time!

... you made my day!
btw... Welcome.
</offtopic>
Posted: Thu Jan 22, 2009 12:25 am
by netmaestro
Also offtopic, if you were to release your B3DSDK as a PureBasic user library, it would sell pretty well here imho. I know I'd buy it.
Posted: Thu Jan 22, 2009 2:59 am
by Mistrel
Welcome, Mark. I'm glad to see people getting excited over games in PureBasic. We need more stimulus in this area.
Do you have an ETA on when this might be available?
Posted: Thu Jan 22, 2009 4:26 am
by Rook Zimbabwe
Hi Mark! I have always believed in the stupid / silly question! I ask them frequently!
There was a bit of work on this previously as well... some of the ideas therein might help / inspire you:
http://www.purebasic.fr/english/viewtop ... =word+wrap
I can't locate the two others... but I am bad at searching!

Posted: Thu Jan 22, 2009 11:21 am
by PB
Hmm, so many people quick to believe it's Mark with no proof but his word?
Would you also believe it was Bill Gates if he came here and said it was him?
See the analogy? I severely doubt it's Mark. As if someone from a competing
language would come here and start asking the most simple of questions.
Think about it, guys! :roll:
Posted: Thu Jan 22, 2009 12:12 pm
by Mark.s
@PB
I don't believe too, are that person real "Mark Sibly". Well its not a matter, if that person not are real "Mark Sibly".
But hoax is always bad.
Well nobody can be sure who is it in real life. But anyways, if marksibly is real "Mark Sibly", i say welcome, otherwise i say nothing. Well people need proofs and whitout proofs some words are nothing in internet.
In my opinion its weird, if a BlitzBasic creator ask simple questions. Not sure if that are simple.
pdwyer wrote:Storm in a teacup

No i am not are "Mark Sibly". Well that ".s" just coming from "string" to last part of my nickname.
Posted: Thu Jan 22, 2009 12:54 pm
by pdwyer
Maybe that's because YOU are the real Mark Sibly and know it's an imposter!!

A doppleganger! <Gasp> Thinly disguised behind a "Mark.s" name. Where's Scooby Doo to expose the truth?

Storm in a teacup
