i have found glut.inc in powerbasic forum here.... (http://www.powerbasic.com/support/PBforums/showthread.php?p=167048)i tried it to draw some geometrical figures after deleting the #include lines. and it works, i have mixed TBGL functions with classic opengl and glut functions. amazing this works, and thanks for Petr for making his module very flexible.
i don't know how much using this old glut.inc are safe or not.
attached the
glut.inc copy it to c:\thinbasic\Inc
glut32.dll copy it to c:\windows\system32 (this is in windows xp)
with the code to display wireTeapot, WireSphere, WireOctahedron. all rotating, you can add much more by inspecting the file glut.inc
http://i56.tinypic.com/jrslmx.png
Uses "tbgl"
#INCLUDE "%app_includepath%\thinbasic_gl.inc"
#INCLUDE "%app_includepath%\thinbasic_glu.inc"
#INCLUDE "%app_includepath%\glut.inc"
Dim hwnd As DWord
hwnd = TBGL_CreateWindowEx("Glut application - esc to exit", 500, 500, 32, 0)
TBGL_ShowWindow
TBGL_ResetKeyState()
While TBGL_IsWindow(hwnd)
TBGL_ClearFrame
init
display
TBGL_DrawFrame
If TBGL_GetWindowKeyState( hwnd, %VK_ESCAPE) Then Exit While
Wend
TBGL_DestroyWindow
Sub init()
glclearcolor(0.0, 0.0, 0.0, 0.0)
glcolor3f(0.0, 0.0, 1.0)
glmatrixmode(%gl_projection)
glloadidentity()
glortho(-20.0, 20.0, -20.0, 20.0, -20.0, 20.0)
End Sub
Sub display()
glclear(%gl_color_buffer_bit)
'TBGL_ResetMatrix
TBGL_PushMatrix
TBGL_Translate 10, -7, 0
TBGL_Rotate GetTickCount/10,0,1,0
glutWireSphere(5,20,30)
TBGL_PopMatrix
glColor3f(1.0,0.0,0.0)
TBGL_PushMatrix
TBGL_Translate -10, -7, 0
TBGL_Rotate GetTickCount/10,0,1,0
glScalef( 5.0, 5.0, 5.0)
glutWireOctahedron()
TBGL_PopMatrix
glColor3f(1.0,1.0,0.0)
TBGL_PushMatrix
TBGL_Translate 0, 7, 0
TBGL_Rotate GetTickCount/10,0,1,0
glutWireTeapot(5)
TBGL_PopMatrix
End Sub
danbaron
24-05-2011, 06:10
I like the teapot and the wire circle (sphere).
The circle reminds me of the guy they show with the arms and legs outstretched to a circle's rim, I think, on public television. Maybe it's from a drawing by da Vinci, I don't know.
Petr Schreiber
24-05-2011, 07:41
Hi Zak,
it should be safe to combine GLUT and TBGL this way, I try to keep the module open to such a tricks :)
Petr
José Roca
24-05-2011, 21:32
I don't use DLLs of abandoned projects. What will happen to them the day we will have to move to 64 bits? Instead, I have translated the source code of these functions to PowerBASIC, mainly using the source of freeglut.
those shapes SUBs in the site of José Roca here :
http://www.jose.it-berater.org/smfforum/index.php?topic=3694.45 and in previous pages are wonderful , i have tried two of them
glutWireCone, and glutWireCube.
and it works , it is just glutWireCone and fghCircleTable subs needs small modification since it has arrays begins with index zero and thinbasic arrays begins with index 1 . the modified lines are commented.
7245
Uses "tbgl"
#INCLUDE "%app_includepath%\thinbasic_gl.inc"
#INCLUDE "%app_includepath%\thinbasic_glu.inc"
'the subs glutWireCube, glutWireCone,fghCircleTable are from José Roca site:
'http://www.jose.it-berater.org/smfforum/index.php?topic=3694.45
'the glutWireCone and fghCircleTable subs modified lines are commented
Dim hwnd As DWord
hwnd = TBGL_CreateWindowEx("Geometrical Shapes - esc to exit", 500, 500, 32, 0)
TBGL_ShowWindow
TBGL_ResetKeyState()
While TBGL_IsWindow(hwnd)
TBGL_ClearFrame
init
display
TBGL_DrawFrame
If TBGL_GetWindowKeyState( hwnd, %VK_ESCAPE) Then Exit While
Wend
TBGL_DestroyWindow
Sub init()
glclearcolor(0.0, 0.0, 0.0, 0.0)
glcolor3f(0.0, 0.0, 1.0)
glmatrixmode(%gl_projection)
glloadidentity()
glortho(-20.0, 20.0, -20.0, 20.0, -20.0, 20.0)
End Sub
Sub display()
glclear(%gl_color_buffer_bit)
glColor3f(1.0,1.0,0.0)
TBGL_PushMatrix
TBGL_Translate 10, 0, 0
TBGL_Rotate GetTickCount/10,0,1,0
glutWireCube(7)
TBGL_PopMatrix
TBGL_PushMatrix
glColor3f(0.0,1.0,0.0)
TBGL_Translate -10, 0, 0
TBGL_Rotate GetTickCount/10,0,1,0
glutWireCone(7,8,40,20)
TBGL_PopMatrix
End Sub
' Draws a wireframed cube.
Sub glutWireCube (ByVal dSize As Double)
Local dblSize As Double
dblSize = dSize * 0.5
glBegin(%GL_LINE_LOOP)
glNormal3d(1.0, 0.0, 0.0)
glVertex3d(dblSize, -dblSize, dblSize)
glVertex3d(dblSize, -dblSize, -dblSize)
glVertex3d(dblSize, dblSize, -dblSize)
glVertex3d(dblSize, dblSize, dblSize)
glEnd
glBegin(%GL_LINE_LOOP)
glNormal3d(0.0, 1.0, 0.0)
glVertex3d(dblSize, dblSize, dblSize)
glVertex3d(dblSize, dblSize, -dblSize)
glVertex3d(-dblSize, dblSize, -dblSize)
glVertex3d(-dblSize, dblSize, dblSize)
glEnd
glBegin(%GL_LINE_LOOP)
glNormal3d(0.0, 0.0, 1.0)
glVertex3d(dblSize, dblSize, dblSize)
glVertex3d(-dblSize, dblSize, dblSize)
glVertex3d(-dblSize, -dblSize, dblSize)
glVertex3d(dblSize, -dblSize, dblSize)
glEnd
glBegin(%GL_LINE_LOOP)
glNormal3d(-1.0, 0.0, 0.0)
glVertex3d(-dblSize, -dblSize, dblSize)
glVertex3d(-dblSize, dblSize, dblSize)
glVertex3d(-dblSize, dblSize, -dblSize)
glVertex3d(-dblSize, -dblSize, -dblSize)
glEnd
glBegin(%GL_LINE_LOOP)
glNormal3d(0.0,-1.0, 0.0)
glVertex3d(-dblSize, -dblSize, dblSize)
glVertex3d(-dblSize, -dblSize, -dblSize)
glVertex3d(dblSize, -dblSize, -dblSize)
glVertex3d(dblSize, -dblSize, dblSize)
glEnd
glBegin(%GL_LINE_LOOP)
glNormal3d(0.0, 0.0,-1.0)
glVertex3d(-dblSize, -dblSize, -dblSize)
glVertex3d(-dblSize, dblSize, -dblSize)
glVertex3d(dblSize, dblSize, -dblSize)
glVertex3d(dblSize, -dblSize, -dblSize)
glEnd
End Sub
' * Draws a wire cone
Sub fghCircleTable (ByRef sint() As Double, ByRef cost() As Double, ByVal n As Long)
Local i As Long
' /* Table size, the sign of n flips the circle direction */
Local nSize As Long
nSize = Abs(n)
' /* Determine the angle between samples */
Local angle As Double
If n = 0 Then n = 1
angle = 2 * 3.14159265358979323846 / IIf(n = 0, 1, n)
' /* Allocate memory for n samples, plus duplicate of first entry at the end */
ReDim sint(nSize) As Double
ReDim cost(nSize) As Double
' /* Compute cos and sin around the circle */
sint(1) = 0.0
cost(1) = 1.0
''For i = 1 To nSize - 1
For i = 1 To nSize
'sint(i) = Sin(angle * i)
'cost(i) = Cos(angle * i)
sint(i) = Sin(angle * (i-1))
cost(i) = Cos(angle * (i-1))
Next
' /* Last sample is duplicate of the first */
''sint(nSize) = sint(1)
''cost(nSize) = cost(1)
End Sub
Sub glutWireCone (ByVal dbase As Double, ByVal height As Double, ByVal slices As Long, ByVal stacks As Long)
Local i, j As Long
' /* Step in z and radius as stacks are drawn. */
Local z, r As Double
z = 0.0
r = dbase
Local zStep, rStep As Double
zStep = height / IIf (stacks > 0, stacks, 1)
rStep = dbase / IIf(stacks > 0, stacks, 1)
' /* Scaling factors for vertex normals */
Local cosn, sinn As Double
cosn = (height / Sqr(height * height + dbase * dbase))
sinn = (dbase / Sqr(height * height + dbase * dbase))
' /* Pre-computed circle */
Dim sint(1) As Double
Dim cost(1) As Double
'fghCircleTable(sint(), cost(), -slices)
fghCircleTable(sint, cost, -slices)
' /* Draw the stacks... */
For i = 0 To stacks - 1
glBegin(%GL_LINE_LOOP)
For j = 1 To slices -1
glNormal3d(cost(j)*sinn, sint(j)*sinn, cosn)
glVertex3d(cost(j)*r, sint(j)*r, z )
Next
glEnd
z += zStep
r -= rStep
Next
' /* Draw the slices */
r = dbase
glBegin(%GL_LINES)
''For j = 1 To slices -1
For j = 1 To slices
glNormal3d(cost(j)*sinn, sint(j)*sinn, cosn )
glVertex3d(cost(j)*r, sint(j)*r, 0.0 )
glVertex3d(0.0, 0.0, height)
Next
glEnd
End Sub
José Roca
25-05-2011, 23:58
I have also transladed the remaining ones. They are grouped in a file called AfxGlut.inc that will be included in the next release of my WIndows API Headers package.
José Roca
26-05-2011, 00:19
First they released glaux.dll. Later it was deprecated and replaced with glut.dll, that has not been developed since 2001! OpenGlut.dll has not been developed since 2005. freeglut seems still active: last version was released in 2009. But as I was only interested in the high level functions, I decided to port them and be safe (and no to have to use an additional DLL). The major difficulty has been to fill all these darned arrays :)
Petr Schreiber
26-05-2011, 19:05
José,
your hard work is very much appreciated!
Petr