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

Thread: Logic trouble (help asked)

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

    thanks a lot for providing me with valuable feedback, this is exactly the kind of help which helps to push things forward

    The non-reset of pixelOffset to zero is an ommision from my side. Do you have a gitHub account by the way? So I could assign pull requests to you?

    Going to fix that offset non-reset issue now


    Petr
    Last edited by Petr Schreiber; 12-01-2019 at 16:16.
    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
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,146
    Rep Power
    735
    DirectuX, I know the reason for strange artifacts in your example.

    You create window of some size, but then you create matrix 1 bigger in each dimension.

    Imagine you have window 1280x720. You should create TBGL_RenderMatrix2D(1, 1, 1280, 720), not TBGL_RenderMatrix2D(0, 0, 1280, 720) for it.

    Why? Because the range is inclusive, 1 to 1280 on X, 1 to 720 on Y.

    In 1280x720, there are really 1280 pixels * 720 pixels, not 1281 * 721.

    Check this altered example:
    #region "Uses"
    
    
    uses "tbgl", "file", "ui"
    
    
    #endRegion
    
    
    type mousecur
          position as POINTAPI
          direction as Integer
    end type
    
    
    type mycolors
          red as byte
          green as Byte
          blue as Byte
    end type
    
    
    dword htbgl 'handler for draw window
    
    
    integer max_x = 1280' window dimensions
    integer max_y = 720
    
    
    dim mymouse as mousecur 'Cursor state
    
    
    dim perfect as Boolean 'toggle for pixel perfect
    
    
    dim black, white, gray, green, red, orange, blue as mycolors
    
    
    white.red=255
    white.green=255
    white.blue=255
    
    
    gray.red=50
    gray.green=50
    gray.blue=50
    
    
    green.green=250
    
    
    red.red=250
    
    
    blue.green=125
    blue.blue=250
    
    
    orange.red=250
    orange.green=125
    
    
    function tbMain()
    
    
      call myini
      call draw_loop
    
    
      tbgl_destroyWindow
    
    
    end function
    
    
    function myini()
    
    
    'Display settings
      htbgl = TBGL_CreateWindowEx ("[ ESC ] to quit - [ T ] toggle PERFECT PIXEL_2D ** OFF **", max_x, max_y, 32, %TBGL_WS_WINDOWED | %TBGL_WS_DONTSIZE)
      tbgl_ShowWindow
      
      TBGL_ShowCursor false
      TBGL_UseVSync true
      
      TBGL_RenderMatrix2D(1, 1, max_x, max_y)
      
      TBGL_Color_set (white)
      TBGL_BackColor_set (black)
    
    
      tbgl_ResetKeyState()
    
    
    'Font settings
      TBGL_UseTexturing (False)
    
    
    end Function
    
    
    Function draw_loop()
    ' -- Main loop
      While tbgl_IsWindow(htbgl)
    
    
        If tbgl_GetWindowKeyState(htbgl, %VK_ESCAPE) Then Exit While
        
        If TBGL_GetWindowKeyOnce(htbgl, %VK_T) then
          perfect = not perfect
          if perfect then
            TBGL_RenderMatrix2D(1,1,max_x,max_y)
            TBGL_SetWindowTitle( htbgl, "[ ESC ] to quit - [ T ] toggle PERFECT PIXEL_2D ** OFF **" )
          Else
            TBGL_RenderMatrix2D(1,1,max_x,max_y, %TBGL_PIXEL_PERFECT_2D)
            TBGL_SetWindowTitle( htbgl, "[ ESC ] to quit - [ T ] toggle PERFECT PIXEL_2D ** ON  **" )
          endif
        endif
        
        tbgl_clearFrame
    
    
        call draw_mouse
        call draw_lines
        call draw_mouse_cross
    
    
        tbgl_drawFrame
    
    
      Wend
    
    
    end Function
    
    
    function draw_mouse()
    
    
      dim position as Integer
    
    
      mymouse.position.x=TBGL_MouseGetPosX
      mymouse.position.y=max_y-TBGL_MouseGetPosy
    
    
    end function
    
    
    function draw_lines()
    
    
      integer ii, jj
    
    
      for ii = 1 to max_x Step 10
        for jj = 1 to max_y step 10
    
    
          tbgl_line(ii,jj,ii+7,jj+7) ' regular dashes
    
    
        next ii
      next jj
    
    
    end function
    
    
    function draw_mouse_cross()
    
    
      TBGL_PushColor_set(green)
      Tbgl_line(mymouse.position.x,1,mymouse.position.x,max_y)
      Tbgl_line(1,mymouse.position.y,max_x,mymouse.position.y)
      TBGL_PopColor
    
    
    end function
    
    
    function TBGL_Color_set (mycolor as mycolors)
      TBGL_Color(mycolor.red,mycolor.green,mycolor.blue)
    end function
    
    
    function TBGL_BackColor_set (mycolor as mycolors)
      TBGL_BackColor(mycolor.red,mycolor.green,mycolor.blue)
    end function
    
    
    function TBGL_PushColor_set (mycolor as mycolors)
      TBGL_PushColor(mycolor.red,mycolor.green,mycolor.blue)
    end function
    
    In the meantime, this is a fix for your observation:
    https://github.com/ThinBASIC/thinBas...L/pull/4/files

    The fix will be present in next thinBasic release, thank you!


    Petr
    Last edited by Petr Schreiber; 12-01-2019 at 16:17.
    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. Trouble in (my) Paradise
    By LCSims in forum Core module
    Replies: 24
    Last Post: 04-07-2013, 21:58
  2. TBGL FAQ ( Frequently Asked Questions )
    By Petr Schreiber in forum TBGL General
    Replies: 4
    Last Post: 07-05-2013, 15:35
  3. Logic wins??
    By danbaron in forum Science
    Replies: 0
    Last Post: 15-11-2010, 06:52
  4. Logic wins??
    By danbaron in forum Science
    Replies: 0
    Last Post: 15-11-2010, 06:51

Members who have read this thread: 0

There are no members to list at the moment.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •