Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 23

Thread: A few Texture-Questions

  1. #11
    thinBasic MVPs
    Join Date
    May 2007
    Location
    UK
    Posts
    1,427
    Rep Power
    159
    Declare Function GdipImageRotateFlip Lib "GDIPLUS.DLL" Alias "GdipImageRotateFlip" ( _
       ByVal pImage As DWord _                               ' __in GpImage *image
     , ByVal rfType As Long _                               ' __in RotateFlipType rfType
     ) As Long                                              ' GpStatus
    
    
    ' enum RotateFlipType
    
    
    %RotateNoneFlipNone = 0
    %Rotate90FlipNone   = 1
    %Rotate180FlipNone  = 2
    %Rotate270FlipNone  = 3
    
    
    %RotateNoneFlipX    = 4
    %Rotate90FlipX      = 5
    %Rotate180FlipX     = 6
    %Rotate270FlipX     = 7
    
    
    %RotateNoneFlipY    = %Rotate180FlipX
    %Rotate90FlipY      = %Rotate270FlipX
    %Rotate180FlipY     = %RotateNoneFlipX
    %Rotate270FlipY     = %Rotate90FlipX
    
    
    %RotateNoneFlipXY   = %Rotate180FlipNone
    %Rotate90FlipXY     = %Rotate270FlipNone
    %Rotate180FlipXY    = %RotateNoneFlipNone
    %Rotate270FlipXY    = %Rotate90FlipNone
    
    
      sFile = Ucode$(sFile)
      hStatus = GdipLoadImageFromFile(StrPtr(sFile), pImage)
      If hStatus = %S_OK Then
      hStatus = GdipImageRotateFlip(pImage, %Rotate180FlipY)
      If hStatus = %S_OK Then
    
    Hello Rene,

    Try the above I don't the code to try it but it should do what you want, let me if it does the job.

    Mike C.
    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. #12
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,527
    Rep Power
    170
    thanks Mike, but there are missing a few words, lines... endifs... and I have the string *.png-Texture already converted to TBGL-usable format in memory. It's just the re-ordering like described above needs a little long - so it's no fun browsing some directory since the textures are displayed instantly when mouse points at it in my "explorer".
    But I'm already happy that it does compressed *.tga so there's at least one alpha-channel-format that I can load.
    At the moment (see "own class"-thread) there's some other thing that keeps brain 1.0 busy - I need some dynamic structure to store and edit meshes i.e. arranged by Entities - I have no idea how to arrange memory and i fear that data gets lost, messed up or leaks if i use pointers and poke them somewhere to memory
    btw.
    I think I read somewhere that I can use Win-API-functions in tB without declaring them - is that wrong or right?
    Last edited by ReneMiner; 18-11-2012 at 12:21.
    I think there are missing some Forum-sections as beta-testing and support

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

    here is new version which loads the PNG file in correct orientation.


    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

  4. #14
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,527
    Rep Power
    170
    You're the best too, anyway - how about building this into TBGL? Would be nice just to tell TBGL_LoadTexture()...
    I think there are missing some Forum-sections as beta-testing and support

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

    it will be done, but only once ThinBASIC drops support for Win95/98/ME, because GDI+ is only available on XP and newer Windows...


    Petr
    Last edited by Petr Schreiber; 18-11-2012 at 21:06.
    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
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,527
    Rep Power
    170
    Maybe it's easier if just the TBGL-Module drops below XP support.
    Somebody has to start going a step forward, the future is about to come

    Who uses ME? People that have a small notebook with 192 MB Ram, which can't handle XP, and those things have 2MB-Graphics-Chip onBoard- that's not enough to even open TBGL-Window! All other win95/98/ME-Users are offices, factories and bureaus. They won't need TBGL at work and they still have Version 1.9.0.1. what they can use
    Last edited by ReneMiner; 18-11-2012 at 21:41.
    I think there are missing some Forum-sections as beta-testing and support

  7. #17
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,527
    Rep Power
    170

    TBGL_MakeTexture

    Can't I just create an empty texture somehow?
    Currently I load black rectangular bitmaps in desired size and draw on them, but I would like to create textures on the fly since that seems just a waste of HD-space because I use different sizes and have now maybe 20 empty templates in some subfolder and it's growing...

    How can I fill a string correct to match the requirements since I want to use an invisible color/alpha channel?

    I tried already like this

    sPixel = chr$(0)+chr$(0)+chr$(0) + chr$(255)
    sString = Repeat$(sPixel, Width * Height)

    put 255 also in front, used 0... %TBGL_DATA_RGBA, %TBGL_DATA_BGRA but somehow it won't get translucent/transparent
    Last edited by ReneMiner; 25-11-2012 at 13:23.
    I think there are missing some Forum-sections as beta-testing and support

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

    I think your problem is that you pass wrong parameters to repeat$ function, first goes the number of repetitions, please see the manual.
    Textures cannot be automagically transparent, you can make them appear so by enabling alpha blending and/or alpha testing first.

    Here is basic example, where you can test the transparency nicely (just change the transparency variable to anything between 0 (invisible) to 255(fully visible):
    '
    ' Creating texture from string
    ' Petr Schreiber, 2012
    '
    
    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       
      
      Long   nWidth = 256
      Long   nHeight= 256                                         
      Long   transparency = 128 ' -- 0 = fully transparent, 255 = fully solid
      String sTextureData = Repeat$(nWidth*nHeight, Chr$(0, 0, 0, 255))
      
      TBGL_MakeTexture sTextureData, %TBGL_DATA_RGBA, nWidth, nHeight, 1, %TBGL_TEX_LINEAR
    
      TBGL_BackColor 255, 255, 255, 255  
      ' -- Resets status of all keys 
      TBGL_ResetKeyState()
    
      ' -- Main loop
      While TBGL_IsWindow(hWnd) 
        FrameRate = TBGL_GetFrameRate
    
        TBGL_ClearFrame 
          TBGL_Camera 0, 0, 2, 0, 0, 0
          
          ' -- Use texturing and blending on textured quad
          TBGL_PushState %TBGL_TEXTURING Or %TBGL_BLEND
            TBGL_PushTexture 1
            TBGL_PushBlendFunc %GL_SRC_ALPHA, %GL_ONE_MINUS_SRC_ALPHA
              
              TBGL_BeginPoly %GL_QUADS
                TBGL_TexCoord2D 0, 0
                TBGL_Vertex -0.5, -0.5
                
                TBGL_TexCoord2D 1, 0  
                TBGL_Vertex  0.5, -0.5
                
                TBGL_TexCoord2D 1, 1
                TBGL_Vertex  0.5,  0.5
                
                TBGL_TexCoord2D 0, 1
                TBGL_Vertex -0.5,  0.5
              TBGL_EndPoly
          
            TBGL_PopBlendFunc 
            TBGL_PopTexture
          TBGL_PopState
            
        TBGL_DrawFrame 
    
        ' -- ESCAPE key to exit application
        If TBGL_GetWindowKeyState(hWnd, %VK_ESCAPE) Then Exit While 
    
      Wend 
    
      TBGL_DestroyWindow
    End Function
    

    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

  9. #19
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,527
    Rep Power
    170
    grr... yeah... my mistake wasn't Repeat$ (i did it right in script) but the size! since it's zero-based texture I messed something up a little bit - used 255 and 127 as width/height

    But- is there a way to retrieve ID of an empty Texture-Slot? Like "TBGL_EntityGetFreeID"


    Would be real helpful since my program consists of different files and it's just somehow cumbersome if I use constants for objects like a menu or list and that lists or menus ID needs a typed array to store properties etc. So I have one constant for the array and a different one for the texture... I would like to store those ID's to the items subset like I can do with entities already.

    With sprites won't work either see here http://www.thinbasic.com/community/project.php
    Last edited by ReneMiner; 25-11-2012 at 16:42.
    I think there are missing some Forum-sections as beta-testing and support

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

    as I explained in other topic, although it might seem trivial, adding native free texture id generator would mean deep redesign of TBGL for which I would need longer time block to implement and test.

    In the meantime you could use approach I use:
    Function Texture_GetNewID() As Long
      Static id As Long 
      
      id += 1   
      
      If id > 1024 Then
        MsgBox 0, "You reached the TBGL limit for texture index"
        Return 0
        
      Else  
        Return id
        
      End If  
      
    End Function
    

    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 3 FirstFirst 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
  •