Scaffolding is using the GDImage OpenGL built-in facilities.
I could have done a much smaller project, if going full SDK mode, but that was not the purpose of the project,
instead it was to explain how to use the buit-in GL primitives of GDImage altogether with WinDev.
Hold down the left mouse button to move the camera around the scene, and use the slider to zoom in/out.
And here is the code of the main DrawScene procedure:
// Main OpenGL render procedure.
// Procédure OpenGL principale.
PROCEDURE glDrawScene()
nFlip is int = NOT GetStaticValue(FLIP)
SetStaticValue(FLIP, nFlip)
IF nFlip = 0 THEN RETURN
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
rX1, rY1, rX2, rY2 are 4-byte real
nW is int = 520
nH is int = 240
rX1 = 0; rY1 = 0; rX2 = rX1 + nW - 1; rY2 = rY1 + nH - 1
rW is 4-byte real = nW * 0.5
rH is 4-byte real = nH * 0.5
nARGBcolor is int
rRadius, rPenSize are 4-byte real
// Start drawing a new scene.
// On débute le dessin d'une nouvelle scene.
glLoadIdentity()
// Zooming factor.
// Facteur de zoom.
rZoom is 4-byte real = Zoom * -0.01
glScalef(rZoom, rZoom, rZoom)
// Apply mousing rotation.
// On fait pivoter la vue en fonction de l'utilisation du bouton gauche de la souris.
glRotatef(-grSpinY, 1, 0, 0)
glRotatef(-grSpinX, 0, 1, 0)
// Draw a pipe
// Dessine un tube
glPushMatrix()
glRotatef(-90, 1, 0, 0) // ROTATION
rRadius = 10; gl_dPipe(rX1 + 20 - rW, -40, -rH, rRadius, nH + 20, 0, 0, ZD_ColorARGB(255, White), gnChrome)
glPopMatrix()
// Draw a cylinder
// Dessine un cylindre
glPushMatrix()
rRadius = 10; gl_dCylinder(rX1 + 20 - rW, -40, -rH, rRadius, nH + 20, 0, 0, ZD_ColorARGB(255, White), gnChrome, gnRadial)
glPopMatrix()
// Draw a textured rectangle.
// Dessine un rectangle texturé.
gl_dRectTexture(rX1 - rW, rY1 - rH, rX2 -rW, rY2 - rH, ZD_ColorARGB(255, iWhite), gnBuilding)
// Draw a rectangular outline.
// Dessine contour rectangle.
rPenSize = 1; gl_dRectOutline(rX1 - rW, rY1 - rH, rX2 - rW, rY2 - rH, ZD_ColorARGB(255, Black), rPenSize)
// Draw a line.
// Dessine une ligne
rPenSize = 2; gl_dLine(rX1 - rW, rY2 - rH, rX2 - rW, rY1 - rH, ZD_ColorARGB(255, LightYellow), rPenSize)
// Draw a grid.
// Dessine a quadrillage.
glPushMatrix()
rPenSize = 2
glTranslatef(0, 0, rPenSize) // TRANSLATION
nARGBcolor = ZD_ColorARGB(255, RGB(80,80,80))
// Draw horizontal
FOR YY = 20 _TO_ nH - 20 STEP 20
gl_dLine(rX1 - rW, nH - YY - rH - 1, rX2 - rW, nH - YY - rH - 1, nARGBcolor, rPenSize)
END
// Draw vertical
FOR XX = 0 _TO_ nW STEP 20
gl_dLine(0 + XX - rW, 0 - rH, 0 + XX - rW, nH - rH, nARGBcolor, rPenSize)
END
glPopMatrix()
// Draw 5 wooden floor stage.
// Dessine 5 étages de plancher en bois.
glPushMatrix()
glRotatef(90, 1, 0, 0) // ROTATION
glTranslatef(0, 0, rH) // TRANSLATION
FOR K = 1 TO 5
glTranslatef(0, 0, -40) // TRANSLATION
gl_dRectTexture(rX1 - rW, 0, rX2 - rW, 20, ZD_ColorARGB(255, White), gnFloor)
END
glPopMatrix()
// Draw asphalt ground.
// Dessine le sol en asphalt.
glPushMatrix()
glRotatef(90, 1, 0, 0) // ROTATION
glTranslatef(0, 40, rH + 4) // TRANSLATION
gl_dParallelogramRect(rW, 40, 4, ZD_ColorARGB(255, DarkGray), gnConcrete)
glPopMatrix()
// Draw a wooden cube.
// Dessine un cube en bois.
glPushMatrix()
glRotatef(90, 1, 0, 0) // ROTATION
glTranslatef(rW - 20, 40 + 10, rH - 20) // TRANSLATION
gl_dParallelogramRect(20, 20, 20, ZD_ColorARGB(255, White), gnFloor)
glPopMatrix()
// Draw a grid.
// Dessine un quadrillage.
glPushMatrix()
glTranslatef(0, 0, rPenSize + 20)
IF INT_Animate THEN nARGBcolor = ZD_ColorARGB(255, RGB(92, 92, 92)) ELSE nARGBcolor = ZD_ColorARGB(255, RGB(192, 192, 192))
// Draw horizontal
FOR YY = 20 _TO_ nH - 20 STEP 20
gl_dLine(rX1 - rW, nH - YY - rH - 1, rX2 - rW, nH - YY - rH - 1, nARGBcolor, rPenSize)
END
// Draw vertical
FOR XX = 0 _TO_ nW STEP 20
gl_dLine(0 + XX - rW, 0 - rH, 0 + XX - rW, nH - rH, nARGBcolor, rPenSize)
END
glPopMatrix()
// Draw a circle.
// Dessine un cercle.
glPushMatrix()
glTranslatef(0, 0, -20) // TRANSLATION
IF INT_Animate THEN
rRadius = Random(10, rH)
glTranslatef(rH - rRadius, rH - rRadius, 0)
ELSE
rRadius = rH
END
rPenSize = 2; gl_dCircle(rX1 - rW, rY1 - rH, rRadius, ZD_ColorARGB(255, LightRed), rPenSize)
glPopMatrix()
// Draw a cone.
// Dessin un cone.
glPushMatrix()
glTranslatef(0, 0, 40) // TRANSLATION
rConeTop is 4-byte real = 0.0001
rConeBase is 4-byte real = 1
rRadius = 40; gl_dCylinder(0, 0, 0, rRadius, rRadius * 2, rConeTop, rConeBase, ZD_ColorARGB(255, White), gnChrome, gnRadial)
glPopMatrix()
// Draw a dome.
// Dessine un dome.
glPushMatrix()
glRotatef(90, 1, 0, 0) // ROTATION
glTranslatef(80, 160, -70) // TRANSLATION
rRadius = 40; gl_dDome(0, 0, 0, rRadius, ZD_ColorARGB(255, White), gnRedWood)
// Use a 50% transparent black color to paint the inside.
// On peint l'intérieur avec un noir transparent à 50%.
rRadius = 39.5; gl_dDome(0, 0, 0, rRadius, ZD_ColorARGB(128, Black), 0)
glPopMatrix()
// Draw a sphere.
// Dessine une sphere.
glPushMatrix()
glRotatef(90, 1, 0, 0) // ROTATION
glTranslatef(80, 160, 0) // TRANSLATION
rRadius = 40; gl_dSphere(0, 0, 0, rRadius, ZD_ColorARGB(255, White), gnRedWood)
glPopMatrix()
// Draw a cup.
// Dessine une coupe.
glPushMatrix()
glRotatef(90, 1, 0, 0) // ROTATION
glTranslatef(80, 160, 70) // TRANSLATION
rRadius = 40; gl_dCup(0, 0, 0, rRadius, ZD_ColorARGB(255, White), gnRedWood)
// Use a 50% transparent black color to paint the inside.
// On peint l'intérieur avec un noir transparent à 50%.
rRadius = 39.5; gl_dCup(0, 0, 0, rRadius, ZD_ColorARGB(128, Black), 0)
glPopMatrix()
// Draw a torus.
// Dessine un tore.
glPushMatrix()
//glRotatef(90, 1, 0, 0) // ROTATION
Enable_Specular() // REFLEXION
//Enable_Wire()
gl_dTorus(20, 150, 48, 48, ZD_ColorARGB(155, PastelYellow), gnSpecular)
//Disable_Wire()
Disable_Specular()
glPopMatrix()
// Flush OpenGL buffer.
glFlush()
// Draw the scene into the GDImage control.
// On dessine la scene dans le contrôle GDImage.
ZI_UpdateGLWindow(gnCtrl)
Once you mastered WinDev, there is no limit to what you can do with it.
:)
Here is the translation to PowerBASIC 32-bit, using only the core SDK API syntax.
...