Page 2 of 2 FirstFirst 12
Results 11 to 17 of 17

Thread: stencil buffer question

  1. #11
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    Hi Largo,

    1)
    The proposed syntax is identical to native OpenGL, so in such a case it is better to use it directly:
    #include "thinBasic_gl.inc"
    
    ...
    
    glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, arrayOfParams)
    ' -- And so on
    
    Regarding the emission, I just added it for you as TBGL_SetMaterialEmission. You can download the preview here.

    2)
    If you need glEnable(GL_BLEND)/glDisable(GL_BLEND), you can use the OpenGL headers as I wrote in #1. In TBGL, the same functionality is solved via more flexible TBGL_UseBlend.
    I am not adding blending to material definition yet, as it is tricky (order dependent property). I need to think about it more.

    3)
    TBGL internally uses just OpenGL with extensions on the rendering side, so no 3rd party libraries are used. The internal design is done in way it is possible to mix TBGL with OpenGL calls in ThinBASIC scripts. I think it should be possible to mix it with other libraries as well.

    Support
    May I ask which browser do you use? I tried from FireFox 6 and there was no problem to create new issue by clicking that magic button.


    Petr
    Last edited by Petr Schreiber; 29-08-2011 at 14:29.
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  2. #12
    petr, thank you for little gifts! I will check new tbgl setMaterialEmission !

    1) short feedback question for understanding: I can create "transparent" material or "alpha-blending" (with current tbgl power) example like I did with freebasic ? see my antique example with freeglut.dll and included last years "freeglut.bi" library for this example. Push "A" key to set alpha blending and "b" for taking back.

    2) you've said: "The proposed syntax is identical to native OpenGL, so in such a case it is better to use it directly:".. these native functions are working for 100 per cent together with your tbgl commands ? I will check some new example to explore that behaviour. thank you for fast feedback and new material!

    3) firefox 3.6.

    bye, largo
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by largo_winch; 29-08-2011 at 14:55.

  3. #13
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    1)
    For alpha blending, you can use:
    TBGL_BlendFunc(%GL_SRC_ALPHA, %GL_ONE_MINUS_SRC_ALPHA)
    TBGL_PushState(%TBGL_Blend)
    
    ...
    
    TBGL_PopState
    
    So here comes whole example:
    Uses "TBGL" 
    
    Function TBMain()
      Local hWnd      As DWord
      Local FrameRate As Double
      
      ' -- Create and show window
      hWnd = TBGL_CreateWindowEx("TBGL script - press ESC to quit", 640, 480, 32, %TBGL_WS_WINDOWED Or %TBGL_WS_CLOSEBOX) 
      TBGL_ShowWindow 
    
      ' -- Initialize lighting
      TBGL_UseLighting(%TRUE)
      TBGL_UseLightSource(%GL_LIGHT0, %TRUE)    
      TBGL_SetLightParameter(%GL_LIGHT0, %TBGL_LIGHT_POSITION, 10, 10, 10, 1)
      
      ' -- Setup material 1
      ' -- Create new materials
      Global mBlue  As Long = TBGL_NewMaterial  
      Global mGreen As Long = TBGL_NewMaterial  
      
      ' -- Set properties
      TBGL_SetMaterialDiffuse(mBlue, 0, 0, 255)
      TBGL_SetMaterialAmbient(mBlue, 0, 0, 255) 
      TBGL_SetMaterialSpecular(mBlue, 255, 255, 255)
      TBGL_SetMaterialSpecularExponent(mBlue, 128)  
    
      TBGL_SetMaterialDiffuse(mGreen, 0, 255, 0, 128)
      TBGL_SetMaterialAmbient(mGreen, 0, 255, 0) 
      TBGL_SetMaterialSpecular(mGreen, 255, 255, 255)
      TBGL_SetMaterialSpecularExponent(mGreen, 128)  
    
      ' -- Resets status of all keys 
      TBGL_ResetKeyState()
    
      ' -- Main loop
      While TBGL_IsWindow(hWnd)           
        FrameRate = TBGL_GetFrameRate
    
        TBGL_ClearFrame 
          TBGL_Camera(5, 5, 10, 0, 0, 0)
          
          ' -- Transform
          TBGL_PushMatrix
            ' -- Material
            TBGL_PushMaterial mBlue
              TBGL_Sphere 1
            TBGL_PopMaterial
            
          TBGL_PopMatrix
    
          ' -- Transform
          TBGL_PushMatrix
            TBGL_Translate 0.5, 0.5, 0
            
            ' -- Blending
            TBGL_BlendFunc(%GL_SRC_ALPHA, %GL_ONE_MINUS_SRC_ALPHA)
            TBGL_PushState(%TBGL_BLEND)
            
              ' -- Material
              TBGL_PushMaterial mGreen            
                TBGL_Sphere 1
              TBGL_PopMaterial
              
            TBGL_PopState  
              
          TBGL_PopMatrix      
    
        TBGL_DrawFrame 
    
        ' -- ESCAPE key to exit application
        If TBGL_GetWindowKeyState(hWnd, %VK_ESCAPE) Then Exit While 
    
      Wend 
    
      TBGL_DestroyWindow
    End Function
    
    2)
    You should be able to use FreeGlut primitives for example. Try it out, if you have time.

    3)
    I don't want to force you to do anything, but I would strongly recommend to upgrade to Firefox 5/6.

    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  4. #14

    my example works! :)

    Well and so simple!, I can see: that was only missing important command "TBGL_PushState(%TBGL_BLEND)" I didn't know this nice little blending helpers! Thank you petr for your short and interesting example! I am learning walking tbgl like a child!

    As you can see in my example I have placed "TBGL_PushStateProtected" in subs I didn't want to blend. I have tried last days blending with "TBGL_BlendFunc(%GL_SRC_ALPHA, %GL_ONE_MINUS_SRC_ALPHA)" in my subs but without "applying" these blending function command (TBGL_PushState(%TBGL_BLEND) ) to specific material it couldn't work!

    my correct blending example I have had in mind last days to realize with tbgl I send again. Now the result for me is very ok!

    bye, largo
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by largo_winch; 29-08-2011 at 17:20.

  5. #15
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    I am happy it worked for you!
    Demo ran okay here

    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  6. #16

    texturing, blending, materials

    this little example shows how to texture primitives with current example project.

    @petr: How I can make a reflection effect as you did in tbgl_advanced_dungeonWithCollisionBlend ("the old tumb") example with different floor textures ? btw: the old dungeon example has a little rotation problem with function "chunkCalcPositionAndDraw()"

    zip folder contains all textures. bye, largo
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by largo_winch; 13-09-2011 at 11:30.

  7. #17
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    Hi Largo,

    the reflection was made using simple trick - the floor was transparent and the scene was rendered upside down below the floor to create the illusion


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

Page 2 of 2 FirstFirst 12

Similar Threads

  1. How to read the keyboard buffer?
    By Michael Hartlef in forum thinBasic General
    Replies: 7
    Last Post: 18-05-2009, 08:47
  2. UDT question
    By sandyrepope in forum thinBasic General
    Replies: 3
    Last Post: 18-02-2008, 22:33

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
  •