What is a Canvas Container?
Posted: Thu Feb 02, 2017 9:44 am
Can someone explain me what a Canvas Container does?
http://www.purebasic.com
https://www.purebasic.fr/english/
Code: Select all
OpenWindow(0, 0, 0, 300, 300, "Canvas Container", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
#Button = 4
CanvasGadget(0, 40, 40, 210, 200, #PB_Canvas_Container)
EditorGadget(1, 0, 0, 200, 30, #PB_Editor_WordWrap)
ButtonGadget(#Button, 0, 40, 60, 40, "Stop/Rot")
OpenGLGadget(2, 0, 105, 100, 100)
CloseGadgetList()
AddGadgetItem(1, 0, "Thats Hot")
;SetActiveGadget(0)
Global run = 1
If StartDrawing(CanvasOutput(0))
Circle(160, 120, 7, RGB(0, 0, 250))
Circle(160, 150, 10, RGB(255, 0, 0))
StopDrawing()
EndIf
x.f=100
If StartDrawing(CanvasOutput(0))
For i=0 To 1000
y.f=Sin(x)*20
Plot(x,y+80,RGB(255,0,0))
x+0.1
Next
StopDrawing()
EndIf
glDrawBuffer_(#GL_FRONT_AND_BACK)
Repeat
Repeat
EventID = WindowEvent()
Select EventID
Case #PB_Event_Gadget
If EventGadget() = #Button
run ! 1
EndIf
Case #PB_Event_CloseWindow
Quit = 1
EndSelect
Until EventID = 0
glMatrixMode_(#GL_PROJECTION)
glLoadIdentity_()
;gluPerspective( GLdouble fovy,GLdouble aspect, GLdouble zNear, GLdouble zFar);
gluPerspective_(30, Abs(WindowWidth(0) / WindowHeight(0)), 0.1, 100.0)
glMatrixMode_(#GL_MODELVIEW)
glLoadIdentity_()
glClear_(#GL_COLOR_BUFFER_BIT | #GL_DEPTH_BUFFER_BIT)
glLoadIdentity_()
glTranslatef_(0.0, 0.0, -8.0)
If run
rot+1
glRotatef_(rot*run, 0, 1, 0)
Else
glRotatef_(rot, 0, 1, 0)
EndIf
glColor3f_(1.0, 1.0, 1.0)
glBegin_(#GL_TRIANGLES) ; Start drawing a triangle
glColor3f_ ( 1.5, 0.0, 0.0) ; Set top point of triangle to Red
glVertex3f_( 0.0, 1.5, 0.0) ; First point of the triangle
glColor3f_ ( 0.0, 1.5, 0.0) ; Set left point of triangle to Green
glVertex3f_(-1.5, -1.5, 0.0) ; Second point of the triangle
glColor3f_ ( 0.0, 0.0, 1.5) ; Set right point of triangle to Blue
glVertex3f_( 1.5, -1.5, 0.0) ; Third point of the triangle
glEnd_() ; Don
SetGadgetAttribute(2, #PB_OpenGL_FlipBuffers, #True)
Until Quit = #True
End