GTK + Canvas: How to???

BlitzMax Forums/Brucey's Modules/GTK + Canvas: How to???

danvari(Posted 2008) [#1]
hello!

just go and try the following code:

Framework bah.gtkmaxgui
Import brl.eventqueue
Import brl.max2d


Local window:Tgadget = CreateWindow("test", 0, 0, 300, 300)
Local canvas:tgadget = CreateCanvas(10, 10, 200, 200, window)
SetGraphics(CanvasGraphics(canvas))
Repeat
	WaitEvent()

	Select EventID()
		Case EVENT_GADGETPAINT
			Cls()

			Flip()
	End Select

Until KeyDown(key_escape)





for me it does not work at all. error message: cls() tries to access to a null object...??


SebHoll(Posted 2008) [#2]
You need to import one of the max2d drivers:

e.g. use...

Framework bah.gtkmaxgui
Import brl.eventqueue
Import brl.glmax2d
... for the OpenGL graphics driver.


danvari(Posted 2008) [#3]
ah yes thank you that worked for me :) :)


danvari(Posted 2008) [#4]
no gtk + canvas does not work :-\

this here is just a sample code:

Framework bah.gtkmaxgui
'Framework brl.fltkmaxgui
Import brl.glmax2d
Import brl.eventqueue

Local window:TGadget = CreateWindow("Minesweeper vX", 100, 100, 500, 500)
Local canvas:Tgadget = CreateCanvas(10, 10, 450, 450, window)
Local tiles:TImage = LoadAnimImage("media\default.png", 24, 24, 0, 4)
Local map:TBlock[20,30]
If tiles=Null Then Print "NOFILE"; End

For Local i% = 0 To 19
	For Local k% = 0 To 29
		map[i, k] = New TBlock
	Next
Next

SetGraphics CanvasGraphics(canvas)

Repeat
	
	WaitEvent()

	Select EventID()

		Case EVENT_WINDOWCLOSE
			End

		Case EVENT_GADGETPAINT
			Cls()
			
			For i = 0 To 19
				For k = 0 To 29
					If map[i, k].Open = True Then DrawImage tiles, 24*i, 24*k, 1 Else DrawImage tiles, 24*i, 24*k, 0
				Next
			Next

			Flip()

	End Select

Forever

Type TBlock
	Field Open% = False
	Field Bomb% = False
	Field Flag% = False
End Type


in fltk it works for me, it loads my png file and prints it to the canvas. in gtk it just draws a black screen :(.


Brucey(Posted 2008) [#5]
What about the glcube.bmx test that you can find in the tests folder of the module?

There's also one called createcanvas.bmx in there.


danvari(Posted 2008) [#6]
yes and no. i had to import eventqueue in both of them. glcube.bmx does work for me, but it is using glgraphics and i want to use max2d. though i tried createcanvas.bmx and i did not work for me. it starts, outputs some debug info and thats all...:

...
TimerTick: data=480, mods=0, x=0, y=0, extra=""
GadgetPaint: data=0, mods=0, x=0, y=0, extra=""
TimerTick: data=481, mods=0, x=0, y=0, extra=""
GadgetPaint: data=0, mods=0, x=0, y=0, extra=""
TimerTick: data=482, mods=0, x=0, y=0, extra=""
GadgetPaint: data=0, mods=0, x=0, y=0, extra=""
TimerTick: data=483, mods=0, x=0, y=0, extra=""
GadgetPaint: data=0, mods=0, x=0, y=0, extra=""
TimerTick: data=484, mods=0, x=0, y=0, extra=""
GadgetPaint: data=0, mods=0, x=0, y=0, extra=""
TimerTick: data=485, mods=0, x=0, y=0, extra=""
...


and so on. it opens up a very very small "window" (it so small, that you cant even talk of a window), just 1x4 pixels or so.


SebHoll(Posted 2008) [#7]
it opens up a very very small "window" (it so small, that you cant even talk of a window), just 1x4 pixels or so.

I too have noticed this behaviour with the GTKMaxGUI module - I reported it a while back with a few other bugs in this thread *click*.