Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: TBGL_LoadTexture and loading

  1. #1
    thinBasic MVPs
    Join Date
    May 2007
    Location
    UK
    Posts
    1,427
    Rep Power
    159

    TBGL_LoadTexture and loading

    Can TBGL_LoadTexture only be called after my TBGL_CreateWindowEx.

    If i put it before create window I dont get any textures.
    Home Desktop : Windows 7 - Intel Pentium (D) - 3.0 Ghz - 2GB - Geforce 6800GS
    Home Laptop : WinXP Pro SP3 - Intel Centrino Duo - 1.73 Ghz - 2 GB - Intel GMA 950
    Home Laptop : Windows 10 - Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz, 2401 Mhz, 2 Core(s), 4 Logical Processor(s) - 4 GB - Intel HD 4400
    Work Desktop : Windows 10 - Intel I7 - 4 Ghz - 8GB - Quadro Fx 370

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

    Re: TBGL_LoadTexture and loading

    Abraxas, glad you are tinkering with tbgl too. I don't know if you checked out the example files in the samples directory.

    C:\thinBasic\SampleScripts\TbGl

    Also in the tbgl help, there is a nice tbgl skeleton file to use that you can flesh out.

    [code=thinbasic]'
    ' TBGL Script Skeleton
    '
    Uses "TBGL"

    Dim hWnd As Dword

    hWnd = TBGL_CreateWindowEx("My Demo - press ESC to quit", 640, 480, 32, 0)
    TBGL_ShowWindow

    TBGL_GetAsyncKeyState(-1) ' Resets status of all keys

    While TBGL_IsWindow(hWnd)

    tbgl_ClearFrame

    tbgl_DrawFrame

    If TBGL_GetWindowKeyState( hWnd, %VK_ESCAPE) Then Exit While

    Wend

    TBGL_DestroyWindow
    [/code]

    Here is an example with textures from the sample files:
    [code=thinbasic]'
    ' TBGL 0.1.6 Demoscript : Textured and blended square
    '
    ' Petr Schreiber 2006
    '

    Uses "TBGL"
    Uses "UI"

    DIM hWnd AS dword

    MSGBOX 0, "Welcome to the TBGL module demonstration"+$LF+$LF+"It displays colorful textured rotating square, with some advanced blending", %MB_ICONINFORMATION, "TBGL demo"

    hWnd = TBGL_CreateWindow("Textured and blended square - press ESC to quit") ' Creates OpenGL window, it returns handle
    TBGL_ShowWindow ' Shows the window

    TBGL_LoadTexture App_SourcePath+"Test.bmp",1,%TBGL_TEX_MIPMAP ' Loads texture as #1, with best quality

    TBGL_UseTexture 1 ' I want to use textures
    TBGL_BindTexture 1 ' I want to use texture #1

    GetAsyncKeyState(%VK_ESCAPE) ' Resets ESC key status before checking

    While isWindow(hWnd)

    TBGL_ClearFrame ' Prepares clear frame
    TBGL_Camera 0,0,5,0,0,0 ' Setups camera to look from 0,0,5 to 0,0,0

    TBGL_Rotate GetTickCount/10,1,1,1 ' Rotates around all axis ( 1 enables axis, 0 disables )

    TBGL_BeginPoly %GL_QUADS ' Starts polygon definition based on 4 vertexes
    TBGL_TexCoord2d 0,0 ' Sets texture coordinate for this vertex
    TBGL_Vertex -1,-1,0 ' Adds vertex

    TBGL_TexCoord2d 1,0
    TBGL_Vertex 1,-1,0

    TBGL_TexCoord2d 1,1
    TBGL_Vertex 1, 1,0

    TBGL_TexCoord2d 0,1
    TBGL_Vertex -1, 1,0

    TBGL_EndPoly ' Ends polygon definition

    TBGL_UseBlend 1 ' Use blending

    TBGL_Translate 0,0,1 ' This polygon will be moved by 1 in Z axis

    TBGL_BeginPoly %GL_QUADS ' Starts polygon definition based on 4polys
    TBGL_Color 255,0,0 ' Sets RGB color
    TBGL_TexCoord2d 0,0
    TBGL_Vertex -1,-1,0 ' Adds vertex

    TBGL_Color 0,255,0
    TBGL_TexCoord2d 1,0
    TBGL_Vertex 1,-1,0

    TBGL_Color 0,0,255
    TBGL_TexCoord2d 1,1
    TBGL_Vertex 1, 1,0

    TBGL_Color 255,255,255
    TBGL_TexCoord2d 0,1
    TBGL_Vertex -1, 1,0

    TBGL_EndPoly ' Ends polygon definition

    TBGL_UseBlend 0 ' Don't use blending

    TBGL_DrawFrame ' Swaps the buffers - displays rendered image

    if GetAsyncKeyState(%VK_ESCAPE) THEN exit while

    wend

    TBGL_DestroyWindow ' Closes OpenGL window

    MSGBOX 0, "Show is over", %MB_ICONINFORMATION or %MB_TOPMOST, "TBGL demo"[/code]

    You can only at the moment use bmp and tga files and they need to be in the power of 2's: 32,64,128,256,512,1024 etc.
    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. #3
    thinBasic MVPs
    Join Date
    May 2007
    Location
    UK
    Posts
    1,427
    Rep Power
    159

    Re: TBGL_LoadTexture and loading

    Thanks for the info. but can it only be called after creating the window because it makes my program pause while it loads 10 textures.
    Home Desktop : Windows 7 - Intel Pentium (D) - 3.0 Ghz - 2GB - Geforce 6800GS
    Home Laptop : WinXP Pro SP3 - Intel Centrino Duo - 1.73 Ghz - 2 GB - Intel GMA 950
    Home Laptop : Windows 10 - Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz, 2401 Mhz, 2 Core(s), 4 Logical Processor(s) - 4 GB - Intel HD 4400
    Work Desktop : Windows 10 - Intel I7 - 4 Ghz - 8GB - Quadro Fx 370

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

    Re: TBGL_LoadTexture and loading

    I am not sure on the order, Petr I am sure will have the answer for you when he logs on.
    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. #5

    Re: TBGL_LoadTexture and loading

    Quote Originally Posted by Abraxas
    Thanks for the info. but can it only be called after creating the window because it makes my program pause while it loads 10 textures.
    You gave the answer youself, as it doesn't work if you try to load textures before you create the window.
    How about a little loading text on the screen while you load the textures. You could even animate this (change of color, or use graphics) between each texture you load, so the user doesn't look at a blank screen and think that your game might have crashed.

    Michael

  6. #6
    thinBasic MVPs
    Join Date
    May 2007
    Location
    UK
    Posts
    1,427
    Rep Power
    159

    Re: TBGL_LoadTexture and loading

    I dont see why you would need the handle for an gl window to load a file, decode the BMP structure and assign it to a texture but I must be missing something.
    Home Desktop : Windows 7 - Intel Pentium (D) - 3.0 Ghz - 2GB - Geforce 6800GS
    Home Laptop : WinXP Pro SP3 - Intel Centrino Duo - 1.73 Ghz - 2 GB - Intel GMA 950
    Home Laptop : Windows 10 - Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz, 2401 Mhz, 2 Core(s), 4 Logical Processor(s) - 4 GB - Intel HD 4400
    Work Desktop : Windows 10 - Intel I7 - 4 Ghz - 8GB - Quadro Fx 370

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

    Re: TBGL_LoadTexture and loading

    Abraxas,

    it should be by design, I mean Petr should have decided to do that way.
    I'm with you on this but you have to wait Petr to reply. I'm pretty sure he will have a solution or a reason why.

    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

  8. #8
    thinBasic MVPs
    Join Date
    May 2007
    Location
    UK
    Posts
    1,427
    Rep Power
    159

    Re: TBGL_LoadTexture and loading

    Its not a problem i just thought i was doing something wrong.
    Home Desktop : Windows 7 - Intel Pentium (D) - 3.0 Ghz - 2GB - Geforce 6800GS
    Home Laptop : WinXP Pro SP3 - Intel Centrino Duo - 1.73 Ghz - 2 GB - Intel GMA 950
    Home Laptop : Windows 10 - Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz, 2401 Mhz, 2 Core(s), 4 Logical Processor(s) - 4 GB - Intel HD 4400
    Work Desktop : Windows 10 - Intel I7 - 4 Ghz - 8GB - Quadro Fx 370

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

    Re: TBGL_LoadTexture and loading

    I have a Petr example loading textures and showing their names on screen just not letting user think something is going wrong with a black screen.
    As Mike suggested, some info on screen can even be nice to see.

    Maybe you already have this example. If yes, sorry.

    Ciao
    Eros
    Attached Files Attached Files
    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

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

    Re: TBGL_LoadTexture and loading

    Hi Abraxas,

    Can TBGL_LoadTexture only be called after my TBGL_CreateWindowEx.

    If i put it before create window I dont get any textures.
    This is documented behaviour in help file - window creation must go first.

    I am sorry you find this uncomfortable, but it was designed this way.

    To be able to load texture, OpenGL window must be created already.
    To create rendering context I need to know handle of display device, which can't be obtained for no window. Then setup pixelformat and pass device context to OpenGL driver.

    Theoretically it would be possible to load raw data and as soon as window exists bind it to GL, but this seems quite weird to me. But I am weird too , if it would be better for you I could write something like tbgl_CreateTexture, which would have as a parameter not file name, but already preprocessed RGBA buffer?

    In case loading of textures before window creation would be possible, what would user see ? Hourglass cursor maybe ? And I can't guarantee passing data to GL is instant too, some time can take creating of mipmaps and so on.
    It is easier to render any loading screen ( progressbar and/or game hints ) while loading program resources, this way user/player can see what happens.

    I will try to optimize texture loading procedures to take less time :-[, what size did you used ?


    Thanks,
    Petr

    P.S. I'm sorry to reply so late, but I was out of house all the day
    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 1 of 2 12 LastLast

Similar Threads

  1. B3D loading functions
    By Michael Hartlef in forum thinBasic vaporware
    Replies: 10
    Last Post: 10-02-2008, 21:18

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
  •