2D API N00b question

I am trying to learn the 2D API for a custom UI I am working on and can’t get anything to draw on the canvas. What am I doing wrong ?

This is supposed to draw a solid yellow rectangle at the top of the screen


sub main()

 screen = CreateObject("roScreen",true)
 screen.DrawRect(0, 0, 1280, 121, &hFFFF00FF)
 screen.Finish() 
 
 msgport = CreateObject("roMessagePort")
 screen.SetMessagePort(msgport)
 
 pressedState = -1 ' If > 0, is the button currently in pressed state
 
 ' Start our event loop
  
   while true
	if pressedState = -1 then
	    msg=wait(0, msgport)   ' wait for a button press
	else
	    msg=wait(1, msgport)   ' wait for a button release or move in current pressedState direction 
	endif
        if type(msg)="roUniversalControlEvent" then
                keypressed = msg.GetInt()
                print "keypressed=";keypressed
        end if
    end while

end sub

You created a double buffered screen. You need to call swapbuffers() instead of Finish() on your screen.

  • Joel

Welcome to the 2D API Jungle! :sunglasses: