Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
39
Task/OpenGL/Nim/opengl.nim
Normal file
39
Task/OpenGL/Nim/opengl.nim
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
import opengl, glut
|
||||
|
||||
proc paint() {.cdecl.} =
|
||||
glClearColor(0.3,0.3,0.3,0.0)
|
||||
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT)
|
||||
|
||||
glShadeModel(GL_SMOOTH)
|
||||
|
||||
glLoadIdentity()
|
||||
glTranslatef(-15.0, -15.0, 0.0)
|
||||
|
||||
glBegin(GL_TRIANGLES)
|
||||
glColor3f(1.0, 0.0, 0.0)
|
||||
glVertex2f(0.0, 0.0)
|
||||
glColor3f(0.0, 1.0, 0.0)
|
||||
glVertex2f(30.0, 0.0)
|
||||
glColor3f(0.0, 0.0, 1.0)
|
||||
glVertex2f(0.0, 30.0)
|
||||
glEnd()
|
||||
|
||||
glFlush()
|
||||
|
||||
proc reshape(width, height) {.cdecl.} =
|
||||
glViewport(0, 0, width, height)
|
||||
glMatrixMode(GL_PROJECTION)
|
||||
glLoadIdentity()
|
||||
glOrtho(-30.0, 30.0, -30.0, 30.0, -30.0, 30.0)
|
||||
glMatrixMode(GL_MODELVIEW)
|
||||
|
||||
enableAutoGlErrorCheck(false)
|
||||
loadExtensions()
|
||||
glutInit()
|
||||
glutInitWindowSize(640, 480)
|
||||
discard glutCreateWindow("Triangle")
|
||||
|
||||
glutDisplayFunc(paint)
|
||||
glutReshapeFunc(reshape)
|
||||
|
||||
glutMainLoop()
|
||||
35
Task/OpenGL/Phix/opengl-1.phix
Normal file
35
Task/OpenGL/Phix/opengl-1.phix
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
include demo\Arwen32dibdemo\a32dpoly.ew
|
||||
|
||||
a32Dib0 screen_dib = 0
|
||||
integer dx = 0, dy = 0, dw = 0, dh = 0
|
||||
|
||||
constant win = create(Window, "Arwen32Dib bitmap shaded triangle demo", 0, 0, Default, Default, 480, 300, 0)
|
||||
|
||||
function winHandler(integer id, integer msg, atom wParam, object lParam)
|
||||
sequence rect
|
||||
if id or object(lParam) then end if -- suppress warnings
|
||||
if msg=WM_PAINT then
|
||||
if sequence(screen_dib) then
|
||||
clearDib(screen_dib, {0, 0, 0})
|
||||
drawShadedPolygonToDib(screen_dib, {{dx, dy}, {dx, dh-dy}, {dw-dx, dh-dy}}, {{255, 0, 0}, {0, 0, 255}, {0, 255, 0}})
|
||||
drawDib(win, screen_dib, 0, 0, 0, 0, screen_dib[DibWidth]-1, screen_dib[DibHeight]-1)
|
||||
end if
|
||||
elsif msg=WM_SIZE then
|
||||
rect = getClientRect(win)
|
||||
dw = rect[3]
|
||||
dh = rect[4]
|
||||
dx = floor(dw/4)+1
|
||||
dy = floor(dh/4)+1
|
||||
if sequence(screen_dib) then killDib(screen_dib) end if
|
||||
screen_dib = newDib(dw, dh)
|
||||
elsif msg=WM_CHAR
|
||||
and wParam=VK_ESCAPE then
|
||||
closeWindow(win)
|
||||
end if
|
||||
return 0
|
||||
end function
|
||||
setHandler(win, routine_id("winHandler"))
|
||||
|
||||
WinMain(win, SW_NORMAL)
|
||||
|
||||
if sequence(screen_dib) then killDib(screen_dib) end if
|
||||
57
Task/OpenGL/Phix/opengl-2.phix
Normal file
57
Task/OpenGL/Phix/opengl-2.phix
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
include pGUI.e
|
||||
include opengl.e
|
||||
|
||||
function resize_cb(Ihandle /*ih*/, integer width, integer height)
|
||||
glViewport(0, 0, width, height)
|
||||
glMatrixMode(GL_PROJECTION)
|
||||
glLoadIdentity()
|
||||
glOrtho(-30.0, 30.0, -30.0, 30.0, -30.0, 30.0)
|
||||
glMatrixMode(GL_MODELVIEW)
|
||||
return IUP_DEFAULT
|
||||
end function
|
||||
|
||||
function action(Ihandle /*ih*/)
|
||||
|
||||
glClearColor(0.3,0.3,0.3,0.0)
|
||||
glClear(GL_COLOR_BUFFER_BIT+GL_DEPTH_BUFFER_BIT)
|
||||
|
||||
glShadeModel(GL_SMOOTH)
|
||||
|
||||
glLoadIdentity()
|
||||
glTranslate(-15.0, -15.0, 0.0)
|
||||
|
||||
glBegin(GL_TRIANGLES)
|
||||
glColor(1.0, 0.0, 0.0)
|
||||
glVertex(0.0, 0.0)
|
||||
glColor(0.0, 1.0, 0.0)
|
||||
glVertex(30.0, 0.0)
|
||||
glColor(0.0, 0.0, 1.0)
|
||||
glVertex(0.0, 30.0)
|
||||
glEnd()
|
||||
|
||||
glFlush()
|
||||
|
||||
return IUP_DEFAULT
|
||||
end function
|
||||
|
||||
Ihandle dialog, canvas
|
||||
|
||||
function map_cb(Ihandle /*ih*/)
|
||||
IupGLMakeCurrent(canvas)
|
||||
integer {width, height} = IupGetIntInt(dialog, "RASTERSIZE")
|
||||
{} = resize_cb(dialog, width, height)
|
||||
return IUP_DEFAULT
|
||||
end function
|
||||
|
||||
IupOpen()
|
||||
IupGLCanvasOpen()
|
||||
|
||||
canvas = IupGLCanvas(Icallback("action"), "RASTERSIZE=640x480")
|
||||
IupSetCallback(canvas, "RESIZE_CB", Icallback("resize_cb"))
|
||||
|
||||
dialog = IupDialog(canvas, "MAP_CB", Icallback("map_cb"), "TITLE=Triangle, SHRINK=YES")
|
||||
|
||||
IupShow(dialog)
|
||||
IupMainLoop()
|
||||
IupDestroy(dialog)
|
||||
IupClose()
|
||||
Loading…
Add table
Add a link
Reference in a new issue