Canvas size limited to 1024x768 ?

BlitzMax Forums/BlitzMax Beginners Area/Canvas size limited to 1024x768 ?

hub(Posted 2006) [#1]
Canvas size seems limited to 1024x768 ?
Try this :

Const WWX = 1024
Const WWY = 768

Const W = 2048 ' Canvas Size work only with
Const H = 1024  ' W=1024 and H=768

Local window:TGadget=CreateWindow("",0,0,WWX,WWY, Null, WINDOW_MENU|WINDOW_TITLEBAR)
Local panel:Tgadget = CreatePanel(10,10,WWX-40,WWY-80,window,PANEL_ACTIVE)

Global canvas:TGadget=CreateCanvas(0,0,W,H,panel)


While WaitEvent()
	Select EventID()
		Case EVENT_TIMERTICK
			RedrawGadget canvas

		Case EVENT_GADGETPAINT
			SetGraphics CanvasGraphics(canvas)
			Cls
			SetColor 255,255,255
			'...
			Flip
			
		Case EVENT_WINDOWCLOSE
				FreeGadget canvas
				End

		Case EVENT_APPTERMINATE
			End
	End Select

Wend



Azathoth(Posted 2006) [#2]
I just increased the window size and it worked, I had to set W down because 2048 is too big for my monitor.


hub(Posted 2006) [#3]
In fact i want scroll the canvas inside the windows !


hub(Posted 2006) [#4]
Try this (scrollbars)
Const WWX = 800
Const WWY = 600

Const W = 1024 'not work with 2048x1024 !
Const H = 768

Local window:TGadget=CreateWindow("",0,0,WWX,WWY, Null, WINDOW_MENU|WINDOW_TITLEBAR)

Local panel:Tgadget = CreatePanel(10,10,WWX-40,WWY-80,window,PANEL_ACTIVE)
SetGadgetLayout panel,1,1,1,1
SetPanelColor panel,100,0,200

Local sv:Tgadget = CreateSlider(WWX-30,10,20,WWY-80,window,SLIDER_VERTICAL)
Local sh:Tgadget = CreateSlider(10,WWY-70,WWX-40,20,window,SLIDER_HORIZONTAL)

Global canvas:TGadget=CreateCanvas(0,0,W,H,panel)

SetSliderRange sv,ClientWidth(panel),GadgetWidth(canvas)
SetSliderRange sh,ClientHeight(panel),GadgetHeight(canvas)

While WaitEvent()
	Select EventID()
		Case EVENT_TIMERTICK
			RedrawGadget canvas

		Case EVENT_GADGETPAINT
			SetGraphics CanvasGraphics(canvas)
			Cls
			SetColor 255,255,255
			'...
			Flip
			
			SetGadgetShape canvas,-SliderValue(sh),-SliderValue(sv),GadgetWidth(canvas),GadgetHeight(canvas)
			
			
		Case EVENT_MOUSEMOVE

			SetSliderRange sh,ClientWidth(panel),GadgetWidth(canvas)
			SetSliderRange sv,ClientHeight(panel),GadgetHeight(canvas)
			SetGadgetShape canvas,-SliderValue(sh),-SliderValue(sv),GadgetWidth(canvas),GadgetHeight(canvas)
			
			
		Case EVENT_WINDOWCLOSE
				FreeGadget canvas
				End

		Case EVENT_APPTERMINATE
			End
	End Select

	
Wend



hub(Posted 2006) [#5]
I've adapted the code from a blitzplus program. With blitzplus, you can use large canvas (2048x1024) and more ! bmax limitation ? No info about this into the documentation.


Scienthsine(Posted 2006) [#6]
Scrolling a canvas isn't needed, as you can just scroll what's be drawn on the canvas...


hub(Posted 2006) [#7]
@Scienthsine : my prog is a spline editor (path for enemies). For a 1024x768 in-game resolution i need a 1224x1224 working area to position some spline points outside the game area. Perhaps a solution will be to use a large image and scroll it.


hub(Posted 2006) [#8]
uhm... the large image seems not be the solution. if i do this i can't use command like 'drawline' ! With an image you can only use writepixel !

image=CreateImage(256,1)
map=LockImage(image)
For i=0 To 255
	WritePixel(map,i,0,ALPHABITS|i)
Next
UnlockImage(image)

DrawImageRect image,0,0,640,480



Scienthsine(Posted 2006) [#9]
You only need a canvas as big as what you can display at any one time. Use Scroll bars, and offset your drawing onto the canvas by the scollbars. Yes, somethings won't be drawn because they will run over the canvas, but they would be seen at that point anyway... *sigh*

It's as smiple as making 2 scrollbars. Make the value range for the scrollbars to their 'working size'-'canvas actual size'. Then, to all of your drawing commands, subtract the scrollbar's current value from it's draw position.


Fabian.(Posted 2006) [#10]
This sounds like there can only be displayed 1024*768 pixels at one time, doesn't it?
But there also screens with 1280*1024 pixels or more.
And some Windows systems allow you to have more than one screen in a system - if you've two screens with each 1280*1024 pixels, one left, one right, you'll have 2560*1024 pixels.


Mark Tiffany(Posted 2006) [#11]
I think you are limited to the current screen res for your canvases. Or possibly the highest res that your gfx card can support?


Fabian.(Posted 2006) [#12]
But think of the RedrawGadget example:

If the user resizes the window the canvas will be resized too because of its layout. So the user could resize the canvas to sizes bigger than screen resultion and the canvas would "freeze".


Dreamora(Posted 2006) [#13]
That is normal behavior at least for OpenGL which does not support to have higher "canvas" than the actual screensize.