Results 1 to 3 of 3

Thread: Example: Section 4.3 (page 28), My First OGL Program (second program)

  1. #1
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    67
    Posts
    3,869
    Rep Power
    404

    Example: Section 4.3 (page 28), My First OGL Program (second program)

    The attachment contains the necessary model file for the teapot and also the source code.
    [code=thinbasic]' Example 4.3 First OpenGL Program

    ' From Stan Blank's Book:
    ' "Python Programming in OpenGL
    ' "A Graphical Approach to Programming

    ' Converted by Kent Sarikaya
    ' Last modified: February 25, 2010


    ' thinBasic does not use GLUT, we use instead tbgl
    Uses "TBGL"


    ' It is nice to use Constants instead of just numbers
    %teapot = 1


    ' We need to load our teapot mesh
    TBGL_m15LoadModel "teapot.m15", "", %teapot, 0, %TBGL_NORMAL_SMOOTH

    ' We are not using any special lighting in this example
    TBGL_UseLighting %FALSE

    ' Handle for our window
    Local hWnd As DWord

    ' Create and show window
    hWnd = TBGL_CreateWindowEx("My Second OGL Program", 250, 250, 32, %TBGL_WS_WINDOWED Or %TBGL_WS_CLOSEBOX)
    TBGL_ShowWindow

    ' Resets status of all keys
    TBGL_ResetKeyState()

    ' Main loop
    While TBGL_IsWindow(hWnd)
    TBGL_ClearFrame
    ' This gives us our wireframe look
    TBGL_PolygonLook %GL_LINE

    ' Move the teapot away from the camera so we can see it, the camera by default is at position 0,0,0
    TBGL_Translate 0,0,-1.75

    ' I imported the model in the wrong direction so I will compensate for the rotation here
    ' 90 degress in the y axis
    TBGL_Rotate 90, 0,1,0
    TBGL_m15DrawModel %teapot
    TBGL_DrawFrame

    ' ESCAPE key to exit application
    If TBGL_GetWindowKeyState(hWnd, %VK_ESCAPE) Then Exit While
    Wend

    TBGL_DestroyWindow



    'Python source page 28
    '# First Python OpenGL program
    '# ogl1.py
    'from OpenGL.GLUT import *
    'from OpenGL.GL import *
    'from OpenGL.GLU import *
    'def Draw():
    ' glClear(GL_COLOR_BUFFER_BIT)
    ' glutWireTeapot(0.5)
    ' glFlush()
    'glutInit(sys.argv)
    'glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB)
    'glutInitWindowSize(250, 250)
    'glutInitWindowPosition(100, 100)
    'glutCreateWindow("My Second OGL Program")
    'glutDisplayFunc(Draw)
    'glutMainLoop()
    '# End of program[/code]
    Attached Files Attached Files
    Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
    Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server

  2. #2
    Member sblank's Avatar
    Join Date
    Feb 2010
    Location
    Wayne City, Illinois
    Posts
    80
    Rep Power
    23

    Re: Example: Section 4.3 (page 28), My First OGL Program (second program)

    Fantastic! Nice work Kent!

    Stan

  3. #3
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    67
    Posts
    3,869
    Rep Power
    404

    Re: Example: Section 4.3 (page 28), My First OGL Program (second program)

    Thanks Stan, enjoying doing them while reading your book.
    Acer Notebook: Win 10 Home 64 Bit, Core i7-4702MQ @ 2.2Ghz, 12 GB RAM, nVidia GTX 760M and Intel HD 4600
    Raspberry Pi 3: Raspbian OS use for Home Samba Server and Test HTTP Server

Similar Threads

  1. Invoking One .tbasic Program From Another .tbasic Program
    By gungadout in forum thinBasic General
    Replies: 46
    Last Post: 23-11-2009, 12:01

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •