Announcement

Collapse
No announcement yet.

freeglut 2.8.0 Headers

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #21
    Code:
    '/*
    ' * Copyright (c) 1993-1997, Silicon Graphics, Inc.
    ' * ALL RIGHTS RESERVED
    ' * Permission to use, copy, modify, and distribute this software for
    ' * any purpose and without fee is hereby granted, provided that the above
    ' * copyright notice appear in all copies and that both the copyright notice
    ' * and this permission notice appear in supporting documentation, and that
    ' * the name of Silicon Graphics, Inc. not be used in advertising
    ' * or publicity pertaining to distribution of the software without specific,
    ' * written prior permission.
    ' *
    ' * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
    ' * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
    ' * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
    ' * FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL SILICON
    ' * GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
    ' * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
    ' * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
    ' * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
    ' * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC.  HAS BEEN
    ' * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
    ' * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
    ' * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
    ' *
    ' * US Government Users Restricted Rights
    ' * Use, duplication, or disclosure by the Government is subject to
    ' * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
    ' * (c)(1)(ii) of the Rights in Technical Data and Computer Software
    ' * clause at DFARS 252.227-7013 and/or in similar or successor
    ' * clauses in the FAR or the DOD or NASA FAR Supplement.
    ' * Unpublished-- rights reserved under the copyright laws of the
    ' * United States.  Contractor/manufacturer is Silicon Graphics,
    ' * Inc., 2011 N.  Shoreline Blvd., Mountain View, CA 94039-7311.
    ' *
    ' * OpenGL(R) is a registered trademark of Silicon Graphics, Inc.
    ' */
    
    '/*
    ' *  model.c
    ' *  This program demonstrates modeling transformations
    ' */
    
    ' Translated and adapted to PowerBASIC by José Roca, 2007
    
    ' SED_PBWIN - Use the PBWIN compiler
    #COMPILE EXE
    #DIM ALL
    #INCLUDE "freeglut.inc"
    
    $WindowCaption = "model"
    
    ' ========================================================================================
    SUB Init ()
    
       glClearColor 0.0, 0.0, 0.0, 0.0
       glShadeModel %GL_FLAT
    
    END SUB
    ' ========================================================================================
    
    ' ========================================================================================
    SUB draw_triangle()
    
       glBegin %GL_LINE_LOOP
       glVertex2f 0.0, 25.0
       glVertex2f 25.0, -25.0
       glVertex2f -25.0, -25.0
       glEnd
    
    END SUB
    ' ========================================================================================
    
    ' ========================================================================================
    SUB DisplayProc CDECL ()
    
       glClear %GL_COLOR_BUFFER_BIT
       glColor3f 1.0, 1.0, 1.0
    
       glLoadIdentity
       glColor3f 1.0, 1.0, 1.0
       draw_triangle
    
       glEnable %GL_LINE_STIPPLE
       glLineStipple 1, &HF0F0
       glLoadIdentity
       glTranslatef -20.0, 0.0, 0.0
       draw_triangle
    
       glLineStipple 1, &HF00F
       glLoadIdentity
       glScalef 1.5, 0.5, 1.0
       draw_triangle
    
       glLineStipple 1, &H8888
       glLoadIdentity
       glRotatef 90.0, 0.0, 0.0, 1.0
       draw_triangle
       glDisable %GL_LINE_STIPPLE
    
       glFlush
    
    END SUB
    ' ========================================================================================
    
    ' ========================================================================================
    ' Redisplay callback procedure
    ' ========================================================================================
    SUB ReshapeProc CDECL (BYVAL w AS LONG, BYVAL h AS LONG)
    
       glViewport 0, 0, w, h
       glMatrixMode %GL_PROJECTION
       glLoadIdentity
       IF w <= h THEN
          glOrtho -50.0, 50.0, -50.0 * h / w, _
             50.0 * h / w, -1.0, 1.0
       ELSE
          glOrtho -50.0 * w / h, _
             50.0 * w / h, -50.0, 50.0, -1.0, 1.0
       END IF
       glMatrixMode %GL_MODELVIEW
    
    END SUB
    ' ========================================================================================
    
    ' ========================================================================================
    ' Keyboard callback procedure
    ' ========================================================================================
    FUNCTION KeyboardProc CDECL (BYVAL nKey AS BYTE, BYVAL x AS LONG, BYVAL y AS  LONG) AS LONG
    
       SELECT CASE nKey
          CASE 27   ' Escape Key
             glutLeaveMainLoop
       END SELECT
    
    END FUNCTION
    ' ========================================================================================
    
    ' ========================================================================================
    '/*  Main Loop
    ' *  Open window with initial window size, title bar,
    ' *  RGBA display mode, and handle input events.
    ' */
    ' ========================================================================================
    FUNCTION PBMAIN () AS LONG
    
       GlutInit 1, " "   ' We need at least one character or it will GPF
       glutInitDisplayMode %GLUT_SINGLE OR %GLUT_RGB
       glutInitWindowSize 640, 480
       glutInitWindowPosition 0, 0
       glutCreateWindow $WindowCaption
       Init
       glutReshapeFunc  CODEPTR(ReshapeProc)
       glutKeyboardFunc CODEPTR(KeyboardProc)
       glutDisplayFunc  CODEPTR(DisplayProc)
       glutMainLoop
    
    END FUNCTION
    ' ========================================================================================
    Attached Files
    Forum: http://www.jose.it-berater.org/smfforum/index.php

    Comment


    • #22
      Code:
      '/* Copyright (c) Mark J. Kilgard, 1995. */
      
      '/* This program is freely distributable without licensing fees
      '   and is provided without guarantee or warrantee expressed or
      '   implied. This program is -not- in the public domain. */
      
      '/* molehill uses the GLU NURBS routines to draw some nice surfaces. */
      
      ' Translated and adapted to PowerBASIC by José Roca, 2007
      
      ' SED_PBWIN - Use the PBWIN compiler
      #COMPILE EXE
      #DIM ALL
      #INCLUDE "freeglut.inc"
      
      $WindowCaption = "molehill"
      
      GLOBAL mat_red_diffuse() AS SINGLE
      GLOBAL mat_green_diffuse() AS SINGLE
      GLOBAL mat_blue_diffuse() AS SINGLE
      GLOBAL mat_yellow_diffuse() AS SINGLE
      GLOBAL mat_specular() AS SINGLE
      GLOBAL mat_shininess() AS SINGLE
      GLOBAL knots() AS SINGLE
      GLOBAL pts1() AS SINGLE
      GLOBAL pts2() AS SINGLE
      GLOBAL nurb AS DWORD
      GLOBAL u, v AS LONG
      
      
      ' ========================================================================================
      SUB DisplayProc CDECL ()
      
        glClear %GL_COLOR_BUFFER_BIT OR %GL_DEPTH_BUFFER_BIT
        glCallList 1
        glFlush
      
      END SUB
      ' ========================================================================================
      
      ' ========================================================================================
      ' Keyboard callback procedure
      ' ========================================================================================
      FUNCTION KeyboardProc CDECL (BYVAL nKey AS BYTE, BYVAL x AS LONG, BYVAL y AS  LONG) AS LONG
      
         SELECT CASE nKey
            CASE 27   ' Escape Key
               glutLeaveMainLoop
         END SELECT
      
      END FUNCTION
      ' ========================================================================================
      
      ' ========================================================================================
      ' Main Loop
      ' ========================================================================================
      FUNCTION PBMAIN () AS LONG
      
         GlutInit 1, " "   ' We need at least one character or it will GPF
         glutInitDisplayMode %GLUT_SINGLE OR %GLUT_RGB OR %GLUT_DEPTH
         glutInitWindowSize 640, 480
         glutInitWindowPosition 0, 0
         glutCreateWindow $WindowCaption
      
         DIM mat_red_diffuse(3) AS SINGLE
         ARRAY ASSIGN mat_red_diffuse() = 0.7, 0.0, 0.1, 1.0
         DIM mat_green_diffuse(3) AS SINGLE
         ARRAY ASSIGN mat_green_diffuse() = 0.0, 0.7, 0.1, 1.0
         DIM mat_blue_diffuse(3) AS SINGLE
         ARRAY ASSIGN mat_blue_diffuse() = 0.0, 0.1, 0.7, 1.0
         DIM mat_yellow_diffuse(3) AS SINGLE
         ARRAY ASSIGN mat_yellow_diffuse() = 0.7, 0.8, 0.1, 1.0
         DIM mat_specular(3) AS SINGLE
         ARRAY ASSIGN mat_specular() = 1.0, 1.0, 1.0, 1.0
         DIM mat_shininess(0) AS SINGLE
         ARRAY ASSIGN mat_shininess() = 100.0
         DIM knots(7) AS SINGLE
         ARRAY ASSIGN knots() = 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0
      
         DIM pts1(2, 3, 3) AS SINGLE
         DIM pts2(2, 3, 3) AS SINGLE
         DIM pts3(2, 3, 3) AS SINGLE
         DIM pts4(2, 3, 3) AS SINGLE
      
         glMaterialfv %GL_FRONT, %GL_SPECULAR, mat_specular(0)
         glMaterialfv %GL_FRONT, %GL_SHININESS, mat_shininess(0)
         glEnable %GL_LIGHTING
         glEnable %GL_LIGHT0
         glEnable %GL_DEPTH_TEST
         glEnable %GL_AUTO_NORMAL
         glEnable %GL_NORMALIZE
         nurb = gluNewNurbsRenderer
         gluNurbsProperty nurb, %GLU_SAMPLING_TOLERANCE, 25.0
         gluNurbsProperty nurb, %GLU_DISPLAY_MODE, %GLU_FILL
      
         ' /* Build control points for NURBS mole hills. */
         FOR u = 0 TO 3
            FOR v = 0 TO 3
               '/* Red. */
               pts1(0, v, u) = 2.0 * u
               pts1(1, v, u) = 2.0 * v
               IF  (u=1 OR u = 2) AND (v = 1 OR v = 2) THEN
                  ' /* Stretch up middle. */
                  pts1(2, v, u) = 6.0
               ELSE
                  pts1(2, v, u) = 0.0
               END IF
               ' /* Green. */
               pts2(0, v, u) = 2.0 * (u - 3.0)
               pts2(1, v, u) = 2.0 * (v - 3.0)
               IF (u=1 OR u = 2) AND (v = 1 OR v = 2) THEN
                  IF u = 1 AND v = 1 THEN
                     ' /* Pull hard on single middle square. */
                     pts2(2, v, u) = 15.0
                  ELSE
                     ' /* Push down on other middle squares. */
                     pts2(2, v, u) = -2.0
                  END IF
               ELSE
                  pts2(2, v, u) = 0.0
               END IF
               ' /* Blue. */
               pts3(0, v, u) = 2.0 * (u - 3.0)
               pts3(1, v, u) = 2.0 * v
               IF (u=1 OR u = 2) AND (v = 1 OR v = 2) THEN
                  IF u = 1 AND v = 2 THEN
                     ' /* Pull up on single middple square. */
                     pts3(2, v, u) = 11.0
                  ELSE
                     ' /* Pull up slightly on other middle squares. */
                     pts3(2, v, u) = 2.0
                  END IF
               ELSE
                  pts3(2, v, u) = 0.0
               END IF
               ' /* Yellow. */
               pts4(0, v, u) = 2.0 * u
               pts4(1, v, u) = 2.0 * (v - 3.0)
               IF (u=1 OR u = 2 OR u = 3) AND (v = 1 OR v = 2) THEN
                  IF v = 1 THEN
                     ' /* Push down front middle and right squares. */
                     pts4(2, v, u) = -2.0
                  ELSE
                     ' /* Pull up back middle and right squares. */
                     pts4(2, v, u) = 5.0
                  END IF
               ELSE
                  pts4(2, v, u) = 0.0
               END IF
            NEXT
         NEXT
      
         ' /* Stretch up red's far right corner. */
         pts1(2, 3, 3) = 6
         ' /* Pull down green's near left corner a little. */
         pts2(2, 0, 0) = -2
         ' /* Turn up meeting of four corners. */
         pts1(2, 0, 0) = 1
         pts2(2, 3, 3) = 1
         pts3(2, 0, 3) = 1
         pts4(2, 3, 0) = 1
      
         glMatrixMode %GL_PROJECTION
         gluPerspective 55.0, 1.0, 2.0, 24.0
         glMatrixMode %GL_MODELVIEW
         glTranslatef 0.0, 0.0, -15.0
         glRotatef 330.0, 1.0, 0.0, 0.0
      
         glNewList 1, %GL_COMPILE
         ' /* Render red hill. */
         glMaterialfv %GL_FRONT, %GL_DIFFUSE, mat_red_diffuse(0)
         gluBeginSurface nurb
            gluNurbsSurface nurb, 8, knots(0), 8, knots(0), _
              4 * 3, 3, pts1(0, 0, 0), _
              4, 4, %GL_MAP2_VERTEX_3
         gluEndSurface nurb
      
         ' /* Render green hill. */
         glMaterialfv %GL_FRONT, %GL_DIFFUSE, mat_green_diffuse(0)
         gluBeginSurface nurb
            gluNurbsSurface nurb, 8, knots(0), 8, knots(0), _
              4 * 3, 3, pts2(0, 0, 0), _
              4, 4, %GL_MAP2_VERTEX_3
         gluEndSurface nurb
      
         ' /* Render blue hill. */
         glMaterialfv %GL_FRONT, %GL_DIFFUSE, mat_blue_diffuse(0)
         gluBeginSurface nurb
            gluNurbsSurface nurb, 8, knots(0), 8, knots(0), _
              4 * 3, 3, pts3(0, 0, 0), _
              4, 4, %GL_MAP2_VERTEX_3
         gluEndSurface nurb
      
         ' /* Render yellow hill. */
         glMaterialfv %GL_FRONT, %GL_DIFFUSE, mat_yellow_diffuse(0)
         gluBeginSurface nurb
            gluNurbsSurface nurb, 8, knots(0), 8, knots(0), _
              4 * 3, 3, pts4(0, 0, 0), _
              4, 4, %GL_MAP2_VERTEX_3
         gluEndSurface nurb
         glEndList
      
         glutKeyboardFunc CODEPTR(KeyboardProc)
         glutDisplayFunc  CODEPTR(DisplayProc)
         glutMainLoop
      
      END FUNCTION
      ' ========================================================================================
      Attached Files
      Forum: http://www.jose.it-berater.org/smfforum/index.php

      Comment


      • #23
        Code:
        '/*
        ' * Copyright (c) 1993-1997, Silicon Graphics, Inc.
        ' * ALL RIGHTS RESERVED
        ' * Permission to use, copy, modify, and distribute this software for
        ' * any purpose and without fee is hereby granted, provided that the above
        ' * copyright notice appear in all copies and that both the copyright notice
        ' * and this permission notice appear in supporting documentation, and that
        ' * the name of Silicon Graphics, Inc. not be used in advertising
        ' * or publicity pertaining to distribution of the software without specific,
        ' * written prior permission.
        ' *
        ' * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
        ' * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
        ' * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
        ' * FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL SILICON
        ' * GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
        ' * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
        ' * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
        ' * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
        ' * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC.  HAS BEEN
        ' * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
        ' * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
        ' * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
        ' *
        ' * US Government Users Restricted Rights
        ' * Use, duplication, or disclosure by the Government is subject to
        ' * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
        ' * (c)(1)(ii) of the Rights in Technical Data and Computer Software
        ' * clause at DFARS 252.227-7013 and/or in similar or successor
        ' * clauses in the FAR or the DOD or NASA FAR Supplement.
        ' * Unpublished-- rights reserved under the copyright laws of the
        ' * United States.  Contractor/manufacturer is Silicon Graphics,
        ' * Inc., 2011 N.  Shoreline Blvd., Mountain View, CA 94039-7311.
        ' *
        ' * OpenGL(R) is a registered trademark of Silicon Graphics, Inc.
        ' */
        
        '/*
        ' *  movelight.c
        ' *  This program demonstrates when to issue lighting and
        ' *  transformation commands to render a model with a light
        ' *  which is moved by a modeling transformation (rotate or
        ' *  translate).  The light position is reset after the modeling
        ' *  transformation is called.  The eye position does not change.
        ' *
        ' *  A sphere is drawn using a grey material characteristic.
        ' *  A single light source illuminates the object.
        ' *
        ' *  Interaction:  pressing the left mouse button alters
        ' *  the modeling transformation (x rotation) by 30 degrees.
        ' *  The scene is then redrawn with the light in a new position.
        ' */
        
        ' Translated and adapted to PowerBASIC by José Roca, 2007
        
        ' SED_PBWIN - Use the PBWIN compiler
        #COMPILE EXE
        #DIM ALL
        #INCLUDE "freeglut.inc"
        
        $WindowCaption = "movelight"
        
        GLOBAL spin AS LONG
        
        ' ========================================================================================
        '/*  Initialize material property, light source, lighting model,
        ' *  and depth buffer.
        ' */
        ' ========================================================================================
        SUB Init ()
        
           glClearColor 0.0, 0.0, 0.0, 0.0
           glShadeModel %GL_SMOOTH
           glEnable %GL_LIGHTING
           glEnable %GL_LIGHT0
           glEnable %GL_DEPTH_TEST
        
        END SUB
        ' ========================================================================================
        
        ' ========================================================================================
        '/*  Here is where the light position is reset after the modeling
        ' *  transformation (glRotated) is called.  This places the
        ' *  light at a new position in world coordinates.  The cube
        ' *  represents the position of the light.
        ' */
        ' ========================================================================================
        SUB DisplayProc CDECL ()
        
           DIM position(3) AS SINGLE
        
           ARRAY ASSIGN position() = 0.0, 0.0, 1.5, 1.0
        
           glClear %GL_COLOR_BUFFER_BIT OR %GL_DEPTH_BUFFER_BIT
           glPushMatrix
           gluLookAt 0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0
        
           glPushMatrix
           glRotated spin, 1.0, 0.0, 0.0
           glLightfv %GL_LIGHT0, %GL_POSITION, position(0)
        
           glTranslated 0.0, 0.0, 1.5
           glDisable %GL_LIGHTING
           glColor3f 0.0, 1.0, 1.0
           glutWireCube 0.1
           glEnable %GL_LIGHTING
           glPopMatrix
        
           glutSolidTorus 0.275, 0.85, 8, 15
           glPopMatrix
           glFlush
        
        END SUB
        ' ========================================================================================
        
        ' ========================================================================================
        ' Redisplay callback procedure
        ' ========================================================================================
        SUB ReshapeProc CDECL (BYVAL w AS LONG, BYVAL h AS LONG)
        
           glViewport 0, 0, w, h
           glMatrixMode %GL_PROJECTION
           glLoadIdentity
           gluPerspective 40.0, w / h, 1.0, 20.0
           glMatrixMode %GL_MODELVIEW
           glLoadIdentity
        
        END SUB
        ' ========================================================================================
        
        ' ========================================================================================
        SUB MouseProc CDECL (BYVAL nButton AS LONG, BYVAL nState AS LONG, BYVAL x AS LONG, BYVAL y AS LONG)
        
           SELECT CASE nButton
              CASE %GLUT_LEFT_BUTTON
                 IF nState = %GLUT_DOWN THEN
                    spin = (spin + 30) MOD 360
                    glutPostRedisplay
                 END IF
           END SELECT
        
        END SUB
        ' ========================================================================================
        
        ' ========================================================================================
        ' Keyboard callback procedure
        ' ========================================================================================
        FUNCTION KeyboardProc CDECL (BYVAL nKey AS BYTE, BYVAL x AS LONG, BYVAL y AS  LONG) AS LONG
        
           SELECT CASE nKey
              CASE 27   ' Escape Key
                 glutLeaveMainLoop
           END SELECT
        
        END FUNCTION
        ' ========================================================================================
        
        ' ========================================================================================
        '/*  Main Loop
        ' *  Open window with initial window size, title bar,
        ' *  RGBA display mode, depth buffer, and handle input events.
        ' */
        ' ========================================================================================
        FUNCTION PBMAIN () AS LONG
        
           GlutInit 1, " "   ' We need at least one character or it will GPF
           glutInitDisplayMode %GLUT_SINGLE OR %GLUT_RGB OR %GLUT_DEPTH
           glutInitWindowSize 640, 480
           glutInitWindowPosition 0, 0
           glutCreateWindow $WindowCaption
           Init
           glutReshapeFunc  CODEPTR(ReshapeProc)
           glutKeyboardFunc CODEPTR(KeyboardProc)
           glutDisplayFunc  CODEPTR(DisplayProc)
           glutMouseFunc    CODEPTR(MouseProc)
           glutMainLoop
        
        END FUNCTION
        ' ========================================================================================
        Attached Files
        Forum: http://www.jose.it-berater.org/smfforum/index.php

        Comment


        • #24
          Code:
          '/*
          ' * Copyright (c) 1993-1997, Silicon Graphics, Inc.
          ' * ALL RIGHTS RESERVED
          ' * Permission to use, copy, modify, and distribute this software for
          ' * any purpose and without fee is hereby granted, provided that the above
          ' * copyright notice appear in all copies and that both the copyright notice
          ' * and this permission notice appear in supporting documentation, and that
          ' * the name of Silicon Graphics, Inc. not be used in advertising
          ' * or publicity pertaining to distribution of the software without specific,
          ' * written prior permission.
          ' *
          ' * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
          ' * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
          ' * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
          ' * FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL SILICON
          ' * GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
          ' * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
          ' * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
          ' * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
          ' * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC.  HAS BEEN
          ' * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
          ' * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
          ' * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
          ' *
          ' * US Government Users Restricted Rights
          ' * Use, duplication, or disclosure by the Government is subject to
          ' * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
          ' * (c)(1)(ii) of the Rights in Technical Data and Computer Software
          ' * clause at DFARS 252.227-7013 and/or in similar or successor
          ' * clauses in the FAR or the DOD or NASA FAR Supplement.
          ' * Unpublished-- rights reserved under the copyright laws of the
          ' * United States.  Contractor/manufacturer is Silicon Graphics,
          ' * Inc., 2011 N.  Shoreline Blvd., Mountain View, CA 94039-7311.
          ' *
          ' * OpenGL(R) is a registered trademark of Silicon Graphics, Inc.
          ' */
          
          '/*
          ' *  planet.c
          ' *  This program shows how to composite modeling transformations
          ' *  to draw translated and rotated models.
          ' *  Interaction:  pressing the d and y keys (day and year)
          ' *  alters the rotation of the planet around the sun.
          ' */
          
          ' Translated and adapted to PowerBASIC by José Roca, 2007
          
          ' SED_PBWIN - Use the PBWIN compiler
          #COMPILE EXE
          #DIM ALL
          #INCLUDE "freeglut.inc"
          
          $WindowCaption = "planet"
          
          GLOBAL year, day AS LONG
          
          ' ========================================================================================
          SUB Init ()
          
             glClearColor 0.0, 0.0, 0.0, 0.0
             glShadeModel %GL_FLAT
          
          END SUB
          ' ========================================================================================
          
          ' ========================================================================================
          SUB DisplayProc CDECL ()
          
             glClear %GL_COLOR_BUFFER_BIT
             glColor3f 1.0, 1.0, 1.0
          
             glPushMatrix
             glutWireSphere 1.0, 20, 16  ' /* draw sun */
             glRotatef year, 0.0, 1.0, 0.0
             glTranslatef 2.0, 0.0, 0.0
             glRotatef day, 0.0, 1.0, 0.0
             glutWireSphere 0.2, 10, 8   ' /* draw smaller planet */
             glPopMatrix
             glutSwapBuffers
          
          END SUB
          ' ========================================================================================
          
          ' ========================================================================================
          ' Redisplay callback procedure
          ' ========================================================================================
          SUB ReshapeProc CDECL (BYVAL w AS LONG, BYVAL h AS LONG)
          
             glViewport 0, 0, w, h
             glMatrixMode %GL_PROJECTION
             glLoadIdentity
             gluPerspective 60.0, w / h, 1.0, 20.0
             glMatrixMode %GL_MODELVIEW
             glLoadIdentity
             gluLookAt 0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0
          
          END SUB
          ' ========================================================================================
          
          ' ========================================================================================
          ' Keyboard callback procedure
          ' ========================================================================================
          FUNCTION KeyboardProc CDECL (BYVAL nKey AS BYTE, BYVAL x AS LONG, BYVAL y AS  LONG) AS LONG
          
             SELECT CASE nKey
                CASE 27   ' Escape Key
                   glutLeaveMainLoop
                CASE ASC("d"), ASC("D")
                   day = (day + 10) MOD 360
                   glutPostRedisplay
                CASE ASC("y"), ASC("Y")
                   year = (year + 5) MOD 360
                   glutPostRedisplay
             END SELECT
          
          END FUNCTION
          ' ========================================================================================
          
          ' ========================================================================================
          '/*  Main Loop
          ' ========================================================================================
          FUNCTION PBMAIN () AS LONG
          
             GlutInit 1, " "   ' We need at least one character or it will GPF
             glutInitDisplayMode %GLUT_SINGLE OR %GLUT_RGB
             glutInitWindowSize 640, 480
             glutInitWindowPosition 0, 0
             glutCreateWindow $WindowCaption
             Init
             glutReshapeFunc  CODEPTR(ReshapeProc)
             glutKeyboardFunc CODEPTR(KeyboardProc)
             glutDisplayFunc  CODEPTR(DisplayProc)
             glutMainLoop
          
          END FUNCTION
          ' ========================================================================================
          Attached Files
          Forum: http://www.jose.it-berater.org/smfforum/index.php

          Comment


          • #25
            Code:
            '/*
            ' * Copyright (c) 1993-1997, Silicon Graphics, Inc.
            ' * ALL RIGHTS RESERVED
            ' * Permission to use, copy, modify, and distribute this software for
            ' * any purpose and without fee is hereby granted, provided that the above
            ' * copyright notice appear in all copies and that both the copyright notice
            ' * and this permission notice appear in supporting documentation, and that
            ' * the name of Silicon Graphics, Inc. not be used in advertising
            ' * or publicity pertaining to distribution of the software without specific,
            ' * written prior permission.
            ' *
            ' * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
            ' * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
            ' * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
            ' * FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL SILICON
            ' * GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
            ' * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
            ' * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
            ' * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
            ' * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC.  HAS BEEN
            ' * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
            ' * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
            ' * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
            ' *
            ' * US Government Users Restricted Rights
            ' * Use, duplication, or disclosure by the Government is subject to
            ' * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
            ' * (c)(1)(ii) of the Rights in Technical Data and Computer Software
            ' * clause at DFARS 252.227-7013 and/or in similar or successor
            ' * clauses in the FAR or the DOD or NASA FAR Supplement.
            ' * Unpublished-- rights reserved under the copyright laws of the
            ' * United States.  Contractor/manufacturer is Silicon Graphics,
            ' * Inc., 2011 N.  Shoreline Blvd., Mountain View, CA 94039-7311.
            ' *
            ' * OpenGL(R) is a registered trademark of Silicon Graphics, Inc.
            ' */
            
            '/*
            ' *  polyoff.c
            ' *  This program demonstrates polygon offset to draw a shaded
            ' *  polygon and its wireframe counterpart without ugly visual
            ' *  artifacts ("stitching").
            ' */
            
            ' Translated and adapted to PowerBASIC by José Roca, 2007
            
            ' SED_PBWIN - Use the PBWIN compiler
            #COMPILE EXE
            #DIM ALL
            #INCLUDE "freeglut.inc"
            
            $WindowCaption = "polyoff"
            
            GLOBAL list AS DWORD
            GLOBAL spinx AS LONG
            GLOBAL spiny AS LONG
            GLOBAL tdist AS SINGLE
            GLOBAL polyfactor AS SINGLE
            GLOBAL polyunits AS SINGLE
            
            ' ========================================================================================
            '/*  specify initial properties
            ' *  create display list with sphere
            ' *  initialize lighting and depth buffer
            ' */
            ' ========================================================================================
            SUB Init ()
            
               polyfactor = 1.0
               polyunits = 1.0
            
               DIM light_ambient(3) AS SINGLE
               DIM light_diffuse(3) AS SINGLE
               DIM light_specular(3) AS SINGLE
               DIM light_position(3) AS SINGLE
               DIM global_ambient(3) AS SINGLE
            
               ARRAY ASSIGN light_ambient() = 0.0, 0.0, 0.0, 1.0
               ARRAY ASSIGN light_diffuse() = 1.0, 1.0, 1.0, 1.0
               ARRAY ASSIGN light_specular() = 1.0, 1.0, 1.0, 1.0
               ARRAY ASSIGN light_position() = 1.0, 1.0, 1.0, 0.0
            
               ARRAY ASSIGN global_ambient() = 0.2, 0.2, 0.2, 1.0
            
               glClearColor 0.0, 0.0, 0.0, 1.0
            
               list = glGenLists(1)
               glNewList list, %GL_COMPILE
                  glutSolidSphere 1.0, 20, 12
               glEndList
            
               glEnable %GL_DEPTH_TEST
            
               glLightfv %GL_LIGHT0, %GL_AMBIENT, light_ambient(0)
               glLightfv %GL_LIGHT0, %GL_DIFFUSE, light_diffuse(0)
               glLightfv %GL_LIGHT0, %GL_SPECULAR, light_specular(0)
               glLightfv %GL_LIGHT0, %GL_POSITION, light_position(0)
               glLightModelfv %GL_LIGHT_MODEL_AMBIENT, global_ambient(0)
            
            END SUB
            ' ========================================================================================
            
            ' ========================================================================================
            '/*  display() draws two spheres, one with a gray, diffuse material,
            ' *  the other sphere with a magenta material with a specular highlight.
            ' */
            ' ========================================================================================
            SUB DisplayProc CDECL ()
            
               DIM rggray(3) AS SINGLE
               DIM rgblack(3) AS SINGLE
            
               ARRAY ASSIGN rggray() = 0.8, 0.8, 0.8, 1.0
               ARRAY ASSIGN rgblack() = 0.0, 0.0, 0.0, 1.0
            
               glClear %GL_COLOR_BUFFER_BIT OR %GL_DEPTH_BUFFER_BIT
               glPushMatrix
               glTranslatef 0.0, 0.0, tdist
               glRotatef spinx, 1.0, 0.0, 0.0
               glRotatef spiny, 0.0, 1.0, 0.0
            
               glMaterialfv %GL_FRONT, %GL_AMBIENT_AND_DIFFUSE, rggray(0)
               glMaterialfv %GL_FRONT, %GL_SPECULAR, rgblack(0)
               glMaterialf %GL_FRONT, %GL_SHININESS, 0.0
               glEnable %GL_LIGHTING
               glEnable %GL_LIGHT0
               glEnable %GL_POLYGON_OFFSET_FILL
               glPolygonOffset polyfactor, polyunits
               glCallList list
               glDisable %GL_POLYGON_OFFSET_FILL
            
               glDisable %GL_LIGHTING
               glDisable %GL_LIGHT0
               glColor3f 1.0, 1.0, 1.0
               glPolygonMode %GL_FRONT_AND_BACK, %GL_LINE
               glCallList list
               glPolygonMode %GL_FRONT_AND_BACK, %GL_FILL
            
               glPopMatrix
               glFlush
            
            END SUB
            ' ========================================================================================
            
            ' ========================================================================================
            ' Redisplay callback procedure
            ' /*  call when window is resized  */
            ' ========================================================================================
            SUB ReshapeProc CDECL (BYVAL w AS LONG, BYVAL h AS LONG)
            
               glViewport 0, 0, w, h
               glMatrixMode %GL_PROJECTION
               glLoadIdentity
               gluPerspective 45.0, w / h, 1.0, 10.0
               glMatrixMode %GL_MODELVIEW
               glLoadIdentity
               gluLookAt 0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0
            
            END SUB
            ' ========================================================================================
            
            ' ========================================================================================
            ' /*  call when mouse button is pressed  */
            ' ========================================================================================
            SUB MouseProc CDECL (BYVAL nButton AS LONG, BYVAL nState AS LONG, BYVAL x AS LONG, BYVAL y AS LONG)
            
               SELECT CASE nButton
                  CASE %GLUT_LEFT_BUTTON
                     SELECT CASE nState
                        CASE %GLUT_DOWN
                           spinx = (spinx + 5) MOD 360
                           glutPostRedisplay
                     END SELECT
                  CASE %GLUT_MIDDLE_BUTTON
                     SELECT CASE nState
                        CASE %GLUT_DOWN
                           spiny = (spiny + 5) MOD 360
                           glutPostRedisplay
                     END SELECT
            '      CASE %GLUT_RIGHT_BUTTON
            '         SELECT CASE nState
            '            CASE %GLUT_UP
            '            glutLeaveMainLoop
            '         END SELECT
               END SELECT
            
            END SUB
            ' ========================================================================================
            
            ' ========================================================================================
            ' Keyboard callback procedure
            ' ========================================================================================
            FUNCTION KeyboardProc CDECL (BYVAL nKey AS BYTE, BYVAL x AS LONG, BYVAL y AS  LONG) AS LONG
            
               SELECT CASE nKey
                  CASE 27   ' Escape Key
                     glutLeaveMainLoop
                  CASE ASC("t")
                     IF tdist < 4.0 THEN
                        tdist = tdist + 0.5
                        glutPostRedisplay
                     END IF
                  CASE ASC("T")
                     IF tdist > -5.0 THEN
                        tdist = tdist - 0.5
                        glutPostRedisplay
                     END IF
                  CASE ASC("f")
                     polyfactor = polyfactor + 0.1
                     glutPostRedisplay
                  CASE ASC("F")
                     polyfactor = polyfactor - 0.1
                     glutPostRedisplay
                  CASE ASC("u")
                     polyunits = polyunits + 1.0
                     glutPostRedisplay
                  CASE ASC("u")
                     polyunits = polyunits - 1.0
                     glutPostRedisplay
               END SELECT
            
            END FUNCTION
            ' ========================================================================================
            
            ' ========================================================================================
            '/*  Main Loop
            ' *  Open window with initial window size, title bar,
            ' *  RGBA display mode, and handle input events.
            ' */
            ' ========================================================================================
            FUNCTION PBMAIN () AS LONG
            
               GlutInit 1, " "   ' We need at least one character or it will GPF
               glutInitDisplayMode %GLUT_SINGLE OR %GLUT_RGB OR %GLUT_DEPTH
               glutInitWindowSize 640, 480
               glutInitWindowPosition 0, 0
               glutCreateWindow $WindowCaption
               Init
               glutReshapeFunc  CODEPTR(ReshapeProc)
               glutKeyboardFunc CODEPTR(KeyboardProc)
               glutDisplayFunc  CODEPTR(DisplayProc)
               glutMouseFunc    CODEPTR(MouseProc)
               glutMainLoop
            
            END FUNCTION
            ' ========================================================================================
            Attached Files
            Forum: http://www.jose.it-berater.org/smfforum/index.php

            Comment


            • #26
              Code:
              '/*
              ' * Copyright (c) 1993-1997, Silicon Graphics, Inc.
              ' * ALL RIGHTS RESERVED
              ' * Permission to use, copy, modify, and distribute this software for
              ' * any purpose and without fee is hereby granted, provided that the above
              ' * copyright notice appear in all copies and that both the copyright notice
              ' * and this permission notice appear in supporting documentation, and that
              ' * the name of Silicon Graphics, Inc. not be used in advertising
              ' * or publicity pertaining to distribution of the software without specific,
              ' * written prior permission.
              ' *
              ' * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
              ' * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
              ' * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
              ' * FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL SILICON
              ' * GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
              ' * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
              ' * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
              ' * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
              ' * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC.  HAS BEEN
              ' * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
              ' * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
              ' * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
              ' *
              ' * US Government Users Restricted Rights
              ' * Use, duplication, or disclosure by the Government is subject to
              ' * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
              ' * (c)(1)(ii) of the Rights in Technical Data and Computer Software
              ' * clause at DFARS 252.227-7013 and/or in similar or successor
              ' * clauses in the FAR or the DOD or NASA FAR Supplement.
              ' * Unpublished-- rights reserved under the copyright laws of the
              ' * United States.  Contractor/manufacturer is Silicon Graphics,
              ' * Inc., 2011 N.  Shoreline Blvd., Mountain View, CA 94039-7311.
              ' *
              ' * OpenGL(R) is a registered trademark of Silicon Graphics, Inc.
              ' */
              
              '/*
              ' *  polys.c
              ' *  This program demonstrates polygon stippling.
              ' */
              
              ' Translated and adapted to PowerBASIC by José Roca, 2007
              
              ' SED_PBWIN - Use the PBWIN compiler
              #COMPILE EXE
              #DIM ALL
              #INCLUDE "freeglut.inc"
              
              $WindowCaption = "polys"
              
              ' ========================================================================================
              SUB Init ()
              
                 glClearColor 0.0, 0.0, 0.0, 0.0
                 glShadeModel %GL_FLAT
              
              END SUB
              ' ========================================================================================
              
              ' ========================================================================================
              SUB DisplayProc CDECL ()
              
                 DIM fly(128) AS BYTE
              
                 ARRAY ASSIGN fly() = _
                    &H00, &H00, &H00, &H00, &H00, &H00, &H00, &H00, _
                    &H03, &H80, &H01, &HC0, &H06, &HC0, &H03, &H60, _
                    &H04, &H60, &H06, &H20, &H04, &H30, &H0C, &H20, _
                    &H04, &H18, &H18, &H20, &H04, &H0C, &H30, &H20, _
                    &H04, &H06, &H60, &H20, &H44, &H03, &HC0, &H22, _
                    &H44, &H01, &H80, &H22, &H44, &H01, &H80, &H22, _
                    &H44, &H01, &H80, &H22, &H44, &H01, &H80, &H22, _
                    &H44, &H01, &H80, &H22, &H44, &H01, &H80, &H22, _
                    &H66, &H01, &H80, &H66, &H33, &H01, &H80, &HCC, _
                    &H19, &H81, &H81, &H98, &H0C, &HC1, &H83, &H30, _
                    &H07, &He1, &H87, &He0, &H03, &H3f, &Hfc, &Hc0, _
                    &H03, &H31, &H8c, &Hc0, &H03, &H33, &Hcc, &Hc0, _
                    &H06, &H64, &H26, &H60, &H0c, &Hcc, &H33, &H30, _
                    &H18, &Hcc, &H33, &H18, &H10, &Hc4, &H23, &H08, _
                    &H10, &H63, &HC6, &H08, &H10, &H30, &H0c, &H08, _
                    &H10, &H18, &H18, &H08, &H10, &H00, &H00, &H08
              
                 DIM halftone(128) AS BYTE
              
                 ARRAY ASSIGN halftone() = _
                    &HAA, &HAA, &HAA, &HAA, &H55, &H55, &H55, &H55, _
                    &HAA, &HAA, &HAA, &HAA, &H55, &H55, &H55, &H55, _
                    &HAA, &HAA, &HAA, &HAA, &H55, &H55, &H55, &H55, _
                    &HAA, &HAA, &HAA, &HAA, &H55, &H55, &H55, &H55, _
                    &HAA, &HAA, &HAA, &HAA, &H55, &H55, &H55, &H55, _
                    &HAA, &HAA, &HAA, &HAA, &H55, &H55, &H55, &H55, _
                    &HAA, &HAA, &HAA, &HAA, &H55, &H55, &H55, &H55, _
                    &HAA, &HAA, &HAA, &HAA, &H55, &H55, &H55, &H55, _
                    &HAA, &HAA, &HAA, &HAA, &H55, &H55, &H55, &H55, _
                    &HAA, &HAA, &HAA, &HAA, &H55, &H55, &H55, &H55, _
                    &HAA, &HAA, &HAA, &HAA, &H55, &H55, &H55, &H55, _
                    &HAA, &HAA, &HAA, &HAA, &H55, &H55, &H55, &H55, _
                    &HAA, &HAA, &HAA, &HAA, &H55, &H55, &H55, &H55, _
                    &HAA, &HAA, &HAA, &HAA, &H55, &H55, &H55, &H55, _
                    &HAA, &HAA, &HAA, &HAA, &H55, &H55, &H55, &H55, _
                    &HAA, &HAA, &HAA, &HAA, &H55, &H55, &H55, &H55
              
                 glClear %GL_COLOR_BUFFER_BIT
                 glColor3f 1.0, 1.0, 1.0
              
                 '/*  draw one solid, unstippled rectangle,	*/
                 '/*  then two stippled rectangles		*/
                 glRectf 25.0, 25.0, 125.0, 125.0
                 glEnable %GL_POLYGON_STIPPLE
                 glPolygonStipple fly(0)
                 glRectf 125.0, 25.0, 225.0, 125.0
                 glPolygonStipple halftone(0)
                 glRectf 225.0, 25.0, 325.0, 125.0
                 glDisable %GL_POLYGON_STIPPLE
              
                 glFlush
              
              END SUB
              ' ========================================================================================
              
              ' ========================================================================================
              ' Redisplay callback procedure
              ' ========================================================================================
              SUB ReshapeProc CDECL (BYVAL w AS LONG, BYVAL h AS LONG)
              
                 glViewport 0, 0, w, h
                 glMatrixMode %GL_PROJECTION
                 glLoadIdentity
                 gluOrtho2D 0.0, w, 0.0, h
              
              END SUB
              ' ========================================================================================
              
              ' ========================================================================================
              ' Keyboard callback procedure
              ' ========================================================================================
              FUNCTION KeyboardProc CDECL (BYVAL nKey AS BYTE, BYVAL x AS LONG, BYVAL y AS  LONG) AS LONG
              
                 SELECT CASE nKey
                    CASE 27   ' Escape Key
                       glutLeaveMainLoop
                 END SELECT
              
              END FUNCTION
              ' ========================================================================================
              
              ' ========================================================================================
              '/*  Main Loop
              ' *  Open window with initial window size, title bar,
              ' *  color index display mode, and handle input events.
              ' */
              ' ========================================================================================
              FUNCTION PBMAIN () AS LONG
              
                 GlutInit 1, " "   ' We need at least one character or it will GPF
                 glutInitDisplayMode %GLUT_SINGLE OR %GLUT_RGB
                 glutInitWindowSize 640, 480
                 glutInitWindowPosition 0, 0
                 glutCreateWindow $WindowCaption
                 Init
                 glutReshapeFunc  CODEPTR(ReshapeProc)
                 glutKeyboardFunc CODEPTR(KeyboardProc)
                 glutDisplayFunc  CODEPTR(DisplayProc)
                 glutMainLoop
              
              END FUNCTION
              ' ========================================================================================
              Attached Files
              Forum: http://www.jose.it-berater.org/smfforum/index.php

              Comment


              • #27
                Code:
                '/*
                ' * Copyright (c) 1993-1997, Silicon Graphics, Inc.
                ' * ALL RIGHTS RESERVED
                ' * Permission to use, copy, modify, and distribute this software for
                ' * any purpose and without fee is hereby granted, provided that the above
                ' * copyright notice appear in all copies and that both the copyright notice
                ' * and this permission notice appear in supporting documentation, and that
                ' * the name of Silicon Graphics, Inc. not be used in advertising
                ' * or publicity pertaining to distribution of the software without specific,
                ' * written prior permission.
                ' *
                ' * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
                ' * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
                ' * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
                ' * FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL SILICON
                ' * GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
                ' * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
                ' * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
                ' * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
                ' * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC.  HAS BEEN
                ' * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
                ' * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
                ' * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
                ' *
                ' * US Government Users Restricted Rights
                ' * Use, duplication, or disclosure by the Government is subject to
                ' * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
                ' * (c)(1)(ii) of the Rights in Technical Data and Computer Software
                ' * clause at DFARS 252.227-7013 and/or in similar or successor
                ' * clauses in the FAR or the DOD or NASA FAR Supplement.
                ' * Unpublished-- rights reserved under the copyright laws of the
                ' * United States.  Contractor/manufacturer is Silicon Graphics,
                ' * Inc., 2011 N.  Shoreline Blvd., Mountain View, CA 94039-7311.
                ' *
                ' * OpenGL(R) is a registered trademark of Silicon Graphics, Inc.
                ' */
                
                '/*
                ' *  quadric.c
                ' *  This program demonstrates the use of some of the gluQuadric*
                ' *  routines. Quadric objects are created with some quadric
                ' *  properties and the callback routine to handle errors.
                ' *  Note that the cylinder has no top or bottom and the circle
                ' *  has a hole in it.
                ' */
                
                ' Translated and adapted to PowerBASIC by José Roca, 2007
                
                ' SED_PBWIN - Use the PBWIN compiler
                #COMPILE EXE
                #DIM ALL
                #INCLUDE "freeglut.inc"
                
                $WindowCaption = "quadric"
                
                GLOBAL startList AS DWORD
                
                ' ========================================================================================
                SUB Init ()
                
                   LOCAL qobj AS DWORD
                   DIM mat_ambient(3) AS SINGLE
                   DIM mat_specular(3) AS SINGLE
                   DIM mat_shininess(0) AS SINGLE
                   DIM light_position(3) AS SINGLE
                   DIM model_ambient(3) AS SINGLE
                
                   ARRAY ASSIGN mat_ambient() = 0.5, 0.5, 0.5, 1.0
                   ARRAY ASSIGN mat_specular() = 1.0, 1.0, 1.0, 1.0
                   ARRAY ASSIGN mat_shininess() = 50.0
                   ARRAY ASSIGN light_position() = 1.0, 1.0, 1.0, 0.0
                   ARRAY ASSIGN model_ambient() = 0.5, 0.5, 0.5, 1.0
                
                   glClearColor 0.0, 0.0, 0.0, 0.0
                
                   glMaterialfv %GL_FRONT, %GL_AMBIENT, mat_ambient(0)
                   glMaterialfv %GL_FRONT, %GL_SPECULAR, mat_specular(0)
                   glMaterialfv %GL_FRONT, %GL_SHININESS, mat_shininess(0)
                   glLightfv %GL_LIGHT0, %GL_POSITION, light_position(0)
                   glLightModelfv %GL_LIGHT_MODEL_AMBIENT, model_ambient(0)
                
                   glEnable %GL_LIGHTING
                   glEnable %GL_LIGHT0
                   glEnable %GL_DEPTH_TEST
                
                   '/*  Create 4 display lists, each with a different quadric object.
                   ' *  Different drawing styles and surface normal specifications
                   ' *  are demonstrated.
                   ' */
                   startList = glGenLists(4)
                   qobj = gluNewQuadric()
                '   gluQuadricCallback(qobj, GLU_ERROR,
                '                      errorCallback);
                
                   gluQuadricDrawStyle qobj, %GLU_FILL  ' /* smooth shaded */
                   gluQuadricNormals qobj, %GLU_SMOOTH
                   glNewList startList, %GL_COMPILE
                      gluSphere qobj, 0.75, 15, 10
                   glEndList
                
                   gluQuadricDrawStyle qobj, %GLU_FILL ' /* flat shaded */
                   gluQuadricNormals qobj, %GLU_FLAT
                   glNewList startList + 1, %GL_COMPILE
                      gluCylinder qobj, 0.5, 0.3, 1.0, 15, 5
                   glEndList
                
                   gluQuadricDrawStyle qobj, %GLU_LINE  ' /* all polygons wireframe */
                   gluQuadricNormals qobj, %GLU_NONE
                   glNewList startList + 2, %GL_COMPILE
                      gluDisk qobj, 0.25, 1.0, 20, 4
                   glEndList
                
                   gluQuadricDrawStyle qobj, %GLU_SILHOUETTE  ' /* boundary only  */
                   gluQuadricNormals qobj, %GLU_NONE
                   glNewList startList + 3, %GL_COMPILE
                      gluPartialDisk qobj, 0.0, 1.0, 20, 4, 0.0, 225.0
                   glEndList
                
                END SUB
                ' ========================================================================================
                
                ' ========================================================================================
                '/*  Draw 2 diagonal lines to form an X
                ' */
                ' ========================================================================================
                SUB DisplayProc CDECL ()
                
                   glClear %GL_COLOR_BUFFER_BIT OR %GL_DEPTH_BUFFER_BIT
                   glPushMatrix
                
                   glEnable %GL_LIGHTING
                   glShadeModel %GL_SMOOTH
                   glTranslatef -1.0, -1.0, 0.0
                   glCallList startList
                
                   glShadeModel %GL_FLAT
                   glTranslatef 0.0, 2.0, 0.0
                   glPushMatrix
                   glRotatef 300.0, 1.0, 0.0, 0.0
                   glCallList startList + 1
                   glPopMatrix
                
                   glDisable %GL_LIGHTING
                   glColor3f 0.0, 1.0, 1.0
                   glTranslatef 2.0, -2.0, 0.0
                   glCallList startList + 2
                
                   glColor3f 1.0, 1.0, 0.0
                   glTranslatef 0.0, 2.0, 0.0
                   glCallList startList + 3
                
                   glPopMatrix
                   glFlush
                
                END SUB
                ' ========================================================================================
                
                ' ========================================================================================
                ' Redisplay callback procedure
                ' ========================================================================================
                SUB ReshapeProc CDECL (BYVAL w AS LONG, BYVAL h AS LONG)
                
                   glViewport 0, 0, w, h
                   glMatrixMode %GL_PROJECTION
                   glLoadIdentity
                   IF w <= h THEN
                      glOrtho -2.5, 2.5, -2.5 * h / w, _
                         2.5 * h / w, -10.0, 10.0
                   ELSE
                      glOrtho -2.5 * w / h, _
                         2.5 * w / h, -2.5, 2.5, -10.0, 10.0
                   END IF
                   glMatrixMode %GL_MODELVIEW
                   glLoadIdentity
                
                END SUB
                ' ========================================================================================
                
                ' ========================================================================================
                ' Keyboard callback procedure
                ' ========================================================================================
                FUNCTION KeyboardProc CDECL (BYVAL nKey AS BYTE, BYVAL x AS LONG, BYVAL y AS  LONG) AS LONG
                
                   SELECT CASE nKey
                      CASE 27   ' Escape Key
                         glutLeaveMainLoop
                   END SELECT
                
                END FUNCTION
                ' ========================================================================================
                
                ' ========================================================================================
                '/*  Main Loop
                ' *  Open window with initial window size, title bar,
                ' *  color index display mode, and handle input events.
                ' */
                ' ========================================================================================
                FUNCTION PBMAIN () AS LONG
                
                   GlutInit 1, " "   ' We need at least one character or it will GPF
                   glutInitDisplayMode %GLUT_SINGLE OR %GLUT_RGB OR %GLUT_DEPTH
                   glutInitWindowSize 640, 480
                   glutInitWindowPosition 0, 0
                   glutCreateWindow $WindowCaption
                   Init
                   glutReshapeFunc  CODEPTR(ReshapeProc)
                   glutKeyboardFunc CODEPTR(KeyboardProc)
                   glutDisplayFunc  CODEPTR(DisplayProc)
                   glutMainLoop
                
                END FUNCTION
                ' ========================================================================================
                Attached Files
                Forum: http://www.jose.it-berater.org/smfforum/index.php

                Comment


                • #28
                  Code:
                  '/*
                  ' * Copyright (c) 1993-1997, Silicon Graphics, Inc.
                  ' * ALL RIGHTS RESERVED
                  ' * Permission to use, copy, modify, and distribute this software for
                  ' * any purpose and without fee is hereby granted, provided that the above
                  ' * copyright notice appear in all copies and that both the copyright notice
                  ' * and this permission notice appear in supporting documentation, and that
                  ' * the name of Silicon Graphics, Inc. not be used in advertising
                  ' * or publicity pertaining to distribution of the software without specific,
                  ' * written prior permission.
                  ' *
                  ' * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
                  ' * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
                  ' * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
                  ' * FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL SILICON
                  ' * GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
                  ' * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
                  ' * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
                  ' * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
                  ' * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC.  HAS BEEN
                  ' * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
                  ' * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
                  ' * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
                  ' *
                  ' * US Government Users Restricted Rights
                  ' * Use, duplication, or disclosure by the Government is subject to
                  ' * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
                  ' * (c)(1)(ii) of the Rights in Technical Data and Computer Software
                  ' * clause at DFARS 252.227-7013 and/or in similar or successor
                  ' * clauses in the FAR or the DOD or NASA FAR Supplement.
                  ' * Unpublished-- rights reserved under the copyright laws of the
                  ' * United States.  Contractor/manufacturer is Silicon Graphics,
                  ' * Inc., 2011 N.  Shoreline Blvd., Mountain View, CA 94039-7311.
                  ' *
                  ' * OpenGL(R) is a registered trademark of Silicon Graphics, Inc.
                  ' */
                  
                  '/*
                  ' *  aaindex.c
                  ' *  This program draws shows how to draw anti-aliased lines in color
                  ' *  index mode. It draws two diagonal lines to form an X; when 'r'
                  ' *  is typed in the window, the lines are rotated in opposite
                  ' *  directions.
                  ' */
                  
                  ' Translated and adapted to PowerBASIC by José Roca, 2007
                  
                  ' SED_PBWIN - Use the PBWIN compiler
                  #COMPILE EXE
                  #DIM ALL
                  #INCLUDE "freeglut.inc"
                  
                  $WindowCaption = "robot"
                  
                  GLOBAL shoulder AS LONG
                  GLOBAL elbow AS LONG
                  
                  ' ========================================================================================
                  SUB Init ()
                  
                     glClearColor 0.0, 0.0, 0.0, 0.0
                     glShadeModel %GL_FLAT
                  
                  END SUB
                  ' ========================================================================================
                  
                  ' ========================================================================================
                  '/*  Draw 2 diagonal lines to form an X
                  ' */
                  ' ========================================================================================
                  SUB DisplayProc CDECL ()
                  
                     glClear %GL_COLOR_BUFFER_BIT
                     glPushMatrix
                     glTranslatef -1.0, 0.0, 0.0
                     glRotatef shoulder, 0.0, 0.0, 1.0
                     glTranslatef 1.0, 0.0, 0.0
                     glPushMatrix
                     glScalef 2.0, 0.4, 1.0
                     glutWireCube 1.0
                     glPopMatrix
                  
                     glTranslatef 1.0, 0.0, 0.0
                     glRotatef elbow, 0.0, 0.0, 1.0
                     glTranslatef 1.0, 0.0, 0.0
                     glPushMatrix
                     glScalef 2.0, 0.4, 1.0
                     glutWireCube 1.0
                     glPopMatrix
                  
                     glPopMatrix
                     glutSwapBuffers
                  
                  END SUB
                  ' ========================================================================================
                  
                  ' ========================================================================================
                  ' Redisplay callback procedure
                  ' ========================================================================================
                  SUB ReshapeProc CDECL (BYVAL w AS LONG, BYVAL h AS LONG)
                  
                     glViewport 0, 0, w, h
                     glMatrixMode %GL_PROJECTION
                     glLoadIdentity
                     gluPerspective 65.0, w / h, 1.0, 20.0
                     glMatrixMode %GL_MODELVIEW
                     glLoadIdentity
                     glTranslatef 0.0, 0.0, -5.0
                  
                  END SUB
                  ' ========================================================================================
                  
                  ' ========================================================================================
                  ' Keyboard callback procedure
                  ' ========================================================================================
                  FUNCTION KeyboardProc CDECL (BYVAL nKey AS BYTE, BYVAL x AS LONG, BYVAL y AS  LONG) AS LONG
                  
                     SELECT CASE nKey
                        CASE 27   ' Escape Key
                           glutLeaveMainLoop
                        CASE ASC("s")
                           shoulder = (shoulder + 5) MOD 360
                           glutPostRedisplay
                        CASE ASC("S")
                           shoulder = (shoulder - 5) MOD 360
                           glutPostRedisplay
                        CASE ASC("e")
                           elbow = (elbow + 5) MOD 360
                           glutPostRedisplay
                        CASE ASC("E")
                           elbow = (elbow - 5) MOD 360
                           glutPostRedisplay
                     END SELECT
                  
                  END FUNCTION
                  ' ========================================================================================
                  
                  ' ========================================================================================
                  ' Main Loop
                  ' ========================================================================================
                  FUNCTION PBMAIN () AS LONG
                  
                     GlutInit 1, " "   ' We need at least one character or it will GPF
                     glutInitDisplayMode %GLUT_DOUBLE OR %GLUT_RGB
                     glutInitWindowSize 640, 480
                     glutInitWindowPosition 0, 0
                     glutCreateWindow $WindowCaption
                     Init
                     glutReshapeFunc  CODEPTR(ReshapeProc)
                     glutKeyboardFunc CODEPTR(KeyboardProc)
                     glutDisplayFunc  CODEPTR(DisplayProc)
                     glutMainLoop
                  
                  END FUNCTION
                  ' ========================================================================================
                  Attached Files
                  Forum: http://www.jose.it-berater.org/smfforum/index.php

                  Comment


                  • #29
                    Code:
                    '/*
                    ' * Copyright (c) 1993-1997, Silicon Graphics, Inc.
                    ' * ALL RIGHTS RESERVED
                    ' * Permission to use, copy, modify, and distribute this software for
                    ' * any purpose and without fee is hereby granted, provided that the above
                    ' * copyright notice appear in all copies and that both the copyright notice
                    ' * and this permission notice appear in supporting documentation, and that
                    ' * the name of Silicon Graphics, Inc. not be used in advertising
                    ' * or publicity pertaining to distribution of the software without specific,
                    ' * written prior permission.
                    ' *
                    ' * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
                    ' * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
                    ' * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
                    ' * FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL SILICON
                    ' * GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
                    ' * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
                    ' * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
                    ' * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
                    ' * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC.  HAS BEEN
                    ' * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
                    ' * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
                    ' * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
                    ' *
                    ' * US Government Users Restricted Rights
                    ' * Use, duplication, or disclosure by the Government is subject to
                    ' * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
                    ' * (c)(1)(ii) of the Rights in Technical Data and Computer Software
                    ' * clause at DFARS 252.227-7013 and/or in similar or successor
                    ' * clauses in the FAR or the DOD or NASA FAR Supplement.
                    ' * Unpublished-- rights reserved under the copyright laws of the
                    ' * United States.  Contractor/manufacturer is Silicon Graphics,
                    ' * Inc., 2011 N.  Shoreline Blvd., Mountain View, CA 94039-7311.
                    ' *
                    ' * OpenGL(R) is a registered trademark of Silicon Graphics, Inc.
                    ' */
                    
                    '/*
                    ' *  scene.c
                    ' *  This program demonstrates the use of the GL lighting model.
                    ' *  Objects are drawn using a grey material characteristic.
                    ' *  A single light source illuminates the objects.
                    ' */
                    
                    ' Translated and adapted to PowerBASIC by José Roca, 2007
                    
                    ' SED_PBWIN - Use the PBWIN compiler
                    #COMPILE EXE
                    #DIM ALL
                    #INCLUDE "freeglut.inc"
                    
                    $WindowCaption = "scene"
                    
                    ' ========================================================================================
                    '/*  Initialize material property and light source.
                    ' */
                    ' ========================================================================================
                    SUB Init ()
                    
                       DIM light_ambient(3) AS SINGLE
                       DIM light_diffuse(3) AS SINGLE
                       DIM light_specular(3) AS SINGLE
                       DIM light_position(3) AS SINGLE
                    
                       ARRAY ASSIGN light_ambient() = 0.0, 0.0, 0.0, 1.0
                       ARRAY ASSIGN light_diffuse() = 1.0, 1.0, 1.0, 1.0
                       ARRAY ASSIGN light_specular() = 1.0, 1.0, 1.0, 1.0
                       ' /*	light_position is NOT default value	*/
                       ARRAY ASSIGN light_position() = 1.0, 1.0, 1.0, 0.0
                    
                       glLightfv %GL_LIGHT0, %GL_AMBIENT, light_ambient(0)
                       glLightfv %GL_LIGHT0, %GL_DIFFUSE, light_diffuse(0)
                       glLightfv %GL_LIGHT0, %GL_SPECULAR, light_specular(0)
                       glLightfv %GL_LIGHT0, %GL_POSITION, light_position(0)
                    
                       glEnable %GL_LIGHTING
                       glEnable %GL_LIGHT0
                       glEnable %GL_DEPTH_TEST
                    
                    END SUB
                    ' ========================================================================================
                    
                    ' ========================================================================================
                    SUB DisplayProc CDECL ()
                    
                       glClear %GL_COLOR_BUFFER_BIT OR %GL_DEPTH_BUFFER_BIT
                    
                       glPushMatrix
                       glRotatef 20.0, 1.0, 0.0, 0.0
                    
                       glPushMatrix
                       glTranslatef -0.75, 0.5, 0.0
                       glRotatef 90.0, 1.0, 0.0, 0.0
                       glutSolidTorus 0.275, 0.85, 15, 15
                       glPopMatrix
                    
                       glPushMatrix
                       glTranslatef -0.75, -0.5, 0.0
                       glRotatef 270.0, 1.0, 0.0, 0.0
                       glutSolidCone 1.0, 2.0, 15, 15
                       glPopMatrix
                    
                       glPushMatrix
                       glTranslatef 0.75, 0.0, -1.0
                       glutSolidSphere 1.0, 15, 15
                       glPopMatrix
                    
                       glPopMatrix
                       glFlush
                    
                    END SUB
                    ' ========================================================================================
                    
                    ' ========================================================================================
                    ' Redisplay callback procedure
                    ' ========================================================================================
                    SUB ReshapeProc CDECL (BYVAL w AS LONG, BYVAL h AS LONG)
                    
                       glViewport 0, 0, w, h
                       glMatrixMode %GL_PROJECTION
                       glLoadIdentity
                       IF w <= h THEN
                          glOrtho -2.5, 2.5, -2.5 * h / w, _
                                  2.5 * h / w, -10.0, 10.0
                       ELSE
                          glOrtho -2.5 * w / h, _
                                  2.5 * w / h, -2.5, 2.5, -10.0, 10.0
                       END IF
                       glMatrixMode %GL_MODELVIEW
                       glLoadIdentity
                    
                    END SUB
                    ' ========================================================================================
                    
                    ' ========================================================================================
                    ' Keyboard callback procedure
                    ' ========================================================================================
                    FUNCTION KeyboardProc CDECL (BYVAL nKey AS BYTE, BYVAL x AS LONG, BYVAL y AS  LONG) AS LONG
                    
                       SELECT CASE nKey
                          CASE 27   ' Escape Key
                             glutLeaveMainLoop
                       END SELECT
                    
                    END FUNCTION
                    ' ========================================================================================
                    
                    ' ========================================================================================
                    '/*  Main Loop
                    ' *  Open window with initial window size, title bar,
                    ' *  color index display mode, and handle input events.
                    ' */
                    ' ========================================================================================
                    FUNCTION PBMAIN () AS LONG
                    
                       GlutInit 1, " "   ' We need at least one character or it will GPF
                       glutInitDisplayMode %GLUT_SINGLE OR %GLUT_RGB OR %GLUT_DEPTH
                       glutInitWindowSize 640, 480
                       glutInitWindowPosition 0, 0
                       glutCreateWindow $WindowCaption
                       Init
                       glutReshapeFunc  CODEPTR(ReshapeProc)
                       glutKeyboardFunc CODEPTR(KeyboardProc)
                       glutDisplayFunc  CODEPTR(DisplayProc)
                       glutMainLoop
                    
                    END FUNCTION
                    ' ========================================================================================
                    Attached Files
                    Forum: http://www.jose.it-berater.org/smfforum/index.php

                    Comment


                    • #30
                      Code:
                      '/* Copyright (c) Mark J. Kilgard, 1996. */
                      
                      '/* This program is freely distributable without licensing fees
                      '   and is provided without guarantee or warrantee expressed or
                      '   implied. This program is -not- in the public domain. */
                      
                      '/* This program is a response to a question posed by Gil Colgate
                      '   <[email protected]> about how lengthy a program is required using
                      '   OpenGL compared to using  Direct3D immediate mode to "draw a
                      '   triangle at screen coordinates 0,0, to 200,200 to 20,200, and I
                      '   want it to be blue at the top vertex, red at the left vertex, and
                      '   green at the right vertex".  I'm not sure how long the Direct3D
                      '   program is; Gil has used Direct3D and his guess is "about 3000
                      '   lines of code". */
                      
                      '/* X compile line: cc -o simple simple.c -lglut -lGLU -lGL -lXmu -lXext -lX11 -lm */
                      
                      
                      ' Translated and adapted to PowerBASIC by José Roca, 2007
                      
                      ' SED_PBWIN - Use the PBWIN compiler
                      #COMPILE EXE
                      #DIM ALL
                      #INCLUDE "FreeGlut.inc"
                      
                      $WindowCaption = "single triangle"
                      
                      ' ========================================================================================
                      ' Redisplay callback procedure
                      ' ========================================================================================
                      SUB ReshapeProc CDECL (BYVAL w AS LONG, BYVAL h AS LONG)
                      
                      '  /* Because Gil specified "screen coordinates" (presumably with an
                      '     upper-left origin), this short bit of code sets up the coordinate
                      '     system to correspond to actual window coodrinates.  This code
                      '     wouldn't be required if you chose a (more typical in 3D) abstract
                      '     coordinate system. */
                      
                         glViewport 0, 0, w, h        ' /* Establish viewing area to cover entire window. */
                         glMatrixMode %GL_PROJECTION  ' /* Start modifying the projection matrix. */
                         glLoadIdentity               ' /* Reset project matrix. */
                         glOrtho 0, w, 0, h, -1, 1    ' /* Map abstract coords directly to window coords. */
                         glScalef 1, -1, 1            ' /* Invert Y axis so increasing Y goes down. */
                         glTranslatef 0, -h, 0        ' /* Shift origin up to upper-left corner. */
                      
                      END SUB
                      ' ========================================================================================
                      
                      ' ========================================================================================
                      ' Display procedure
                      ' ========================================================================================
                      SUB DisplayProc CDECL ()
                      
                         glClear %GL_COLOR_BUFFER_BIT
                         glBegin %GL_TRIANGLES
                            glColor3f 0.0, 0.0, 1.0    ' /* blue */
                            glVertex2i 0, 0
                            glColor3f 0.0, 1.0, 0.0    ' /* green */
                            glVertex2i 200, 200
                            glColor3f 1.0, 0.0, 0.0    ' /* red */
                            glVertex2i 20, 200
                         glEnd
                         glFlush    ' /* Single buffered, so needs a flush. */
                      
                      END SUB
                      ' ========================================================================================
                      
                      ' ========================================================================================
                      ' Keyboard callback procedure
                      ' ========================================================================================
                      FUNCTION KeyboardProc CDECL (BYVAL nKey AS BYTE, BYVAL x AS LONG, BYVAL y AS  LONG) AS LONG
                      
                         SELECT CASE nKey
                            CASE 27   ' Escape Key
                               glutLeaveMainLoop
                         END SELECT
                      
                      END FUNCTION
                      ' ========================================================================================
                      
                      ' ========================================================================================
                      ' Main Loop
                      ' ========================================================================================
                      FUNCTION PBMAIN () AS LONG
                      
                         GlutInit 1, " "   ' We need at least one character or it will GPF
                         glutCreateWindow $WindowCaption
                         glutReshapeFunc  CODEPTR(ReshapeProc)
                         glutKeyboardFunc CODEPTR(KeyboardProc)
                         glutDisplayFunc  CODEPTR(DisplayProc)
                         glutMainLoop
                      
                      END FUNCTION
                      ' ========================================================================================
                      Attached Files
                      Forum: http://www.jose.it-berater.org/smfforum/index.php

                      Comment


                      • #31
                        Code:
                        '/*
                        ' * Copyright (c) 1993-1997, Silicon Graphics, Inc.
                        ' * ALL RIGHTS RESERVED
                        ' * Permission to use, copy, modify, and distribute this software for
                        ' * any purpose and without fee is hereby granted, provided that the above
                        ' * copyright notice appear in all copies and that both the copyright notice
                        ' * and this permission notice appear in supporting documentation, and that
                        ' * the name of Silicon Graphics, Inc. not be used in advertising
                        ' * or publicity pertaining to distribution of the software without specific,
                        ' * written prior permission.
                        ' *
                        ' * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
                        ' * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
                        ' * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
                        ' * FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL SILICON
                        ' * GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
                        ' * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
                        ' * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
                        ' * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
                        ' * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC.  HAS BEEN
                        ' * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
                        ' * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
                        ' * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
                        ' *
                        ' * US Government Users Restricted Rights
                        ' * Use, duplication, or disclosure by the Government is subject to
                        ' * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
                        ' * (c)(1)(ii) of the Rights in Technical Data and Computer Software
                        ' * clause at DFARS 252.227-7013 and/or in similar or successor
                        ' * clauses in the FAR or the DOD or NASA FAR Supplement.
                        ' * Unpublished-- rights reserved under the copyright laws of the
                        ' * United States.  Contractor/manufacturer is Silicon Graphics,
                        ' * Inc., 2011 N.  Shoreline Blvd., Mountain View, CA 94039-7311.
                        ' *
                        ' * OpenGL(R) is a registered trademark of Silicon Graphics, Inc.
                        ' */
                        
                        '/*
                        ' * smooth.c
                        ' * This program demonstrates smooth shading.
                        ' * A smooth shaded polygon is drawn in a 2-D projection.
                        ' */
                        
                        ' Translated and adapted to PowerBASIC by José Roca, 2007
                        
                        ' SED_PBWIN - Use the PBWIN compiler
                        #COMPILE EXE
                        #DIM ALL
                        #INCLUDE "freeglut.inc"
                        
                        $WindowCaption = "smooth"
                        
                        ' ========================================================================================
                        SUB Init ()
                        
                           glClearColor 0.0, 0.0, 0.0, 0.0
                           glShadeModel %GL_SMOOTH
                        
                        END SUB
                        ' ========================================================================================
                        
                        ' ========================================================================================
                        SUB triangle()
                        
                           glBegin %GL_TRIANGLES
                           glColor3f 1.0, 0.0, 0.0
                           glVertex2f 5.0, 5.0
                           glColor3f 0.0, 1.0, 0.0
                           glVertex2f 25.0, 5.0
                           glColor3f 0.0, 0.0, 1.0
                           glVertex2f 5.0, 25.0
                           glEnd
                        
                        END SUB
                        ' ========================================================================================
                        
                        ' ========================================================================================
                        SUB DisplayProc CDECL ()
                        
                           glClear %GL_COLOR_BUFFER_BIT
                           triangle
                           glFlush
                        
                        END SUB
                        ' ========================================================================================
                        
                        ' ========================================================================================
                        ' Redisplay callback procedure
                        ' ========================================================================================
                        SUB ReshapeProc CDECL (BYVAL w AS LONG, BYVAL h AS LONG)
                        
                           glViewport 0, 0, w, h
                           glMatrixMode %GL_PROJECTION
                           glLoadIdentity
                           IF w <= h THEN
                              gluOrtho2D 0.0, 30.0, 0.0, 30.0 * h / w
                           ELSE
                              gluOrtho2D 0.0, 30.0 * w / h, 0.0, 30.0
                           END IF
                           glMatrixMode %GL_MODELVIEW
                        
                        END SUB
                        ' ========================================================================================
                        
                        ' ========================================================================================
                        ' Keyboard callback procedure
                        ' ========================================================================================
                        FUNCTION KeyboardProc CDECL (BYVAL nKey AS BYTE, BYVAL x AS LONG, BYVAL y AS  LONG) AS LONG
                        
                           SELECT CASE nKey
                              CASE 27   ' Escape Key
                                 glutLeaveMainLoop
                           END SELECT
                        
                        END FUNCTION
                        ' ========================================================================================
                        
                        ' ========================================================================================
                        '/*  Main Loop
                        ' *  Open window with initial window size, title bar,
                        ' *  color index display mode, and handle input events.
                        ' */
                        ' ========================================================================================
                        FUNCTION PBMAIN () AS LONG
                        
                           GlutInit 1, " "   ' We need at least one character or it will GPF
                           glutInitDisplayMode %GLUT_SINGLE OR %GLUT_RGB
                           glutInitWindowSize 640, 480
                           glutInitWindowPosition 0, 0
                           glutCreateWindow $WindowCaption
                           Init
                           glutReshapeFunc  CODEPTR(ReshapeProc)
                           glutKeyboardFunc CODEPTR(KeyboardProc)
                           glutDisplayFunc  CODEPTR(DisplayProc)
                           glutMainLoop
                        
                        END FUNCTION
                        ' ========================================================================================
                        Attached Files
                        Forum: http://www.jose.it-berater.org/smfforum/index.php

                        Comment


                        • #32
                          Code:
                          '/*
                          ' * Copyright (c) 1993-1997, Silicon Graphics, Inc.
                          ' * ALL RIGHTS RESERVED
                          ' * Permission to use, copy, modify, and distribute this software for
                          ' * any purpose and without fee is hereby granted, provided that the above
                          ' * copyright notice appear in all copies and that both the copyright notice
                          ' * and this permission notice appear in supporting documentation, and that
                          ' * the name of Silicon Graphics, Inc. not be used in advertising
                          ' * or publicity pertaining to distribution of the software without specific,
                          ' * written prior permission.
                          ' *
                          ' * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
                          ' * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
                          ' * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
                          ' * FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL SILICON
                          ' * GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
                          ' * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
                          ' * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
                          ' * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
                          ' * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC.  HAS BEEN
                          ' * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
                          ' * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
                          ' * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
                          ' *
                          ' * US Government Users Restricted Rights
                          ' * Use, duplication, or disclosure by the Government is subject to
                          ' * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
                          ' * (c)(1)(ii) of the Rights in Technical Data and Computer Software
                          ' * clause at DFARS 252.227-7013 and/or in similar or successor
                          ' * clauses in the FAR or the DOD or NASA FAR Supplement.
                          ' * Unpublished-- rights reserved under the copyright laws of the
                          ' * United States.  Contractor/manufacturer is Silicon Graphics,
                          ' * Inc., 2011 N.  Shoreline Blvd., Mountain View, CA 94039-7311.
                          ' *
                          ' * OpenGL(R) is a registered trademark of Silicon Graphics, Inc.
                          ' */
                          
                          '/*
                          ' *  stencil.c
                          ' *  This program demonstrates use of the stencil buffer for
                          ' *  masking nonrectangular regions.
                          ' *  Whenever the window is redrawn, a value of 1 is drawn
                          ' *  into a diamond-shaped region in the stencil buffer.
                          ' *  Elsewhere in the stencil buffer, the value is 0.
                          ' *  Then a blue sphere is drawn where the stencil value is 1,
                          ' *  and yellow torii are drawn where the stencil value is not 1.
                          ' */
                          
                          ' Translated and adapted to PowerBASIC by José Roca, 2007
                          
                          ' SED_PBWIN - Use the PBWIN compiler
                          #COMPILE EXE
                          #DIM ALL
                          #INCLUDE "freeglut.inc"
                          
                          $WindowCaption = "stencil"
                          
                          %YELLOWMAT = 1
                          %BLUEMAT   = 2
                          
                          ' ========================================================================================
                          SUB Init ()
                          
                             DIM yellow_diffuse(3) AS SINGLE
                             DIM yellow_specular(3) AS SINGLE
                             DIM blue_diffuse(3) AS SINGLE
                             DIM blue_specular(3) AS SINGLE
                             DIM position_one(3) AS SINGLE
                          
                             ARRAY ASSIGN yellow_diffuse() = 0.7, 0.7, 0.0, 1.0
                             ARRAY ASSIGN yellow_specular() = 1.0, 1.0, 1.0, 1.0
                          
                             ARRAY ASSIGN blue_diffuse() = 0.1, 0.1, 0.7, 1.0
                             ARRAY ASSIGN blue_specular() = 0.1, 1.0, 1.0, 1.0
                          
                             ARRAY ASSIGN position_one() = 1.0, 1.0, 1.0, 0.0
                          
                             glNewList %YELLOWMAT, %GL_COMPILE
                             glMaterialfv %GL_FRONT, %GL_DIFFUSE, yellow_diffuse(0)
                             glMaterialfv %GL_FRONT, %GL_SPECULAR, yellow_specular(0)
                             glMaterialf %GL_FRONT, %GL_SHININESS, 64.0
                             glEndList
                          
                             glNewList %BLUEMAT, %GL_COMPILE
                             glMaterialfv %GL_FRONT, %GL_DIFFUSE, blue_diffuse(0)
                             glMaterialfv %GL_FRONT, %GL_SPECULAR, blue_specular(0)
                             glMaterialf %GL_FRONT, %GL_SHININESS, 45.0
                             glEndList
                          
                             glLightfv %GL_LIGHT0, %GL_POSITION, position_one(0)
                          
                             glEnable %GL_LIGHT0
                             glEnable %GL_LIGHTING
                             glEnable %GL_DEPTH_TEST
                          
                             glClearStencil &H0
                             glEnable %GL_STENCIL_TEST
                          
                          END SUB
                          ' ========================================================================================
                          
                          ' ========================================================================================
                          '/* Draw a sphere in a diamond-shaped section in the
                          ' * middle of a window with 2 torii.
                          ' */
                          ' ========================================================================================
                          SUB DisplayProc CDECL ()
                          
                             glClear %GL_COLOR_BUFFER_BIT OR %GL_DEPTH_BUFFER_BIT
                          
                             ' /* draw blue sphere where the stencil is 1 */
                             glStencilFunc %GL_EQUAL, &H1, &H1
                             glStencilOp %GL_KEEP, %GL_KEEP, %GL_KEEP
                             glCallList %BLUEMAT
                             glutSolidSphere 0.5, 15, 15
                          
                             ' /* draw the tori where the stencil is not 1 */
                             glStencilFunc %GL_NOTEQUAL, &H1, &H1
                             glPushMatrix
                                glRotatef 45.0, 0.0, 0.0, 1.0
                                glRotatef 45.0, 0.0, 1.0, 0.0
                                glCallList %YELLOWMAT
                                glutSolidTorus 0.275, 0.85, 15, 15
                                glPushMatrix
                                   glRotatef 90.0, 1.0, 0.0, 0.0
                                   glutSolidTorus 0.275, 0.85, 15, 15
                                glPopMatrix
                             glPopMatrix
                          
                          END SUB
                          ' ========================================================================================
                          
                          ' ========================================================================================
                          ' Redisplay callback procedure
                          '/*  Whenever the window is reshaped, redefine the
                          ' *  coordinate system and redraw the stencil area.
                          ' */
                          ' ========================================================================================
                          SUB ReshapeProc CDECL (BYVAL w AS LONG, BYVAL h AS LONG)
                          
                             glViewport 0, 0, w, h
                          
                             ' /* create a diamond shaped stencil area */
                             glMatrixMode %GL_PROJECTION
                             glLoadIdentity
                             IF w <= h THEN
                                gluOrtho2D -3.0, 3.0, -3.0 * h / w, 3.0 * h / w
                             ELSE
                                gluOrtho2D -3.0 * w / h, 3.0 * w / h, -3.0, 3.0
                             END IF
                             glMatrixMode %GL_MODELVIEW
                             glLoadIdentity
                          
                             glClear %GL_STENCIL_BUFFER_BIT
                             glStencilFunc %GL_ALWAYS, &H1, &H1
                             glStencilOp %GL_REPLACE, %GL_REPLACE, %GL_REPLACE
                             glBegin %GL_QUADS
                                glVertex2f -1.0,  0.0
                                glVertex2f  0.0,  1.0
                                glVertex2f  1.0,  0.0
                                glVertex2f  0.0, -1.0
                             glEnd
                          
                             glMatrixMode %GL_PROJECTION
                             glLoadIdentity
                             gluPerspective 45.0, w / h, 3.0, 7.0
                             glMatrixMode %GL_MODELVIEW
                             glLoadIdentity
                             glTranslatef 0.0, 0.0, -5.0
                          
                          END SUB
                          ' ========================================================================================
                          
                          ' ========================================================================================
                          ' Keyboard callback procedure
                          ' ========================================================================================
                          FUNCTION KeyboardProc CDECL (BYVAL nKey AS BYTE, BYVAL x AS LONG, BYVAL y AS  LONG) AS LONG
                          
                             SELECT CASE nKey
                                CASE 27   ' Escape Key
                                   glutLeaveMainLoop
                             END SELECT
                          
                          END FUNCTION
                          ' ========================================================================================
                          
                          ' ========================================================================================
                          ' Main Loop
                          ' ========================================================================================
                          FUNCTION PBMAIN () AS LONG
                          
                             GlutInit 1, " "   ' We need at least one character or it will GPF
                             glutInitDisplayMode %GLUT_SINGLE OR %GLUT_RGB OR %GLUT_DEPTH OR %GLUT_STENCIL
                             glutInitWindowSize 640, 480
                             glutInitWindowPosition 0, 0
                             glutCreateWindow $WindowCaption
                             Init
                             glutReshapeFunc  CODEPTR(ReshapeProc)
                             glutKeyboardFunc CODEPTR(KeyboardProc)
                             glutDisplayFunc  CODEPTR(DisplayProc)
                             glutMainLoop
                          
                          END FUNCTION
                          ' ========================================================================================
                          Attached Files
                          Forum: http://www.jose.it-berater.org/smfforum/index.php

                          Comment


                          • #33
                            Code:
                            '/*
                            ' * Copyright (c) 1993-1997, Silicon Graphics, Inc.
                            ' * ALL RIGHTS RESERVED
                            ' * Permission to use, copy, modify, and distribute this software for
                            ' * any purpose and without fee is hereby granted, provided that the above
                            ' * copyright notice appear in all copies and that both the copyright notice
                            ' * and this permission notice appear in supporting documentation, and that
                            ' * the name of Silicon Graphics, Inc. not be used in advertising
                            ' * or publicity pertaining to distribution of the software without specific,
                            ' * written prior permission.
                            ' *
                            ' * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
                            ' * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
                            ' * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
                            ' * FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL SILICON
                            ' * GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
                            ' * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
                            ' * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
                            ' * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
                            ' * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC.  HAS BEEN
                            ' * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
                            ' * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
                            ' * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
                            ' *
                            ' * US Government Users Restricted Rights
                            ' * Use, duplication, or disclosure by the Government is subject to
                            ' * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
                            ' * (c)(1)(ii) of the Rights in Technical Data and Computer Software
                            ' * clause at DFARS 252.227-7013 and/or in similar or successor
                            ' * clauses in the FAR or the DOD or NASA FAR Supplement.
                            ' * Unpublished-- rights reserved under the copyright laws of the
                            ' * United States.  Contractor/manufacturer is Silicon Graphics,
                            ' * Inc., 2011 N.  Shoreline Blvd., Mountain View, CA 94039-7311.
                            ' *
                            ' * OpenGL(R) is a registered trademark of Silicon Graphics, Inc.
                            ' */
                            
                            '/*
                            ' *  surface.c
                            ' *  This program draws a NURBS surface in the shape of a
                            ' *  symmetrical hill.  The 'c' keyboard key allows you to
                            ' *  toggle the visibility of the control points themselves.
                            ' *  Note that some of the control points are hidden by the
                            ' *  surface itself.
                            ' */
                            
                            ' Translated and adapted to PowerBASIC by José Roca, 2007
                            
                            ' SED_PBWIN - Use the PBWIN compiler
                            #COMPILE EXE
                            #DIM ALL
                            #INCLUDE "freeglut.inc"
                            
                            $WindowCaption = "surface"
                            
                            GLOBAL ctlpoints () AS SINGLE
                            GLOBAL showPoints AS LONG
                            GLOBAL theNurb AS DWORD
                            
                            ' ========================================================================================
                            '/*
                            ' *  Initializes the control points of the surface to a small hill.
                            ' *  The control points range from -3 to +3 in x, y, and z
                            ' */
                            ' ========================================================================================
                            SUB init_surface()
                            
                               LOCAL u, v AS LONG
                               DIM ctlpoints(2, 3, 3)
                            
                               FOR u = 0 TO 3
                                  FOR v = 0 TO 3
                                     ctlpoints(0, v, u) = 2.0 * (u - 1.5)
                                     ctlpoints(1, v, u) = 2.0 * (v - 1.5)
                            
                                     IF (u = 1 OR u = 2) AND (v = 1 OR v = 2) THEN
                                        ctlpoints(2, v, u) = 3.0
                                     ELSE
                                        ctlpoints(2, v, 8)= -3.0
                                     END IF
                                  NEXT
                               NEXT
                            
                            END SUB
                            ' ========================================================================================
                            
                            ' ========================================================================================
                            '/*  Initialize material property and depth buffer.
                            ' */
                            ' ========================================================================================
                            SUB Init ()
                            
                               DIM mat_diffuse(3) AS SINGLE
                               DIM mat_specular(3) AS SINGLE
                               DIM mat_shininess(0) AS SINGLE
                            
                               ARRAY ASSIGN mat_diffuse() = 0.7, 0.7, 0.7, 1.0
                               ARRAY ASSIGN mat_specular() = 1.0, 1.0, 1.0, 1.0
                               ARRAY ASSIGN mat_shininess() = 100.0
                            
                               glClearColor 0.0, 0.0, 0.0, 0.0
                               glMaterialfv %GL_FRONT, %GL_DIFFUSE, mat_diffuse(0)
                               glMaterialfv %GL_FRONT, %GL_SPECULAR, mat_specular(0)
                               glMaterialfv %GL_FRONT, %GL_SHININESS, mat_shininess(0)
                            
                               glEnable %GL_LIGHTING
                               glEnable %GL_LIGHT0
                               glEnable %GL_DEPTH_TEST
                               glEnable %GL_AUTO_NORMAL
                               glEnable %GL_NORMALIZE
                            
                               init_surface
                            
                               theNurb = gluNewNurbsRenderer
                               gluNurbsProperty theNurb, %GLU_SAMPLING_TOLERANCE, 25.0
                               gluNurbsProperty theNurb, %GLU_DISPLAY_MODE, %GLU_FILL
                            
                            END SUB
                            ' ========================================================================================
                            
                            ' ========================================================================================
                            SUB DisplayProc CDECL ()
                            
                               GLOBAL i, j AS LONG
                            
                               DIM knots(7) AS SINGLE
                               ARRAY ASSIGN knots() = 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0
                            
                               glClear %GL_COLOR_BUFFER_BIT OR %GL_DEPTH_BUFFER_BIT
                               glPushMatrix
                               glRotatef 330.0, 1.0, 0.0, 0.0
                               glScalef  0.5, 0.5, 0.5
                            
                               gluBeginSurface theNurb
                               gluNurbsSurface theNurb, _
                                               8, knots(0), 8, knots(0), _
                                               4 * 3, 3, ctlpoints(0, 0, 0), _
                                               4, 4, %GL_MAP2_VERTEX_3
                               gluEndSurface theNurb
                            
                               IF showPoints THEN
                                  glPointSize 5.0
                                  glDisable %GL_LIGHTING
                                  glColor3f 1.0, 1.0, 0.0
                                  glBegin %GL_POINTS
                                  FOR i = 0 TO 3
                                     FOR j = 0 TO 3
                                        glVertex3f ctlpoints(0, j, i), _
                                                ctlpoints(1, j, i), ctlpoints(2, j, i)
                                     NEXT
                                  NEXT
                                  glEnd
                                  glEnable %GL_LIGHTING
                               END IF
                               glPopMatrix
                               glFlush
                            
                            END SUB
                            ' ========================================================================================
                            
                            ' ========================================================================================
                            ' Redisplay callback procedure
                            ' ========================================================================================
                            SUB ReshapeProc CDECL (BYVAL w AS LONG, BYVAL h AS LONG)
                            
                               glViewport 0, 0, w, h
                               glMatrixMode %GL_PROJECTION
                               glLoadIdentity
                               gluPerspective 45.0, w / h, 3.0, 8.0
                            
                               glMatrixMode %GL_MODELVIEW
                               glLoadIdentity
                               glTranslatef 0.0, 0.0, -5.0
                            
                            END SUB
                            ' ========================================================================================
                            
                            ' ========================================================================================
                            ' Keyboard callback procedure
                            ' ========================================================================================
                            FUNCTION KeyboardProc CDECL (BYVAL nKey AS BYTE, BYVAL x AS LONG, BYVAL y AS  LONG) AS LONG
                            
                               SELECT CASE nKey
                                  CASE 27   ' Escape Key
                                     glutLeaveMainLoop
                                  CASE ASC("c"), ASC("C")
                                     showPoints = NOT showPoints
                                     glutPostRedisplay
                               END SELECT
                            
                            END FUNCTION
                            ' ========================================================================================
                            
                            ' ========================================================================================
                            '/*  Main Loop
                            ' *  Open window with initial window size, title bar,
                            ' *  color index display mode, and handle input events.
                            ' */
                            ' ========================================================================================
                            FUNCTION PBMAIN () AS LONG
                            
                               GlutInit 1, " "   ' We need at least one character or it will GPF
                               glutInitDisplayMode %GLUT_SINGLE OR %GLUT_RGB OR %GLUT_DEPTH
                               glutInitWindowSize 640, 480
                               glutInitWindowPosition 0, 0
                               glutCreateWindow $WindowCaption
                               Init
                               glutReshapeFunc  CODEPTR(ReshapeProc)
                               glutKeyboardFunc CODEPTR(KeyboardProc)
                               glutDisplayFunc  CODEPTR(DisplayProc)
                               glutMainLoop
                            
                            END FUNCTION
                            ' ========================================================================================
                            Attached Files
                            Forum: http://www.jose.it-berater.org/smfforum/index.php

                            Comment


                            • #34
                              Code:
                              '/*
                              ' * Copyright (c) 1993-1997, Silicon Graphics, Inc.
                              ' * ALL RIGHTS RESERVED
                              ' * Permission to use, copy, modify, and distribute this software for
                              ' * any purpose and without fee is hereby granted, provided that the above
                              ' * copyright notice appear in all copies and that both the copyright notice
                              ' * and this permission notice appear in supporting documentation, and that
                              ' * the name of Silicon Graphics, Inc. not be used in advertising
                              ' * or publicity pertaining to distribution of the software without specific,
                              ' * written prior permission.
                              ' *
                              ' * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
                              ' * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
                              ' * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
                              ' * FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL SILICON
                              ' * GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
                              ' * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
                              ' * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
                              ' * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
                              ' * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC.  HAS BEEN
                              ' * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
                              ' * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
                              ' * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
                              ' *
                              ' * US Government Users Restricted Rights
                              ' * Use, duplication, or disclosure by the Government is subject to
                              ' * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
                              ' * (c)(1)(ii) of the Rights in Technical Data and Computer Software
                              ' * clause at DFARS 252.227-7013 and/or in similar or successor
                              ' * clauses in the FAR or the DOD or NASA FAR Supplement.
                              ' * Unpublished-- rights reserved under the copyright laws of the
                              ' * United States.  Contractor/manufacturer is Silicon Graphics,
                              ' * Inc., 2011 N.  Shoreline Blvd., Mountain View, CA 94039-7311.
                              ' *
                              ' * OpenGL(R) is a registered trademark of Silicon Graphics, Inc.
                              ' */
                              
                              '/*
                              ' *  teapots.c
                              ' *  This program demonstrates lots of material properties.
                              ' *  A single light source illuminates the objects.
                              ' */
                              
                              ' Translated and adapted to PowerBASIC by José Roca, 2007
                              
                              ' SED_PBWIN - Use the PBWIN compiler
                              #COMPILE EXE
                              #DIM ALL
                              #INCLUDE "freeglut.inc"
                              
                              $WindowCaption = "teapots"
                              
                              GLOBAL teapotList AS DWORD
                              
                              ' ========================================================================================
                              '/*
                              ' * Initialize depth buffer, projection matrix, light source, and lighting
                              ' * model.  Do not specify a material property here.
                              ' */
                              ' ========================================================================================
                              SUB Init ()
                              
                                 DIM ambient(3) AS SINGLE
                                 DIM diffuse(3) AS SINGLE
                                 DIM specular(3) AS SINGLE
                                 DIM position(3) AS SINGLE
                                 DIM lmodel_ambient(3) AS SINGLE
                                 DIM local_view(0) AS SINGLE
                              
                                 ARRAY ASSIGN ambient() = 0.0, 0.0, 0.0, 1.0
                                 ARRAY ASSIGN diffuse() = 1.0, 1.0, 1.0, 1.0
                                 ARRAY ASSIGN specular() = 1.0, 1.0, 1.0, 1.0
                                 ARRAY ASSIGN position() = 0.0, 3.0, 3.0, 0.0
                              
                                 ARRAY ASSIGN lmodel_ambient() = 0.2, 0.2, 0.2, 1.0
                                 ARRAY ASSIGN local_view() = 0.0
                              
                                 glLightfv %GL_LIGHT0, %GL_AMBIENT, ambient(0)
                                 glLightfv %GL_LIGHT0, %GL_DIFFUSE, diffuse(0)
                                 glLightfv %GL_LIGHT0, %GL_POSITION, position(0)
                                 glLightModelfv %GL_LIGHT_MODEL_AMBIENT, lmodel_ambient(0)
                                 glLightModelfv %GL_LIGHT_MODEL_LOCAL_VIEWER, local_view(0)
                              
                                 glFrontFace %GL_CW
                                 glEnable %GL_LIGHTING
                                 glEnable %GL_LIGHT0
                                 glEnable %GL_AUTO_NORMAL
                                 glEnable %GL_NORMALIZE
                                 glEnable %GL_DEPTH_TEST
                                 ' /*  be efficient--make teapot display list  */
                                 teapotList = glGenLists(1)
                                 glNewList teapotList, %GL_COMPILE
                                 glutSolidTeapot 1.0
                                 glEndList
                              
                              END SUB
                              ' ========================================================================================
                              
                              ' ========================================================================================
                              '/*
                              ' * Move object into position.  Use 3rd through 12th
                              ' * parameters to specify the material property.  Draw a teapot.
                              ' */
                              ' ========================================================================================
                              SUB renderTeapot(BYVAL x AS SINGLE, BYVAL y AS SINGLE, _
                                 BYVAL ambr AS SINGLE, BYVAL ambg AS SINGLE, BYVAL ambb AS SINGLE, _
                                 BYVAL difr AS SINGLE, BYVAL difg AS SINGLE, BYVAL difb AS SINGLE, _
                                 BYVAL specr AS SINGLE, BYVAL specg AS SINGLE, BYVAL specb AS SINGLE, BYVAL shine AS SINGLE)
                              
                                 DIM matx(3) AS SINGLE
                              
                                 glPushMatrix
                                 glTranslatef x, y, 0.0
                                 matx(0) = ambr : matx(1) = ambg : matx(2) = ambb : matx(3) = 1.0
                                 glMaterialfv %GL_FRONT, %GL_AMBIENT, matx(0)
                                 matx (0) = difr : matx(1) = difg : matx(2) = difb
                                 glMaterialfv %GL_FRONT, %GL_DIFFUSE, matx(0)
                                 matx(0) = specr : matx(1) = specg : matx(2) = specb
                                 glMaterialfv %GL_FRONT, %GL_SPECULAR, matx(0)
                                 glMaterialf %GL_FRONT, %GL_SHININESS, shine * 128.0
                                 glCallList teapotList
                                 glPopMatrix
                              
                              END SUB
                              ' ========================================================================================
                              
                              ' ========================================================================================
                              '/**
                              ' *  First column:  emerald, jade, obsidian, pearl, ruby, turquoise
                              ' *  2nd column:  brass, bronze, chrome, copper, gold, silver
                              ' *  3rd column:  black, cyan, green, red, white, yellow plastic
                              ' *  4th column:  black, cyan, green, red, white, yellow rubber
                              ' */
                              ' ========================================================================================
                              SUB DisplayProc CDECL ()
                              
                                 glClear %GL_COLOR_BUFFER_BIT OR %GL_DEPTH_BUFFER_BIT
                                 renderTeapot 2.0, 17.0, 0.0215, 0.1745, 0.0215, _
                                    0.07568, 0.61424, 0.07568, 0.633, 0.727811, 0.633, 0.6
                                 renderTeapot 2.0, 14.0, 0.135, 0.2225, 0.1575, _
                                    0.54, 0.89, 0.63, 0.316228, 0.316228, 0.316228, 0.1
                                 renderTeapot 2.0, 11.0, 0.05375, 0.05, 0.06625, _
                                    0.18275, 0.17, 0.22525, 0.332741, 0.328634, 0.346435, 0.3
                                 renderTeapot 2.0, 8.0, 0.25, 0.20725, 0.20725, _
                                    1, 0.829, 0.829, 0.296648, 0.296648, 0.296648, 0.088
                                 renderTeapot 2.0, 5.0, 0.1745, 0.01175, 0.01175, _
                                    0.61424, 0.04136, 0.04136, 0.727811, 0.626959, 0.626959, 0.6
                                 renderTeapot 2.0, 2.0, 0.1, 0.18725, 0.1745, _
                                    0.396, 0.74151, 0.69102, 0.297254, 0.30829, 0.306678, 0.1
                                 renderTeapot 6.0, 17.0, 0.329412, 0.223529, 0.027451, _
                                    0.780392, 0.568627, 0.113725, 0.992157, 0.941176, 0.807843, _
                                    0.21794872
                                 renderTeapot 6.0, 14.0, 0.2125, 0.1275, 0.054, _
                                    0.714, 0.4284, 0.18144, 0.393548, 0.271906, 0.166721, 0.2
                                 renderTeapot 6.0, 11.0, 0.25, 0.25, 0.25, _
                                    0.4, 0.4, 0.4, 0.774597, 0.774597, 0.774597, 0.6
                                 renderTeapot 6.0, 8.0, 0.19125, 0.0735, 0.0225, _
                                    0.7038, 0.27048, 0.0828, 0.256777, 0.137622, 0.086014, 0.1
                                 renderTeapot 6.0, 5.0, 0.24725, 0.1995, 0.0745, _
                                    0.75164, 0.60648, 0.22648, 0.628281, 0.555802, 0.366065, 0.4
                                 renderTeapot 6.0, 2.0, 0.19225, 0.19225, 0.19225, _
                                    0.50754, 0.50754, 0.50754, 0.508273, 0.508273, 0.508273, 0.4
                                 renderTeapot 10.0, 17.0, 0.0, 0.0, 0.0, 0.01, 0.01, 0.01, _
                                    0.50, 0.50, 0.50, .25
                                 renderTeapot 10.0, 14.0, 0.0, 0.1, 0.06, 0.0, 0.50980392, 0.50980392, _
                                    0.50196078, 0.50196078, 0.50196078, .25
                                 renderTeapot 10.0, 11.0, 0.0, 0.0, 0.0, _
                                    0.1, 0.35, 0.1, 0.45, 0.55, 0.45, .25
                                 renderTeapot 10.0, 8.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, _
                                    0.7, 0.6, 0.6, .25
                                 renderTeapot 10.0, 5.0, 0.0, 0.0, 0.0, 0.55, 0.55, 0.55, _
                                    0.70, 0.70, 0.70, .25
                                 renderTeapot 10.0, 2.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.0, _
                                    0.60, 0.60, 0.50, .25
                                 renderTeapot 14.0, 17.0, 0.02, 0.02, 0.02, 0.01, 0.01, 0.01, _
                                    0.4, 0.4, 0.4, .078125
                                 renderTeapot 14.0, 14.0, 0.0, 0.05, 0.05, 0.4, 0.5, 0.5, _
                                    0.04, 0.7, 0.7, .078125
                                 renderTeapot 14.0, 11.0, 0.0, 0.05, 0.0, 0.4, 0.5, 0.4, _
                                    0.04, 0.7, 0.04, .078125
                                 renderTeapot 14.0, 8.0, 0.05, 0.0, 0.0, 0.5, 0.4, 0.4, _
                                    0.7, 0.04, 0.04, .078125
                                 renderTeapot 14.0, 5.0, 0.05, 0.05, 0.05, 0.5, 0.5, 0.5, _
                                    0.7, 0.7, 0.7, .078125
                                 renderTeapot 14.0, 2.0, 0.05, 0.05, 0.0, 0.5, 0.5, 0.4, _
                                    0.7, 0.7, 0.04, .078125
                                 glFlush
                              
                              END SUB
                              ' ========================================================================================
                              
                              ' ========================================================================================
                              ' Redisplay callback procedure
                              ' ========================================================================================
                              SUB ReshapeProc CDECL (BYVAL w AS LONG, BYVAL h AS LONG)
                              
                                 glViewport 0, 0, w, h
                                 glMatrixMode %GL_PROJECTION
                                 glLoadIdentity
                                 IF w <= h THEN
                                    glOrtho 0.0, 16.0, 0.0, 16.0 * h / w, -10.0, 10.0
                                 ELSE
                                    glOrtho 0.0, 16.0 * w / h, 0.0, 16.0, -10.0, 10.0
                                 END IF
                                 glMatrixMode %GL_MODELVIEW
                              
                              END SUB
                              ' ========================================================================================
                              
                              ' ========================================================================================
                              ' Keyboard callback procedure
                              ' ========================================================================================
                              FUNCTION KeyboardProc CDECL (BYVAL nKey AS BYTE, BYVAL x AS LONG, BYVAL y AS  LONG) AS LONG
                              
                                 SELECT CASE nKey
                                    CASE 27   ' Escape Key
                                       glutLeaveMainLoop
                                 END SELECT
                              
                              END FUNCTION
                              ' ========================================================================================
                              
                              ' ========================================================================================
                              '/*  Main Loop
                              ' *  Open window with initial window size, title bar,
                              ' *  color index display mode, and handle input events.
                              ' */
                              ' ========================================================================================
                              FUNCTION PBMAIN () AS LONG
                              
                                 GlutInit 1, " "   ' We need at least one character or it will GPF
                                 glutInitDisplayMode %GLUT_SINGLE OR %GLUT_RGB OR %GLUT_DEPTH
                                 glutInitWindowSize 640, 480
                                 glutInitWindowPosition 0, 0
                                 glutCreateWindow $WindowCaption
                                 Init
                                 glutReshapeFunc  CODEPTR(ReshapeProc)
                                 glutKeyboardFunc CODEPTR(KeyboardProc)
                                 glutDisplayFunc  CODEPTR(DisplayProc)
                                 glutMainLoop
                              
                              END FUNCTION
                              ' ========================================================================================
                              Attached Files
                              Forum: http://www.jose.it-berater.org/smfforum/index.php

                              Comment


                              • #35
                                Code:
                                '/*
                                ' * Copyright (c) 1993-1997, Silicon Graphics, Inc.
                                ' * ALL RIGHTS RESERVED
                                ' * Permission to use, copy, modify, and distribute this software for
                                ' * any purpose and without fee is hereby granted, provided that the above
                                ' * copyright notice appear in all copies and that both the copyright notice
                                ' * and this permission notice appear in supporting documentation, and that
                                ' * the name of Silicon Graphics, Inc. not be used in advertising
                                ' * or publicity pertaining to distribution of the software without specific,
                                ' * written prior permission.
                                ' *
                                ' * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
                                ' * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
                                ' * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
                                ' * FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL SILICON
                                ' * GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
                                ' * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
                                ' * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
                                ' * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
                                ' * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC.  HAS BEEN
                                ' * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
                                ' * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
                                ' * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
                                ' *
                                ' * US Government Users Restricted Rights
                                ' * Use, duplication, or disclosure by the Government is subject to
                                ' * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
                                ' * (c)(1)(ii) of the Rights in Technical Data and Computer Software
                                ' * clause at DFARS 252.227-7013 and/or in similar or successor
                                ' * clauses in the FAR or the DOD or NASA FAR Supplement.
                                ' * Unpublished-- rights reserved under the copyright laws of the
                                ' * United States.  Contractor/manufacturer is Silicon Graphics,
                                ' * Inc., 2011 N.  Shoreline Blvd., Mountain View, CA 94039-7311.
                                ' *
                                ' * OpenGL(R) is a registered trademark of Silicon Graphics, Inc.
                                ' */
                                
                                '/*  texturesurf.c
                                ' *  This program uses evaluators to generate a curved
                                ' *  surface and automatically generated texture coordinates.
                                ' */
                                
                                ' Translated and adapted to PowerBASIC by José Roca, 2007
                                
                                ' SED_PBWIN - Use the PBWIN compiler
                                #COMPILE EXE
                                #DIM ALL
                                #INCLUDE "freeglut.inc"
                                
                                $WindowCaption = "texture surf"
                                
                                GLOBAL ctrlpoints() AS SINGLE
                                GLOBAL texpts() AS SINGLE
                                
                                %imageWidth  = 64
                                %imageHeight = 64
                                GLOBAL rgimage() AS BYTE
                                
                                ' ========================================================================================
                                SUB InitArrays ()
                                
                                   REDIM ctrlpoints(2, 3, 3)
                                
                                   ctrlpoints(0, 0, 0) = -1.5 : ctrlpoints(1, 0, 0) = -1.5 : ctrlpoints(2, 0, 0) =  4.0
                                   ctrlpoints(0, 1, 0) = -0.5 : ctrlpoints(1, 1, 0) = -1.5 : ctrlpoints(2, 1, 0) =  2.0
                                   ctrlpoints(0, 2, 0) =  0.5 : ctrlpoints(1, 2, 0) = -1.5 : ctrlpoints(2, 2, 0) = -1.0
                                   ctrlpoints(0, 3, 0) =  1.5 : ctrlpoints(1, 3, 0) = -1.5 : ctrlpoints(2, 3, 0) =  2.0
                                
                                   ctrlpoints(0, 0, 1) = -1.5 : ctrlpoints(1, 0, 1) = -0.5 : ctrlpoints(2, 0, 1) =  1.0
                                   ctrlpoints(0, 1, 1) = -0.5 : ctrlpoints(1, 1, 1) = -0.5 : ctrlpoints(2, 1, 1) =  3.0
                                   ctrlpoints(0, 2, 1) =  0.5 : ctrlpoints(1, 2, 1) = -0.5 : ctrlpoints(2, 2, 1) =  0.0
                                   ctrlpoints(0, 3, 1) =  1.5 : ctrlpoints(1, 3, 1) = -0.5 : ctrlpoints(2, 3, 1) = -1.0
                                
                                   ctrlpoints(0, 0, 2) = -1.5 : ctrlpoints(1, 0, 2) = -0.5 : ctrlpoints(2, 0, 2) =  4.0
                                   ctrlpoints(0, 1, 2) = -0.5 : ctrlpoints(1, 1, 2) = -0.5 : ctrlpoints(2, 1, 2) =  0.0
                                   ctrlpoints(0, 2, 2) =  0.5 : ctrlpoints(1, 2, 2) = -0.5 : ctrlpoints(2, 2, 2) =  3.0
                                   ctrlpoints(0, 3, 2) =  1.5 : ctrlpoints(1, 3, 2) = -0.5 : ctrlpoints(2, 3, 2) =  4.0
                                
                                   ctrlpoints(0, 0, 3) = -1.5 : ctrlpoints(1, 0, 3) = 1.5 : ctrlpoints(2, 0, 3) = -2.0
                                   ctrlpoints(0, 1, 3) = -0.5 : ctrlpoints(1, 1, 3) = 1.5 : ctrlpoints(2, 1, 3) = -2.0
                                   ctrlpoints(0, 2, 3) =  0.5 : ctrlpoints(1, 2, 3) = 1.5 : ctrlpoints(2, 2, 3) =  0.0
                                   ctrlpoints(0, 3, 3) =  1.5 : ctrlpoints(1, 3, 3) = 1.5 : ctrlpoints(2, 3, 3) = -1.0
                                
                                   REDIM texpts(1, 1, 1)
                                   texpts(0, 0, 0) = 0.0 : texpts(1, 0, 0) = 0.0
                                   texpts(0, 1, 0) = 0.0 : texpts(1, 1, 0) = 1.0
                                   texpts(0, 0, 1) = 1.0 : texpts(1, 0, 1) = 0.0
                                   texpts(0, 1, 1) = 1.0 : texpts(1, 1, 1) = 1.0
                                
                                END SUB
                                ' ========================================================================================
                                
                                ' ========================================================================================
                                SUB makeImage()
                                
                                   LOCAL i, j AS LONG
                                   LOCAL ti, tj AS SINGLE
                                
                                   REDIM rgimage(3 * %imageWidth * %imageHeight)
                                
                                   FOR i = 0 TO %imageWidth - 1
                                      ti = 2.0 * 3.14159265 * i / %imageWidth
                                      FOR j = 0 TO %imageHeight - 1
                                         tj = 2.0 * 3.14159265 * j / %imageHeight
                                         rgimage(3*(%imageHeight*i+j)) = 127*(1.0 + SIN(ti))
                                         rgimage(3*(%imageHeight*i+j)+1) = 127*(1.0 + COS(2*tj))
                                         rgimage(3*(%imageHeight*i+j)+2) = 127*(1.0 + COS(ti+tj))
                                      NEXT
                                   NEXT
                                
                                END SUB
                                ' ========================================================================================
                                
                                ' ========================================================================================
                                SUB DisplayProc CDECL ()
                                
                                   glClear %GL_COLOR_BUFFER_BIT OR %GL_DEPTH_BUFFER_BIT
                                   glColor3f 1.0, 1.0, 1.0
                                   glEvalMesh2 %GL_FILL, 0, 20, 0, 20
                                   glFlush
                                
                                END SUB
                                ' ========================================================================================
                                
                                ' ========================================================================================
                                SUB Init ()
                                
                                   InitArrays
                                
                                   glMap2f %GL_MAP2_VERTEX_3, 0, 1, 3, 4, _
                                           0, 1, 12, 4, ctrlpoints(0, 0, 0)
                                   glMap2f %GL_MAP2_TEXTURE_COORD_2, 0, 1, 2, 2, _
                                           0, 1, 4, 2, texpts(0, 0, 0)
                                   glEnable %GL_MAP2_TEXTURE_COORD_2
                                   glEnable %GL_MAP2_VERTEX_3
                                   glMapGrid2f 20, 0.0, 1.0, 20, 0.0, 1.0
                                   makeImage
                                   glTexEnvf %GL_TEXTURE_ENV, %GL_TEXTURE_ENV_MODE, %GL_DECAL
                                   glTexParameteri %GL_TEXTURE_2D, %GL_TEXTURE_WRAP_S, %GL_REPEAT
                                   glTexParameteri %GL_TEXTURE_2D, %GL_TEXTURE_WRAP_T, %GL_REPEAT
                                   glTexParameteri %GL_TEXTURE_2D, %GL_TEXTURE_MAG_FILTER, %GL_NEAREST
                                   glTexParameteri %GL_TEXTURE_2D, %GL_TEXTURE_MIN_FILTER, %GL_NEAREST
                                   glTexImage2D %GL_TEXTURE_2D, 0, %GL_RGB, %imageWidth, %imageHeight, 0, _
                                                %GL_RGB, %GL_UNSIGNED_BYTE, rgimage(0)
                                   glEnable %GL_TEXTURE_2D
                                   glEnable %GL_DEPTH_TEST
                                   glShadeModel %GL_FLAT
                                
                                END SUB
                                ' ========================================================================================
                                
                                ' ========================================================================================
                                ' Redisplay callback procedure
                                ' ========================================================================================
                                SUB ReshapeProc CDECL (BYVAL w AS LONG, BYVAL h AS LONG)
                                
                                   glViewport 0, 0, w, h
                                   glMatrixMode %GL_PROJECTION
                                   glLoadIdentity
                                   IF w <= h THEN
                                      glOrtho -4.0, 4.0, -4.0*h/w, 4.0*h/w, -4.0, 4.0
                                   ELSE
                                      glOrtho -4.0*w/h, 4.0*w/h, -4.0, 4.0, -4.0, 4.0
                                   END IF
                                   glMatrixMode %GL_MODELVIEW
                                   glLoadIdentity
                                   glRotatef 85.0, 1.0, 1.0, 1.0
                                
                                END SUB
                                ' ========================================================================================
                                
                                ' ========================================================================================
                                ' Keyboard callback procedure
                                ' ========================================================================================
                                FUNCTION KeyboardProc CDECL (BYVAL nKey AS BYTE, BYVAL x AS LONG, BYVAL y AS  LONG) AS LONG
                                
                                   SELECT CASE nKey
                                      CASE 27   ' Escape Key
                                         glutLeaveMainLoop
                                   END SELECT
                                
                                END FUNCTION
                                ' ========================================================================================
                                
                                ' ========================================================================================
                                '/*  Main Loop
                                ' *  Open window with initial window size, title bar,
                                ' *  color index display mode, and handle input events.
                                ' */
                                ' ========================================================================================
                                FUNCTION PBMAIN () AS LONG
                                
                                   GlutInit 1, " "   ' We need at least one character or it will GPF
                                   glutInitDisplayMode %GLUT_SINGLE OR %GLUT_RGB OR %GLUT_DEPTH
                                   glutInitWindowSize 640, 480
                                   glutInitWindowPosition 0, 0
                                   glutCreateWindow $WindowCaption
                                   Init
                                   glutReshapeFunc  CODEPTR(ReshapeProc)
                                   glutKeyboardFunc CODEPTR(KeyboardProc)
                                   glutDisplayFunc  CODEPTR(DisplayProc)
                                   glutMainLoop
                                
                                END FUNCTION
                                ' ========================================================================================
                                Attached Files
                                Forum: http://www.jose.it-berater.org/smfforum/index.php

                                Comment


                                • #36
                                  Code:
                                  '/*
                                  ' * Copyright (c) 1993-1997, Silicon Graphics, Inc.
                                  ' * ALL RIGHTS RESERVED
                                  ' * Permission to use, copy, modify, and distribute this software for
                                  ' * any purpose and without fee is hereby granted, provided that the above
                                  ' * copyright notice appear in all copies and that both the copyright notice
                                  ' * and this permission notice appear in supporting documentation, and that
                                  ' * the name of Silicon Graphics, Inc. not be used in advertising
                                  ' * or publicity pertaining to distribution of the software without specific,
                                  ' * written prior permission.
                                  ' *
                                  ' * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
                                  ' * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
                                  ' * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
                                  ' * FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL SILICON
                                  ' * GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
                                  ' * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
                                  ' * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
                                  ' * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
                                  ' * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC.  HAS BEEN
                                  ' * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
                                  ' * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
                                  ' * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
                                  ' *
                                  ' * US Government Users Restricted Rights
                                  ' * Use, duplication, or disclosure by the Government is subject to
                                  ' * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
                                  ' * (c)(1)(ii) of the Rights in Technical Data and Computer Software
                                  ' * clause at DFARS 252.227-7013 and/or in similar or successor
                                  ' * clauses in the FAR or the DOD or NASA FAR Supplement.
                                  ' * Unpublished-- rights reserved under the copyright laws of the
                                  ' * United States.  Contractor/manufacturer is Silicon Graphics,
                                  ' * Inc., 2011 N.  Shoreline Blvd., Mountain View, CA 94039-7311.
                                  ' *
                                  ' * OpenGL(R) is a registered trademark of Silicon Graphics, Inc.
                                  ' */
                                  
                                  '/*
                                  ' *  torus.c
                                  ' *  This program demonstrates the creation of a display list.
                                  ' */
                                  
                                  ' Translated and adapted to PowerBASIC by José Roca, 2007
                                  
                                  ' SED_PBWIN - Use the PBWIN compiler
                                  #COMPILE EXE
                                  #DIM ALL
                                  #INCLUDE "freeglut.inc"
                                  
                                  $WindowCaption = "torus"
                                  
                                  MACRO PI = 3.14159265358979323846
                                  
                                  GLOBAL theTorus AS DWORD
                                  
                                  ' ========================================================================================
                                  ' /* Draw a torus */
                                  ' ========================================================================================
                                  SUB torus(BYVAL numc AS LONG, BYVAL numt AS LONG)
                                  
                                     LOCAL i, j, k AS LONG
                                     LOCAL s, t, x, y, z, twopi AS DOUBLE
                                  
                                     twopi = 2 * PI
                                     FOR i = 0 TO numc - 1
                                        glBegin %GL_QUAD_STRIP
                                        FOR j = 0 TO numt
                                           FOR k = 1 TO 0 STEP -1
                                              s = (i + k) MOD numc + 0.5
                                              t = j MOD numt
                                  
                                              x = (1+.1*COS(s*twopi/numc))*COS(t*twopi/numt)
                                              y = (1+.1*COS(s*twopi/numc))*SIN(t*twopi/numt)
                                              z = .1 * SIN(s * twopi / numc)
                                              glVertex3f x, y, z
                                           NEXT
                                        NEXT
                                        glEnd
                                     NEXT
                                  
                                  END SUB
                                  ' ========================================================================================
                                  
                                  ' ========================================================================================
                                  ' /* Create display list with Torus and initialize state */
                                  ' ========================================================================================
                                  SUB Init ()
                                  
                                     theTorus = glGenLists(1)
                                     glNewList theTorus, %GL_COMPILE
                                     torus 8, 25
                                     glEndList
                                  
                                     glShadeModel %GL_FLAT
                                     glClearColor 0.0, 0.0, 0.0, 0.0
                                  
                                  END SUB
                                  ' ========================================================================================
                                  
                                  ' ========================================================================================
                                  ' /* Clear window and draw torus */
                                  ' ========================================================================================
                                  SUB DisplayProc CDECL ()
                                  
                                     glClear %GL_COLOR_BUFFER_BIT
                                     glColor3f 1.0, 1.0, 1.0
                                     glCallList theTorus
                                     glFlush
                                  
                                  END SUB
                                  ' ========================================================================================
                                  
                                  ' ========================================================================================
                                  ' /* Handle window resize */
                                  ' ========================================================================================
                                  SUB ReshapeProc CDECL (BYVAL w AS LONG, BYVAL h AS LONG)
                                  
                                     glViewport 0, 0, w, h
                                     glMatrixMode %GL_PROJECTION
                                     glLoadIdentity
                                     gluPerspective 30, w / h, 1.0, 100.0
                                     glMatrixMode %GL_MODELVIEW
                                     glLoadIdentity
                                     gluLookAt 0, 0, 10, 0, 0, 0, 0, 1, 0
                                  
                                  END SUB
                                  ' ========================================================================================
                                  
                                  ' ========================================================================================
                                  ' Keyboard callback procedure
                                  ' ========================================================================================
                                  FUNCTION KeyboardProc CDECL (BYVAL nKey AS BYTE, BYVAL x AS LONG, BYVAL y AS  LONG) AS LONG
                                  
                                     SELECT CASE nKey
                                        CASE 27   ' Escape Key
                                           glutLeaveMainLoop
                                        CASE ASC("x"), ASC("X")
                                           glRotatef 30.0, 1.0, 0.0, 0.0
                                           glutPostRedisplay
                                        CASE ASC("y"), ASC("Y")
                                           glRotatef 30.0, 0.0, 1.0, 0.0
                                           glutPostRedisplay
                                        CASE ASC("i"), ASC("I")
                                           glLoadIdentity
                                           gluLookAt 0, 0, 10, 0, 0, 0, 0, 1, 0
                                           glutPostRedisplay
                                     END SELECT
                                  
                                  END FUNCTION
                                  ' ========================================================================================
                                  
                                  ' ========================================================================================
                                  ' Main Loop
                                  ' ========================================================================================
                                  FUNCTION PBMAIN () AS LONG
                                  
                                     GlutInit 1, " "   ' We need at least one character or it will GPF
                                     glutInitDisplayMode %GLUT_SINGLE OR %GLUT_RGB
                                     glutInitWindowSize 640, 480
                                     glutInitWindowPosition 0, 0
                                     glutCreateWindow $WindowCaption
                                     Init
                                     glutReshapeFunc  CODEPTR(ReshapeProc)
                                     glutKeyboardFunc CODEPTR(KeyboardProc)
                                     glutDisplayFunc  CODEPTR(DisplayProc)
                                     glutMainLoop
                                  
                                  END FUNCTION
                                  ' ========================================================================================
                                  Attached Files
                                  Forum: http://www.jose.it-berater.org/smfforum/index.php

                                  Comment

                                  Working...
                                  X