includepath "iup/"
extern lib "IUP/iup.dll" cdecl
include "iup.h"
extern lib "IUP/iupgl.dll" cdecl
include "iupglA.h"
includepath "$/inc/"
include "minwin.inc"
include "glWinUtil.inc"
'include "console.inc"
indexbase 0
sys canvas,dlg
float ang
extern cdecl
void pyramid()
==============
{
GLColor3ub 255,255,0
glbegin GL_TRIANGLE_FAN
glColor3ub 0, 128, 255 : glVertex3f 0.0, 1.0, 0.0
glColor3ub 255, 0, 0 : glVertex3f -1.0, -1.0, 1.0
glColor3ub 255, 255, 255 : glVertex3f 1.0, -1.0, 1.0
glColor3ub 0, 0, 255 : glVertex3f 1.0, -1.0, -1.0
glColor3ub 0, 255, 0 : glVertex3f -1.0, -1.0, -1.0
glColor3ub 255, 0, 0 : glVertex3f -1.0, -1.0, 1.0
glend
GLBegin GL_LINES
GLColor3ub 0,255,0
float i,j
For i = -10 To 10
For j = -10 To 10
glVertex3f -10, -1, j
glVertex3f 10, -1, j
glVertex3f i, -1, -10
glVertex3f i, -1, 10
Next
Next
GLEnd
}
'static itr
int repaint_cb(Ihandle *self)
=============================
{
static float t
'printl "repaint " self
IupGLMakeCurrent(self);
glClearColor(0.3f, 0.3f, 0.5f, 1.0f); /* White */
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
glMatrixMode(GL_MODELVIEW);
glPushMatrix(); /* saves current model view in a stack */
glTranslatef( 0.0f, 0.0f , -5.0f )
glRotatef(t,0,1,0)
Pyramid();
glPopMatrix();
IupGLSwapBuffers(self); /* change the back buffer with the front buffer */
t+=.25 : if t>=360 then t-=360
sleep 12
return IUP_DEFAULT; /* returns the control to the main loop */
}
int resize_cb(Ihandle *self, int width, int height)
===================================================
{
'printl "resize " self " " width " " height
IupGLMakeCurrent(self); /* Make the canvas current in OpenGL */
/* define the entire canvas as the viewport */
glViewport(0, 0, width, height);
/* transformation applied to each vertex */
glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); /* identity, i. e. no transformation */
/* projection transformation (orthographic in the xy plane) */
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60,4./3.,1.,15);
gluLookAt(0,1,0, 0,0,-5, 0,1,0);
return IUP_DEFAULT; /* return to the IUP main loop */
}
function idle_cb() as sys callback
==================================
static int idle_count = 0
repaint_cb(canvas)
'print "IDLE_ACTION( count = " idle_count ")" & cr
idle_count++
return IUP_DEFAULT
end function
function motion_cb(sys ih) as int callback
==========================================
return IUP_DEFAULT
end function
sub Init()
==========
canvas = IupGlCanvas(NULL)
IupSetAttribute(canvas, "BUFFER","DOUBLE")
IupSetAttribute(canvas, "BUFFER","ANTIALIAS")
IupSetCallback(canvas, "ACTION", @repaint_cb);
IupSetCallback(canvas, "RESIZE_CB",@resize_cb);
IupSetCallback(canvas, "MOTION_CB", @motion_cb)
dlg = IupDialog(canvas)
IupStoreAttribute(dlg, "RASTERSIZE", "500x500")
IupStoreAttribute(dlg, "TITLE", "IUP 3D OpenGL")
IupSetFunction ("IDLE_ACTION", @idle_cb)
end sub
sub main()
==========
IupOpen(null,null)
IupGLCanvasOpen()
Init()
IupShowXY(dlg, IUP_CENTER, IUP_CENTER)
IupMainLoop()
IupClose()
end sub
main()
end extern