Results 1 to 9 of 9

Thread: Basic example on passing value from ThinBASIC to shader

Threaded View

  1. #1
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Brno - Czech Republic
    Blog Entries
    Rep Power

    Basic example on passing value from ThinBASIC to shader

    GLSL shaders are indeed very useful tool for creating unusual graphic output.
    Sometimes you need to change shader behavior after compilation dynamically.
    There is interesting mechanism, which allows change shader variable values according to your ThinBASIC variables.

    The magic OpenGL commands to achieve this are two:
    glGetUniformLocationARB - to retrieve "pointer" to shader variable
    glUniform1fARB - to change variable located at "pointer" to other floating point value

    The attached script demonstrates this technique in the easiest way. Just use slider to modify the variable value and watch the impact on shader in realtime.

    Note: As this script demonstrates advanced technique, your card must be GLSL compatible. That means ideally support for OpenGL 2.0 or OpenGL 1.5 with extensions. Tested on GeForce 9500GT.
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	TBGL_ThinBASICVariableAndShaderBinding.png 
Views:	181 
Size:	12.6 KB 
ID:	6096  
    Attached Files Attached Files
    Last edited by Petr Schreiber; 19-05-2013 at 15:30.
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 7 64bit - Intel Core 2 Duo T6600 @ 2.2GHz - 4 GB RAM - NVIDIA GeForce G210M 512MB
    Windows 8 64bit - Intel Core i5-3350P @ 3.1GHz - 8 GB RAM - NVIDIA GeForce GT640 3GB

Posting Permissions

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