Page 2 of 7 FirstFirst 1234 ... LastLast
Results 11 to 20 of 62

Thread: m15 module

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

    Re: m15 module

    @Holomind, thanks for the links. I have used GLUT and for quick things it is nice I think. There is also an opensource version that is udated now.

    The c++ app I started is being done as in your second link. But I know c++ is not a favorite of many (including me).


    @Petr

    I will experiment with viewport commands just to at least get a model viewer only and none of the other features.

    Summer is almost here and before you know it FALL will be here, so no problem waiting for the cool features that will be coming Petr.
    Nice to know they are in the works

    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. #12
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    67
    Posts
    3,869
    Rep Power
    404

    different background colors for viewports?

    Petr can we have different background colors for each viewport.

    I am trying the following and having no luck.
     TBGL_BackColor( 0, 0, 255 )
     TBGL_ClearFrame ( %TBGL_CLEAR_COLOR or %TBGL_RESET_MATRIX )
     'tbgl_ResetMatrix
     TBGL_Viewport 0,0.875,1,0.125
     TBGL_Camera 1,1,1,0,0,0
    
    It makes all the backgrounds the last color I specify with backcolor overwriting all earlier ones.
    Thanks
    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

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

    Re: m15 module

    Hi Kent,

    you are right. To clear the viewport background you could use a color cube, like in the following example:
    [code=thinBASIC]

    Uses "TBGL"

    ' -- Create and show window
    Dim hWnd As Dword = TBGL_CreateWindowEx("Viewports- press ESC to quit", 640, 480, 32, %TBGL_WS_WINDOWED or %TBGL_WS_CLOSEBOX)
    TBGL_ShowWindow

    TBGL_UseLighting %TRUE
    TBGL_UseLightSource %GL_LIGHT0, %TRUE

    tbgl_SetLightParameter %GL_LIGHT0, %TBGL_LIGHT_POSITION, 15, 10, 15, 1

    DIM FrameRate AS DOUBLE

    ' -- Resets status of all keys
    TBGL_GetAsyncKeyState(-1)

    ' -- Main loop
    While TBGL_IsWindow(hWnd)
    FrameRate = TBGL_GetFrameRate

    TBGL_ClearFrame


    tbgl_ViewPort 0, 0, 0.5, 0.5
    TBGL_Camera 15, 15, 15, 0, 0, 0
    TBGL_Color 128, 0, 0
    TBGL_Box 1, 1, 5
    DrawBackColor(128,0,0)

    TBGL_ClearFrame (%TBGL_RESET_MATRIX or %TBGL_CLEAR_DEPTH )

    tbgl_ViewPort 0.5, 0.5, 0.5, 0.5

    TBGL_Camera 15, 15, 15, 0, 0, 0
    TBGL_Color 0, 128, 0
    TBGL_Box 1, 2, 3
    DrawBackColor(0,128,0)

    TBGL_DrawFrame

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

    Wend

    TBGL_DestroyWindow

    sub DrawBackColor( r as byte, g as byte, b as byte )
    tbgl_ResetMatrix
    tbgl_UseLighting %FALSE
    tbgl_color r, g, b
    tbgl_Box 100,100,100
    tbgl_color 255, 255, 255
    tbgl_UseLighting %TRUE
    end sub
    [/code]

    One note - if you specify viewport with proportions different than parent window, the rendered image is stretched.

    For one 3D window and 2D overlay we don't need any viewports at all, see here:
    [code=thinbasic]

    Uses "TBGL"

    ' -- Create and show window
    Dim hWnd As Dword = TBGL_CreateWindowEx("Editor concept - press ESC to quit", 640, 480, 32, %TBGL_WS_WINDOWED or %TBGL_WS_CLOSEBOX)
    TBGL_ShowWindow

    TBGL_UseLighting %TRUE
    TBGL_UseLightSource %GL_LIGHT0, %TRUE

    tbgl_SetLightParameter %GL_LIGHT0, %TBGL_LIGHT_POSITION, 15, 10, 15, 1

    DIM FrameRate AS DOUBLE

    ' -- Resets status of all keys
    TBGL_GetAsyncKeyState(-1)

    ' -- Main loop
    While TBGL_IsWindow(hWnd)
    FrameRate = TBGL_GetFrameRate

    TBGL_ClearFrame
    ' -- Main scene
    tbgl_RenderMatrix3D

    TBGL_Camera 15, 15, 15, 0, 0, 0
    TBGL_Color 255, 128, 0
    tbgl_Rotate gettickcount/100,0,1,0
    TBGL_Box 1, 1, 5

    ' -- 2D overlay
    tbgl_RenderMatrix2D

    TBGL_USELIGHTING %FALSE
    TBGL_USEDEPTH %FALSE

    tbgl_BeginPoly %GL_QUADS
    ' -- "Dialog Backround"
    TBGL_Color 128, 128, 128
    tbgl_Vertex 0, 0
    tbgl_Vertex 640, 0
    tbgl_Vertex 640, 100
    tbgl_Vertex 0, 100

    TBGL_ENDPOLY

    DrawButton(10, 10, 60, 15)
    DrawButton(10, 30, 60, 15)
    DrawButton(10, 50, 60, 15)
    DrawButton(10, 70, 60, 15)

    TBGL_USEDEPTH %TRUE
    TBGL_USELIGHTING %TRUE

    TBGL_DrawFrame

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

    Wend

    TBGL_DestroyWindow

    sub DrawButton( x as long, y as long, width as long, height as long )

    tbgl_BeginPoly %GL_QUADS
    TBGL_Color 255, 128, 0

    tbgl_Vertex x, y
    tbgl_Vertex x+width, y
    tbgl_Vertex x+width, y+height
    tbgl_Vertex x, y+height
    TBGL_ENDPOLY

    end sub
    [/code]


    Thanks,
    Petr

    P.S. I will try to find solution for viewport image stretching, that is quite unwanted "feature". I think TBGL_RenderMatrix3D/2D should take current viewport size in consideration, I will change them to work this way.
    So TBGL_Viewport + TBGL_ResetMatrix3D will be solution for the problem
    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
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    67
    Posts
    3,869
    Rep Power
    404

    Re: m15 module

    Thanks Petr for examples.

    In the meantime I felt like dr frankenstein in putting your viewport and ui demo together into one.
    It is not working right in that I don't see the viewports.

    Can you take a look. I have 4 viewports still, but will get rid of them once can figure out why it is
    not showing behiind the ui stuff. Also the text is not showing up on the buttons.

    Maybe your fresh and also smart eyes can find what has eluded me in this long night
    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

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

    Re: m15 module

    Hi Kent,

    just put "tbgl_renderMatrix3d" after WHILE.
    You set 2D matrix somewhere and do not restore back to 3 dimensions.

    But even if you will do this, the viewport views will look strange, objects flat or thin.
    If there something strange in your neighbourhood, who you gonna call?

    Well, for example ... me , I have sent new TBGL to Eros. That fixes the odd look and as a bonus it adds possiblity to define own coordinate system for 2D.

    Stay tuned!


    Petr

    P.S. Added preview look with new DLL
    Attached Images Attached Images
    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

    Re: m15 module

    perhaps you need gluperspective to repair the "stretch" of the image:

    http://nehe.gamedev.net/data/lessons....asp?lesson=42
    [code=cpp]
    // Set The Viewport To The Bottom Left. It Will Take Up Half The Screen Width And Height
    glViewport (0, 0, window_width/2, window_height/2);
    glMatrixMode (GL_PROJECTION); // Select The Projection Matrix
    glLoadIdentity (); // Reset The Projection Matrix
    // Set Up Perspective Mode To Fit 1/4 The Screen (Size Of A Viewport)
    gluPerspective( 45.0, (GLfloat)(width)/(GLfloat)(height), 0.1f, 500.0 ); [/code]


    and some details about perspective and glFrustrum (redbook)
    http://cs-sdl.sourceforge.net/index....ransformations


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

    Re: m15 module

    Hi Holomind,

    you are 100% correct! Problem was that in current TBGL the width and height was took from window size, not viewport.
    Corrected version has this fixed and working, in next thinBASIC preview you will find the fix + 2 samples.


    Thanks again,
    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

  8. #18
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10

    Re: m15 module

    I'm preparing a quick thinBasic preview 1.6.0.7 in order to include new TBGL.
    Ready by this evening max (CET time)

    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

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

    Re: m15 module

    Thanks Eros,

    you were faster than I expected

    Here is version working correctly ( see attachement )
    requieres latest preview

    Thanks,
    Petr
    Attached Files Attached Files
    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

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

    Re: m15 module

    Thanks Petr. Who you gonna call-- CodeBusters.

    Nice to wake up and have a working framework to start with!!

    Thanks again.
    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

Page 2 of 7 FirstFirst 1234 ... LastLast

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
  •