Page 1 of 3 123 LastLast
Results 1 to 10 of 23

Thread: A few Texture-Questions

  1. #1
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,530
    Rep Power
    171

    A few Texture-Questions

    I want to create some own UI for my next program using just TBGL because that weird callback-stuff drives me nuts and with TBGL I can see at least some progress if I program something and it gives me the feeling to keep everything under my control.

    So I thought of using Sprites, which might display for example a file-list-box with lots of little pictures (folders etc.) and quite some text. Now I wonder how to draw text and smaller bitmaps/tga's onto a texture in memory so I have to redraw just the sprites texture if necessary and display the whole file-list-box as a sprite on screen. It would shorten the time that it needs to draw all buttons, lists, textboxes or whatever if I had them stored on a texture in memory and redraw them just if changed instead of drawing all single elements each and every frame.

    I tried already the TBGL_OffscreenRendering-Example but it does not run (shows a small, black window for maybe 100 milliseconds and immediately stops again - so it doesn't answer my questions because I don't see a result).

    -Is there a possibility to draw (plain 2d) images and text onto a texture in memory using TBGL?

    -Can I add texture-layers? So a material can have maybe up to 8 translucent different texture-layers?

    -Can I scroll textures? Or do I have to change UV for all vertices to get texture-scrolling-effect?

    Btw. TBGL_Help says for

    TBGL_SpriteDrawAt "Draw a sprite at its internal stored position" , guess that's a mistake?
    I think there are missing some Forum-sections as beta-testing and support

  2. #2
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,530
    Rep Power
    171
    sorry John,
    I'm just a basic-user and I have no idea about c++ and can't help translating or porting something and i don't know how to deal with all that stuff - thats what i need an "include#" or "uses" for, so I don't have to worry about all that complicated stuff.
    I intend to create some 3d-app using a basic language and thinBasic appears currently the best what I can get in the whole wide world to get the stuff, that i like to create, done. I tried blitz, dark, pure, small etc. - seems all overloaded or crippled crap to me, and even if it appears that i am the only user that asks questions here - maybe other users don't dare to ask, have no questions or didn't discover thinBasic yet - I want to program something using thinBasic now.
    And I was just asking a question how to draw onto a texture in memory since the combination of TBGL_GetWindowBMP, TBGL_MakeTexture and TBGL_SpriteSetTexture is a little cumbersome and might get unwanted stuff - like a self-made mousepointer-sprite or another "always-on-top"- window - displayed on my sprite then.

    I tried already using invisible canvas and this way:
    pixelBuffer = Canvas_BitmapGet(width, height)
    TBGL_MakeTexture pixelBuffer, %TBGL_FILE_BMP, width, height, myBufferID, %TBGL_TEX_LINEAR
    
    but that results in a module-specific error (unsupported Format-Version)
    Last edited by ReneMiner; 14-11-2012 at 14:38.
    I think there are missing some Forum-sections as beta-testing and support

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

    you were on right track with FBO - but it is advanced feature.
    What you could use is safe render to texture approach, which is intuitively offered by TBGL_RenderToTexture command.

    So you basically render what you need (for example nice image with text below) and capture it to texture without anything from this process being necessarily visible on the screen.


    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. #4
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,530
    Rep Power
    171
    some other question, but it's about textures too:

    help says there would be sample for freeImage-module/library but there isn't. So I can not find out if it's possible to use *.png, *.tiff or even *.jpeg as texture this way
    - by mentioning FreeImage, I think they got a new version of it, just downloaded one from Oct 2012 at:
    http://freeimage.sourceforge.net/download.html

    Now I try using TImage-Module but same issue as described above where I tried to use invisible canvas as a buffer.
    Is there a way to load some compressed images and convert them internally to TBGL_usable format somehow?
    - at least *.tga or *.png would be great (*.jpeg is not really usable as a texture)
    I think there are missing some Forum-sections as beta-testing and support

  5. #5
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    FreeImage works with TBGL without bigger issues, see 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. #6
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,530
    Rep Power
    171
    thanks once more

    works fine with compressed .tga and also .jpg.

    .png and .tiff load, but were not drawn correctly (I took care of POT)
    I think there are missing some Forum-sections as beta-testing and support

  7. #7
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    You could try this experimental unit. Should work for PNGs. How to use?
    #include "fileformat_IMAGE.tBasicU"
    ...
    
    Long lWidth, lHeight
    String sTexture = IMAGE_GetRGBA("C:\myImage.bmp", lWidth, lHeight)
    
    TBGL_MakeTexture sTexture, %TBGL_DATA_BGRA, lWidth, lHeight, MyTextureIndex, %TBGL_TEX_LINEAR
    
    I think it returned the image upside down, but that can be easily arranged by texture coordinates.


    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

  8. #8
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,530
    Rep Power
    171
    I already built both into my code. Can load almost any texture-files now

    but I don't like the upside-down aspect - no good idea to flip UV - user might exchange texture later and meshes shall be loaded from other tb-apps also. Can't I just flip the strings-value - is it four bytes per pixel, multiplied by width till the end? Or are there some stopBits?

    so I tried like this:
    'string strTextureData  is actual value in your Function IMAGE_GetRGBA()
    ' I added this:
    
    Local i as Long
    Local sLine(imageHeight) as String
    Local lLineLen as Long = 4 * imageWidth 
    
    For i = 1 To imageHeight
        sLine(i) = RIGHT$(strTextureData, lLineLen)
        strTextureData = LEFT$(strTextureData, Len(strTexturedata) - lLineLen)
    Next i
    For i = 1 To imageHeight
        strTextureData = strTextureData + sLine(i)  
    Next i
    
    Function = strTextureData
    
    but image is still flipped upside down! How comes?

    Btw. On Articles-Page of this forum the most recent threads do not appear lots of my questions stay unanswered
    Last edited by ReneMiner; 16-11-2012 at 17:31.
    I think there are missing some Forum-sections as beta-testing and support

  9. #9
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    The solution would be to cut the string to rows of pixels (blocks of length width*4), reverse their order, and join again to mega string.


    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

  10. #10
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,530
    Rep Power
    171
    Quote Originally Posted by Petr Schreiber View Post
    The solution would be to cut the string to rows of pixels (blocks of length width*4), reverse their order, and join again to mega string.


    Petr
    ain't that what I did?
    or do you mean I have to reorder the sLine()-Strings from left to right? Are them bitmaps stored asides?
    I think there are missing some Forum-sections as beta-testing and support

Page 1 of 3 123 LastLast

Similar Threads

  1. TBTIL Texture Image Library
    By D.J.Peters in forum TBTIL Texture Image Library
    Replies: 19
    Last Post: 08-03-2010, 11:17
  2. How to animate a water texture?
    By Michael Hartlef in forum TBGL module by Petr Schreiber
    Replies: 8
    Last Post: 24-10-2008, 19:48
  3. Why is my texture not showing
    By Michael Hartlef in forum TBGL General
    Replies: 11
    Last Post: 02-10-2008, 05:29

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
  •