HUGRPI
Mar 13, 2017 1:17:04 GMT 1
Post by alexfish on Mar 13, 2017 1:17:04 GMT 1
Hi All
hugrpi.bac
First beta Release::
this lib is for Raspberry(PI) only
Implements
EGL canvas in 2d & 3d
255 Reusable textures (To free existing TEXTURE Use 'CLEARTEXTURE(int tex)')
FONTS
CleanUp textures and fonts & de-init canvas
Bug reports can be posted here
any other Post on the Main Raspberry PI(3) thread
there are two archives , the hugrpi.bac and an svg image file ' a tiger head for testing
a Second beta Release:: will have the canvas widgets added
BR
Alex
a bit of code to get started
hugrpi.bac
First beta Release::
this lib is for Raspberry(PI) only
Implements
EGL canvas in 2d & 3d
255 Reusable textures (To free existing TEXTURE Use 'CLEARTEXTURE(int tex)')
FONTS
CleanUp textures and fonts & de-init canvas
Bug reports can be posted here
any other Post on the Main Raspberry PI(3) thread
there are two archives , the hugrpi.bac and an svg image file ' a tiger head for testing
a Second beta Release:: will have the canvas widgets added
BR
Alex
a bit of code to get started
INCLUDE hugrpi.bac
HUGOPTIONS("NOSCALING")
'declare texture ;; texture array[pointer] 0 to 255
CONST TEX1=0
CONST TEX2=1
'===============================================================================
SUB GoDraw()
LOCAL img$
LOCAL rotz = 65 TYPE int
LOCAL rot TYPE float
LOCAL fs
LOCAL rot2 TYPE float
img$= MKSTR(<svg width="60" height="60"><rect x="5" y="5" rx="6" ry="6" \
width="50" height="50" fill="red" stroke="black" stroke-width="2" /></svg>)
SVGLOAD(img$,TEX1)
TEXTURE("./23.svg",TEX2)
WHILE 1 DO
IF KEY() == 65307 THEN
QUIT
END
ENDIF
CLS(win)
'Draw BACKGROUND with opacity / Alpha
VIEW(win,HGL_2D_ORTHO)
INK(0,0,255,190)
'RECT(xpos,ypos,width,height,fill)
RECT(0,0,canvas.width,canvas.height,1)
INK(255,255,255,255)
'DrawTextLine(window,font$, xpos, ypos, width, height, spacing)
DRAWTEXT(win,"Press Esc to Quit",0,0,50,50,10)
DRAWTEXT(win,"BaSiC Basic @~",0,30,70,70,13)
DRAWTEXT(win,"BaCon BASIC £ free",0,60,70,70,13)
VIEW(win,HGL_2D_ORTHO)
INK(0,255,0,100)
MOVE(200,200)
ROTATE(rot)
'CIRCLE( xsize, ysize, fill)
CIRCLE(100,50,1)
INK(255,255,255,255)
DRAWTEXTURE2D(win,TEX1,0,100,50,50,-27,rot,0,0)
'glEnable(GL_TEXTURE_2D)
DRAWTEXTURE2D(win,TEX1,30,170,50,50,-27,0,rot,0)
BINDTEXTURE( TEX2)
'the viewport settings & distance Experiment to get required Perspective
' if drawing a scene keep view port the same & move
'SUB SETCUBE( win, xpos, ypos, width,height, transx, transy, -dist, rotate x, rotate y, rotate z )
SETCUBE(win,0,0,canvas.width,canvas.height,-10,-20,-100,rot2/2,rot2/3,rot2/2)
DRAWCUBEFACE (FRONT_FACE)
DRAWCUBEFACE (BACK_FACE)
DRAWCUBEFACE (TOP_FACE)
DRAWCUBEFACE (BOTTOM_FACE)
DRAWCUBEFACE (LEFT_FACE)
DRAWCUBEFACE (RIGHT_FACE)
SETCUBE(win,0,0,canvas.width,canvas.height,30,10,-100,rot2/2,rot2/3,rot2/2)
DRAWCUBEFACE (FRONT_FACE)
DRAWCUBEFACE (BACK_FACE)
DRAWCUBEFACE (TOP_FACE)
DRAWCUBEFACE (BOTTOM_FACE)
DRAWCUBEFACE (LEFT_FACE)
DRAWCUBEFACE (RIGHT_FACE)
'POLY(width,height,sides >1,fill)
VIEW(win,HGL_2D_ORTHO)
INK(0,255,255,190)
MOVE(300,180)
ROTATE(-rot)
POLY(100,100,6,0)
VIEW(win,HGL_2D_ORTHO)
INK(255,0,0,255)
LINEWIDTH(2)
'LINE(xpos1,ypos1,xpos2,ypos2)
LINE(0,0,canvas.width,canvas.height)
POINTSIZE(4)
VIEW(win,HGL_2D_ORTHO)
INK(255,255,0,255)
MOVE(200,200)
ROTATE(-rot)
'SQUARE( xsize, ysize, fill)
SQUARE(40,40,0)
LINEWIDTH(1)
POINTSIZE(1)
'CBEZIER (float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3,float st)
'QBEZIER (float x0, float y0, float x1, float y1, float x2, float y2, float st)
' Draw crosshair at mouse
IF (MOUSE(0) >= 0 AND MOUSE(1)>= 0) THEN
INK(0,0,0,255)
SETCURSOR(win)
POLY(12,1,2,0)
ROTATE(90)
POLY(12,1,2,0)
END IF
'Swap Buffers
DRAW
INCR rot2
INCR rot, 2
IF (rot >=360) THEN
rot= 0
END IF
WEND
END SUB
'===============================================================================
' Main
'===============================================================================
'CURRENCY MUST BE DECLARE in Main
CURRENCY$="£"
'window and canvas
win = WINDOW("Test Win",600,400)
WINCURSOR(win,30)
CANVAS(20,20,560,360)
' window and canvas must be defined before a call the fullscreen mode
SET(win,1)
' test move & resize CANVAS
MOVECANVAS(100,100)
RESIZECANVAS(700,700)
GoDraw