José Roca Forum
Web Site
News: Version 4.0.14 of the TypeLib Browser released
 
*
Welcome, Guest. Please login or register. September 09, 2010, 02:20:32 PM


Login with username, password and session length


PowerBASIC is a trademark of PowerBASIC, Inc.
This is not an official PowerBASIC site and we are not affiliated with PowerBASIC, Inc.
DISCLAIMER: The software and accompanying documentation are provided "as is" and without warranties as to performance or merchantability or any other warranties whether expressed or implied. Because of the various hardware environments into which the software may be used, no warranty of fitness for a particular purpose is offered. The user must assume the entire risk of using the software. In no case shall any of the contributors to this project be liable for any incidental, special or consequential damages or loss, including, without limitation, lost profits or the inability to use equipment or access data. This is true even if we are advised of the possibility of such damages. We also don't have any obligation of fix eventual bugs or to add new features.
Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 »   Go Down
  Print  
Author Topic: BassBox  (Read 125657 times)
0 Members and 1 Guest are viewing this topic.
Charles Pegge
Global Moderator
Hero Member
*****

Karma: 19
Offline Offline

Posts: 648



WWW
« Reply #150 on: November 05, 2007, 05:06:32 PM »

Very interesting:
I find that %WM_KEYDOWN is correctly received in the WINMAIN message loop but does not get passed to WNDPROC.

One reason is because it is treated as a dialog message and skips.
But to remove this obstacle is not enough to reach GLWindowProc. So I think its getting lost somewhere in the Bassbox/zskin architecture.

PS: the %WM_KEYDOWN message does noy reach WNDPROC either.

Code:
          WHILE GetMessage(Msg, %NULL, 0, 0)  ' SK_MILLISECOND
             'IF IsDialogMessage(hMain, Msg) = %FALSE THEN
                IsDialogMessage(hMain, Msg)
                if Msg.message=%WM_KEYDOWN then msgbox "keydown"
                CALL TranslateMessage(Msg)
                CALL DispatchMessage(Msg)
             'END IF
          WEND
« Last Edit: November 05, 2007, 05:22:40 PM by Charles Pegge » Logged
Patrice Terrier
Global Moderator
Hero Member
*****

Karma: 36
Offline Offline

Gender: Male
Posts: 1353


WWW
« Reply #151 on: November 05, 2007, 05:24:15 PM »

-- Charles

I shall take care of this into the next build.

First I will put the focus myself onto the OpenGL control, each time the user select a new plugin, and I shall also restore the focus in case of WM_LBUTTONDOWN if it is not set already.

« Last Edit: November 05, 2007, 05:26:33 PM by Patrice Terrier » Logged

Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com
Patrice Terrier
Global Moderator
Hero Member
*****

Karma: 36
Offline Offline

Gender: Male
Posts: 1353


WWW
« Reply #152 on: November 05, 2007, 06:29:49 PM »

All keyboard messages are now redirected to the Plugin control when it has the focus.

Code:
          hCtrl = zGetMainItem(%ID_OpenGL)
          CALL SetTimer(hMain, %OPENGL_TIMER, 0, %NULL)
          WHILE GetMessage(Msg, %NULL, 0, 0)  ' SK_MILLISECOND
             IF GetFocus() = hCtrl AND (Msg.message > 255 AND Msg.message < 266) THEN
                CALL TranslateMessage(Msg)
                CALL DispatchMessage(Msg)
             ELSE
                IF IsDialogMessage(hMain, Msg) = %FALSE THEN
                   CALL TranslateMessage(Msg)
                  CALL DispatchMessage(Msg)
                END IF
             END IF
          WEND
          CALL KillTimer(hMain, %OPENGL_TIMER)


See below attached BassPatch38.zip

...
« Last Edit: November 06, 2007, 07:05:13 PM by Patrice Terrier » Logged

Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com
Petr Schreiber
Sr. Member
****

Karma: 9
Offline Offline

Posts: 420


« Reply #153 on: November 05, 2007, 06:46:12 PM »

Hi guys,

few tips on texture quality - mipmaps look good, but with LINEAR in both parameters, like this:
Quote
  glTexParameteri %GL_TEXTURE_2D, %GL_TEXTURE_MAG_FILTER, %GL_LINEAR
  glTexParameteri %GL_TEXTURE_2D, %GL_TEXTURE_MIN_FILTER, %GL_LINEAR_MIPMAP_LINEAR
  gluBuild2DMipmaps %GL_TEXTURE_2D, dataType, xSize, ySize, %GL_RGBA, %GL_UNSIGNED_BYTE, PixelArray(0)

This kind of mipmapping is often ( I think a bit oddly ) called "trilinear filtering". It is the best you can get from old graphic cards.
And that means there must be some better way ? Of course - anisotropic filtering.

Mip mapping + linear filter is good, but kind of blur textures at sharp angles too much, thats because as a base it takes textures which are filtered linearly.
Anisotropic filtering keeps all relatively sharp, to eliminate "pixelisation" we will combine it with classic mipmapping to get the best filtering currently available.

So how to put that marvel on Cheesy ?
Via extension again.

Use this in your initialisation:
Quote
GLOBAL texture_AnisotropyAllowed AS BYTE
GLOBAL texture_AnisotropyMax AS SINGLE

LOCAL OpenGLInfoPTR AS DWORD
LOCAL OpenGLExtensions AS STRING

' -- Get list of available extensions
OpenGLInfoPTR = glGetString(%GL_EXTENSIONS)
OpenGLExtensions = UCASE$(PEEK$(ASCIIZ, OpenGLInfoPTR, 262144))

' -- Test whether we can use it
IF INSTR( OpenGLExtensions, "GL_EXT_TEXTURE_FILTER_ANISOTROPIC " ) THEN
  texture_AnisotropyAllowed = 1
  ' -- If yes, lets get maximum level of anisotrpy available
  glGetFloatv(%GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, texture_AnisotropyMax )
ELSE
  texture_AnisotropyAllowed = 0
  texture_AnisotropyMax     = 0
END IF

What is anisotropy level ? It is number determining number of samples involved in calculation - higher number, higher quality but more power demanding.

So when loading texture I do something like following for my TBGL thinBASIC module for graphics: if anisotropy is supported and I want it, go for it.
If not then do classic mipmapping, as it is best old hardware can do. Also good to check AnisoFactor does not exceed maximum level of anisotropy hardware offer.

Code for anisotropy is here:
Quote
glTexParameteri %GL_TEXTURE_2D, %GL_TEXTURE_MAG_FILTER, %GL_LINEAR
glTexParameteri %GL_TEXTURE_2D, %GL_TEXTURE_MIN_FILTER, %GL_LINEAR_MIPMAP_LINEAR
IF texture_AnisotropyAllowed THEN glTexParameterf(%GL_TEXTURE_2D, %GL_TEXTURE_MAX_ANISOTROPY_EXT, AnisoLevel)
gluBuild2DMipmaps %GL_TEXTURE_2D, dataType, xSize, ySize, %GL_RGBA, %GL_UNSIGNED_BYTE, PixelArray(0)
Where AnisoLevel could be 1, 4, 8, 16 ... up to texture_AnisotropyAllowed .

As you can see, it is quite a mutant composed from linear, aniso and mipmap techniques, but it really looks good Smiley

I attached picture so you can see the diffffference ( as says G-Man from half life 2 Smiley ).
On static picture mipmapping looks like a terrible one, but first two filters cause quite disturbing noise in the picture when animated.


Bye,
Petr
« Last Edit: November 05, 2007, 06:50:34 PM by Petr Schreiber » Logged

AMD Sempron 3400+ | 1GB RAM @ 533MHz | GeForce 6200 / GeForce 9500GT | 32bit Windows XP SP3

psch.thinbasic.com
Patrice Terrier
Global Moderator
Hero Member
*****

Karma: 36
Offline Offline

Gender: Male
Posts: 1353


WWW
« Reply #154 on: November 05, 2007, 07:34:29 PM »

Petr,

What about a working example?

 Wink

...
Logged

Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com
Charles Pegge
Global Moderator
Hero Member
*****

Karma: 19
Offline Offline

Posts: 648



WWW
« Reply #155 on: November 05, 2007, 09:52:07 PM »

Just tried your new patch Patrice. Thanks. But keyboard messages of any sort are still not getting through. I think it may be a deeper seated problem than focus. When I press any key, it goes 'plunk'.

Code:
    CASE %BBP_KEYBOARD

         '// Handle all Windows keyboard messages there
         Msg = BBP.WinMsg: wParam = BBP.wParam: lParam = BBP.lParam
         SELECT CASE LONG Msg
         MSGBOX HEX$(wParam)+" any"
         CASE %WM_KEYDOWN
          IF (wParam AND 255)=&h20 THEN ' '
           Cx=15: Cy=0: Cz=0 ' reset object orientation
          END IF
         CASE %WM_KEYUP
          MSGBOX HEX$(wParam)+" up"
         END SELECT
 

PS: But this part works correctly

Code:
          WHILE GetMessage(Msg, %NULL, 0, 0)  ' SK_MILLISECOND
             IF GetFocus() = hCtrl AND (Msg.message > 255 AND Msg.message < 266) THEN

                IF msg.message=%wm_keydown THEN MSGBOX "keydown main"

                CALL TranslateMessage(Msg)
                CALL DispatchMessage(Msg)
             ELSE
                IF IsDialogMessage(hMain, Msg) = %FALSE THEN
                   CALL TranslateMessage(Msg)
                  CALL DispatchMessage(Msg)
                END IF
             END IF
          WEND



Thanks for the info on MIP mapping and Anisotropics, Petr. I tried your MIP linear settings but Its interactions with light and color are different and I can no longer blend color with texture for some reason. I will have to do some more experimenting and study the Opengl manuals.
« Last Edit: November 05, 2007, 10:10:36 PM by Charles Pegge » Logged
Patrice Terrier
Global Moderator
Hero Member
*****

Karma: 36
Offline Offline

Gender: Male
Posts: 1353


WWW
« Reply #156 on: November 05, 2007, 11:18:24 PM »

--Charles

Then the solution is quite simple, we will handle ourselves the message dispatching, like this:

- First, we REM OUT this in GLWindowProc
Code:
'    CASE %WM_KEYDOWN TO %WM_UNICHAR
'         BBP.Msg    = %BBP_KEYBOARD
'         BBP.WinMsg = Msg
'         BBP.wParam = wParam
'         BBP.lParam = lParam
'         CALL BBP_Plugin(BBP)   

- Second, add this to the main message pump
Code:
          LOCAL BBP AS BBPLUGIN
          hCtrl = zGetMainItem(%ID_OpenGL)
          CALL SetTimer(hMain, %OPENGL_TIMER, 0, %NULL)
          WHILE GetMessage(Msg, %NULL, 0, 0)  ' SK_MILLISECOND
             IF GetFocus() = hCtrl AND (Msg.message > 255 AND Msg.message < 266) THEN
               
                BBP.Msg    = %BBP_KEYBOARD ' <---
                BBP.WinMsg = Msg.message   ' <---
                BBP.wParam = Msg.wParam    ' <---
                BBP.lParam = Msg.lParam    ' <---
                CALL BBP_Plugin(BBP)       ' <---

                CALL TranslateMessage(Msg)
                CALL DispatchMessage(Msg)
             ELSE
                IF IsDialogMessage(hMain, Msg) = %FALSE THEN
                   CALL TranslateMessage(Msg)
                  CALL DispatchMessage(Msg)
                END IF
             END IF
          WEND
          CALL KillTimer(hMain, %OPENGL_TIMER)

...
Logged

Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com
Charles Pegge
Global Moderator
Hero Member
*****

Karma: 19
Offline Offline

Posts: 648



WWW
« Reply #157 on: November 06, 2007, 08:39:58 AM »

Patrice, This works when hctrl is ignored.

Using the keyboard generates %WM_KEYDOWN (&h100)
but after using the mouse, the keyboard message then becomes %WM_SYSKEYDOWN (&h104).

The next key pressed after this will revert to %WM_KEYDOWN (&h100)


Code:
          WHILE GetMessage(Msg, %NULL, 0, 0)  ' SK_MILLISECOND
             'IF GetFocus() = hCtrl AND
             IF (Msg.message > 255 AND Msg.message < 266) THEN
                 
                'IF msg.message=%wm_keydown THEN MSGBOX "keydown main"
                'IF msg.message=%wm_syskeydown THEN MSGBOX "syskeydown main"
               
                LOCAL BBP AS BBPLUGIN
                BBP.Msg    = %BBP_KEYBOARD
                BBP.WinMsg = Msg.message
                BBP.wParam = Msg.wParam
                BBP.lParam = Msg.lParam
                CALL BBP_Plugin(BBP)

                CALL TranslateMessage(Msg)
                CALL DispatchMessage(Msg)
             ELSE
                IF IsDialogMessage(hMain, Msg) = %FALSE THEN
                   CALL TranslateMessage(Msg)
                  CALL DispatchMessage(Msg)
                END IF
             END IF
          WEND

Logged
Patrice Terrier
Global Moderator
Hero Member
*****

Karma: 36
Offline Offline

Gender: Male
Posts: 1353


WWW
« Reply #158 on: November 06, 2007, 11:28:52 AM »

--Charles,

Quote
Using the keyboard generates %WM_KEYDOWN (&h100)
but after using the mouse, the keyboard message then becomes %WM_SYSKEYDOWN (&h104).
The next key pressed after this will revert to %WM_KEYDOWN (&h100)

Yes, this is because we are not using a dedicated "game message pump", but a full Windows message pump using the TranslateMessage API to be compatible with the other child controls of the BassBox window.

See details on MSDN there:
http://msdn2.microsoft.com/en-us/library/ms644955.aspx
« Last Edit: November 06, 2007, 04:22:27 PM by Patrice Terrier » Logged

Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com
Charles Pegge
Global Moderator
Hero Member
*****

Karma: 19
Offline Offline

Posts: 648



WWW
« Reply #159 on: November 06, 2007, 03:44:37 PM »


That's fine Patrice. I have disabled the hctrl focus condition in the Winmain message loop. But is there a way to stop it 'plunk'ing when a key is pressed.

Sonic Circles

This update is well behaved, easier on the eye and visualises more sonic data.
Logged
Patrice Terrier
Global Moderator
Hero Member
*****

Karma: 36
Offline Offline

Gender: Male
Posts: 1353


WWW
« Reply #160 on: November 06, 2007, 05:20:11 PM »

--Charles

Code:
BBP_CreateGLTextureFromFile ("BBPlugin\Texture\wood.jpg",tsc,tsc,pix(),0)

You improperly use the BBP_CreateGLTextureFromFile API. (please look at the source code in BBPlugin.inc)

No need for you to first DIM the array, juste use REDIM pix(0) AS BYTE, because the real size of the array is computed inside of the API.
And using BBPlugin\Texture\wood.jpg",tsc,tsc,pix(),0) is a NoNo, because the texture could fit into a rectangle and not necessarily into a square, moreover the size is rounded to the best 2^, and not to the size YOU specify.
This is because BBP_CreateGLTextureFromFile is able to create a texture form any picture size, and from any GDIPLUS graphic format.

Here is how to use it:
Code:
SUB MakeTexture(zPathToTexture AS ASCIIZ)
    LOCAL nRet, xSize, ySize AS LONG
    DIM Texture(0) AS STATIC LONG

    REDIM PixelArray(0) AS BYTE
    IF BBP_CreateGLTextureFromFile(zPathToTexture, xSize, ySize, PixelArray(), 1) THEN
       CALL glDeleteTextures(1, Texture(0))
       CALL glGenTextures(1, Texture(0)): nRet = glGetError()
       IF nRet = 0 THEN
          CALL glBindTexture(%GL_TEXTURE_2D, Texture(0))
          CALL glTexParameteri(%GL_TEXTURE_2D, %GL_TEXTURE_MAG_FILTER, %GL_LINEAR)
          CALL glTexParameteri(%GL_TEXTURE_2D, %GL_TEXTURE_MIN_FILTER, %GL_LINEAR)
          CALL glTexImage2D(%GL_TEXTURE_2D, 0, 4, xSize, ySize, 0, %GL_RGBA, %GL_UNSIGNED_BYTE, PixelArray(0))
       END IF
    END IF

END SUB

The important part is:
    REDIM PixelArray(0) AS BYTE
    IF BBP_CreateGLTextureFromFile(zPathToTexture, BYREF xSize, BYREF ySize, PixelArray(), 1) THEN



...
« Last Edit: November 06, 2007, 05:24:06 PM by Patrice Terrier » Logged

Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com
Charles Pegge
Global Moderator
Hero Member
*****

Karma: 19
Offline Offline

Posts: 648



WWW
« Reply #161 on: November 06, 2007, 06:11:57 PM »

Patrice, I may need a bit more flexibility - to be able to grab pieces of an image, at varying resolutions, twiddle the pixels etc. The GDIplus Thumbnail was fine for this. Some images may be used at very low resolutions for diffuse effects. I want to use images like Jackson Pollock uses paint Smiley

One idea I am pursuing at the moment is to be able to construct the scene, then capture this as a texture and use it in the next frame so you get an infinite recursion of the image - like a hall of mirrors.

So you see, keeping close to the lower levels of the interface has its benefits.
Logged
Patrice Terrier
Global Moderator
Hero Member
*****

Karma: 36
Offline Offline

Gender: Male
Posts: 1353


WWW
« Reply #162 on: November 06, 2007, 06:46:18 PM »

--Charles

I have no problem with flexibility, I am just focusing your attention on the way the current BBP_CreateGLTextureFromFile works.
Of course feel free to use your own procedure to perform texture creation as long as it is well behaved with the others plugins.

About the focus everything is done by the kernell (BassBox), thus no need to do it in the plugin.
I have edited, and checked all the enclosed plugins to make sure they work well with the current BassBox version.

There is a new texture: Mask72.jpg that looks also good with what you have done.

The current plug005 version makes me think to "Stonehenge" perhaps we could use menhirs and dolmens instead of the wooden pieces and it would become very celtic...  Wink
« Last Edit: November 08, 2007, 05:21:15 PM by Patrice Terrier » Logged

Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com
Petr Schreiber
Sr. Member
****

Karma: 9
Offline Offline

Posts: 420


« Reply #163 on: November 06, 2007, 09:23:17 PM »

Hi,

thanks for the perfect updates, it really looks cool.

I am sorry, but I am afraid there won't be any complete code from me for some time, as I am running too much paralel processes while having single core brain Cheesy


Bye,
Petr
Logged

AMD Sempron 3400+ | 1GB RAM @ 533MHz | GeForce 6200 / GeForce 9500GT | 32bit Windows XP SP3

psch.thinbasic.com
Charles Pegge
Global Moderator
Hero Member
*****

Karma: 19
Offline Offline

Posts: 648



WWW
« Reply #164 on: November 06, 2007, 09:55:39 PM »


Thanks Patrice. The Celtic theme is an excellent idea. Will need to find some convincing stones. Celtic patterns are interesting too.

By the way, Patch39 contains my 2 previous bas versions of PLUG005 but not the latest source, though you have included the compiled DLL of it.



Petr, there is only one solution to single core brain syndrome, and that is to combine all your projects into one big project.
Logged
Pages: « 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 »   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC

IMPRESSUM
Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM
Page created in 0.198 seconds with 18 queries.