Skip to content

Instantly share code, notes, and snippets.

@muspellsson
Created February 27, 2015 08:00
Show Gist options
  • Save muspellsson/0ff23dd3f7c459f0e222 to your computer and use it in GitHub Desktop.
Save muspellsson/0ff23dd3f7c459f0e222 to your computer and use it in GitHub Desktop.
! Copyright (C) 2015 Your name.
! See http://factorcode.org/license.txt for BSD license.
USING: kernel ui.gadgets ui.render ui.gadgets.worlds opengl opengl.gl colors ;
IN: draw-ex
TUPLE: canv < gadget ;
: <canv> ( -- gadget ) canv new ;
M: canv draw-gadget* ( gadget -- )
drop
! [
! -50.0 50.0 -50.0 50.0 -1.0 1.0 glOrtho
! [
! glLoadIdentity
T{ rgba f 1.0 0.0 1.0 1.0 } gl-color
{ 0.0 0.0 } { 0.5 0.5 } gl-fill-rect
! ] do-matrix
! ] do-matrix ;
;
M: canv pref-dim* ( gadget -- dim )
drop { 250 250 } ;
M: canv graft* ( gadget -- )
find-gl-context
0.0 0.0 0.0 1.0 glClearColor
GL_FLAT glShadeModel ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment