mojo2 image/canvas creation order

Monkey Forums/Monkey Bug Reports/mojo2 image/canvas creation order

DruggedBunny(Posted 2015) [#1]
Not sure it's clear from the docs, but you can't load images before creating a main 'window' canvas.

You also can't create an image canvas prior to creating the 'window' canvas.

Examples:


' OK!

		' Main display canvas...
		
		display			= New Canvas		
		display.SetProjection2d 0.0, display.Width * SCALE, 0.0, display.Height * SCALE

		' Load images...
		
		boing			= Image.Load ("boing.png", 0.5, 0.5, 0)
		background		= Image.Load ("background.png", 0.0, 0.0, 0)
		
		' Scaled render target...
		
		rendertarget	= New Image (display.Width * SCALE, display.Height * SCALE, 0.0, 0.0, 0)
		renderbuffer	= New Canvas (rendertarget)
		renderbuffer.SetProjection2d 0, display.Width, 0, display.Height
		



' Not OK...

		' Load images...
		
		boing			= Image.Load ("boing.png", 0.5, 0.5, 0)
		background		= Image.Load ("background.png", 0.0, 0.0, 0)
		
		' Main display canvas...
		
		display			= New Canvas		
		display.SetProjection2d 0.0, display.Width * SCALE, 0.0, display.Height * SCALE

		' Scaled render target...
		
		rendertarget	= New Image (display.Width * SCALE, display.Height * SCALE, 0.0, 0.0, 0)
		renderbuffer	= New Canvas (rendertarget)
		renderbuffer.SetProjection2d 0, display.Width, 0, display.Height
		



' Not OK!

		' Scaled render target...
		
		rendertarget	= New Image (display.Width * SCALE, display.Height * SCALE, 0.0, 0.0, 0)
		renderbuffer	= New Canvas (rendertarget)
		renderbuffer.SetProjection2d 0, display.Width, 0, display.Height
		
		' Main display canvas...
		
		display			= New Canvas		
		display.SetProjection2d 0.0, display.Width * SCALE, 0.0, display.Height * SCALE

		' Load images...
		
		boing			= Image.Load ("boing.png", 0.5, 0.5, 0)
		background		= Image.Load ("background.png", 0.0, 0.0, 0)
		


This is the project I'm playing with:

http://www.hi-toro.com/monkey/scaletest.zip


ImmutableOctet(SKNG)(Posted 2015) [#2]
Mark brought this up before, and has said he plans to fix it. The exact quote can be found in his initial post for Mojo 2:

Note: there's already one bug in there I forgot to fix - you MUST create a canvas (or renderer) before using any other mojo2 classes, as this is where initialization is performed. Will fix, although I am sure there will be other issues...



Still, worth bringing up again, I guess.


DruggedBunny(Posted 2015) [#3]
Ah, I remember reading that now -- many thanks!


marksibly(Posted 2015) [#4]
Oops, keep forgetting to fix this sorry...