• Welcome to Theos PowerBasic Museum 2017.

News:

Attachments are only available to registered users.
Please register using your full, real name.

Main Menu

BassBox

Started by Patrice Terrier, October 08, 2007, 10:57:44 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Emil Weiss

#480
great and thanks for good work

greets Emil

Petr Schreiber

#481
Thanks Patrice,

really impresive :o
Just one complaint ( applies to my Mikado too :-[ ) - for rhytmic music, the perspective scaling of whole ... thing ... on screen is very jumpy, which results in impression the visualisation flickers/runs slow although it runs at great 60FPS.


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

psch.thinbasic.com

Patrice Terrier

#482
Petr,

I shall work on this when i have time, i did it fast with cut and paste from several plugins, including Mikado ;)

I shall post the source code there when cleaned up.


would you imagine that there are spherical quadric objects in it  8)

Added:
By the way it should work at 34 Fps not 60 Fps, if you apply the changes i posted there a few days ago, that will decrease drasticaly the CPU usage.


...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Petr Schreiber

Thanks for the info,

do you use quadrics for the surround beams?
Regarding low CPU mods - I have seen them, and worked great. But I am FPS addict, when I do not get at least 40FPS I start to cry :D, so I stick with the CPU torture ( ok not that much :) ) version.


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

psch.thinbasic.com

Patrice Terrier

#484
Quotedo you use quadrics for the surround beams?

Yes, but in a very unusual way, see below in red:

SUB RenderPhoenix(BYVAL edge AS SINGLE)
    edge = edge / 2
    CALL glTexCoord2f(0.0, 0.0): CALL glVertex3f(-edge,-edge, 0.0)
    CALL glTexCoord2f(1.0, 0.0): CALL glVertex3f( edge,-edge, 0.0)
    CALL glTexCoord2f(1.0, 1.0): CALL glVertex3f( edge, edge, 0.0)
    CALL glTexCoord2f(0.0, 1.0): CALL glVertex3f(-edge, edge, 0.0)
       
    LOCAL quadObj AS LONG
    quadObj = gluNewQuadric()                        ' Pointer to the Quadric Object (Return 0 If No Memory))
    IF quadObj THEN
       CALL gluQuadricNormals(quadObj, %GLU_SMOOTH)  ' Create Smooth Normals
       CALL gluQuadricTexture(quadObj, %GL_TRUE)     ' Create Texture Coords
       CALL gluSphere(quadObj, edge * 3, 2, 2)
       CALL gluDeleteQuadric(quadObj)
    END IF
END SUB

I used gluSphere by lazyness.
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Emil Weiss

new idea

it's real you can make the mousepointer to opengl
when move over the Window
think is a god control for check i have a Focus....

greets Emil

Patrice Terrier

Emil,

See in BassBox the VisualProc:


FUNCTION VisualProc (BYVAL hWnd AS LONG, BYVAL Msg AS LONG, BYVAL wParam AS LONG, BYVAL lParam AS LONG) EXPORT AS LONG
    LOCAL hResource AS LONG, ps AS PAINTSTRUCT, rc AS RECT
    LOCAL BBP AS BBPLUGIN

    SELECT CASE LONG Msg
    CASE %WM_ERASEBKGND
         FUNCTION = 1: EXIT FUNCTION
'    CASE %WM_KEYDOWN TO %WM_UNICHAR
'         BBP.Msg    = %BBP_KEYBOARD
'         BBP.WinMsg = Msg
'         BBP.wParam = wParam
'         BBP.lParam = lParam
'         CALL BBP_Plugin(BBP)
    CASE %WM_MOUSEMOVE TO %WM_XBUTTONDBLCLK
         IF Msg = %WM_LBUTTONDOWN AND GetFocus() <> hWnd THEN CALL SetFocus(hWnd)
         BBP.Msg    = %BBP_MOUSE
         BBP.WinMsg = Msg
         BBP.wParam = wParam
         BBP.lParam = lParam
         CALL BBP_Plugin(BBP)
    CASE %WM_PAINT
         CALL BeginPaint(hWnd, ps)
         CALL EndPaint(hWnd, ps)
         FUNCTION = 0: EXIT FUNCTION
    END SELECT
    FUNCTION = DefWindowProc (hWnd, Msg, wParam, lParam)
END FUNCTION
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Emil Weiss

do not understand me
i mean a grafik Cursor in OpenGl
change window Cursor to OpenGl Cursor

greets Emil

Petr Schreiber

#488
Hi Emil,

if you mean cursor rendered in OpenGL ... sure it is possible ( check out gluUnProject for transformation of window to 3D coordinates ), but it is recommended to use Windows "hardware" cursor, which never lags, even if framerate goes down.

Patrice, thanks for showing the way. It little bit scares me as I cannot see any glBegin/glEnd around the glVertex3f commands. If it is defined outside, then it is kind of luck you mix gluQuadrics and glVertex3f there ( NVIDIA drivers are very tolerant, other not so much ). Once the complete source code will be out I can give more advice, but I think now you dance on thin edge separating OpenGL specification and driver specific implementation. On some cards it could generate GL error and could be followed by undefined behaviour.

According to specs:
Quote
Only a subset of GL commands can be used between glBegin and glEnd.
The commands are
glVertex,
glColor,
glIndex,
glNormal,
glTexCoord,
glEvalCoord,
glEvalPoint,
glArrayElement,
glMaterial, and
glEdgeFlag.
Also, it is acceptable to use glCallList or glCallLists to execute display lists that include only the preceding commands.
If any other GL command is executed between glBegin and glEnd, the error flag is set and the command is ignored.


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

psch.thinbasic.com

Emil Weiss

QuoteHi Emil,

if you mean cursor rendered in OpenGL ... sure it is possible ( check out gluUnProject for transformation of window to 3D coordinates ), but it is recommended to use Windows "hardware" cursor, which never lags, even if framerate goes down.

yes is posible make this for all plugin ?
when not then i make it self ...
my problem this is no longer compatible to plugin

greets Emil

Patrice Terrier

Petr,

Here is the rough code, feel free to enhance it.

as you will see RenderPhoenix is enclosed in glBegin/glEnd.

I didn't had time yet to work on the sound sensitivity (aka Mikado)

Note: without seeing the source code, i guess nobody could figure the texture that has been used  :)


'+--------------------------------------------------------------------------+
'|                                                                          |
'|                                Phoenix                                   |
'|                          BassBox OpenGL plugin                           |
'|                                                                          |
'|                              Version 1.00                                |
'+--------------------------------------------------------------------------+
'|                                                                          |
'|                         Author Patrice TERRIER                           |
'|                                                                          |
'|                            copyright(c) 2008                             |
'|                                                                          |
'|                Patrice Terrier http://www.zapsolution.com                |
'|                                                                          |
'+--------------------------------------------------------------------------+
'|                  Project started on : 06-10-2008 (MM-DD-YYYY)            |
'|                        Last revised : 06-10-2008 (MM-DD-YYYY)            |
'+--------------------------------------------------------------------------+
'

#COMPILE DLL "Phoenix.dll"
#INCLUDE "Include\BBPlugin.inc"

%GL_MODELVIEW                   = &H1700
%GL_PROJECTION                  = &H1701
%GL_DEPTH_TEST                  = &H0B71
%GL_SMOOTH                      = &H1D01
%GL_TRIANGLE_FAN                = &H0006
%GL_DEPTH_BUFFER_BIT            = &H00000100
%GL_COLOR_BUFFER_BIT            = &H00004000
%GL_LINES                       = &H0001???
%GL_LESS                        = &H0201

%GL_ONE                         = &h0001&
%GL_BLEND                       = &h0BE2&
%GL_GREATER                     = &H0204
%GL_PERSPECTIVE_CORRECTION_HINT = &h0C50&
%GL_NICEST                      = &h1102&
%GL_QUADS                       = &h0007&
%GL_TEXTURE_2D                  = &h0DE1&
%GL_TEXTURE_MAG_FILTER          = &h2800&
%GL_TEXTURE_MIN_FILTER          = &h2801&
%GL_LUMINANCE                   = &h1909&
%GL_RGB                         = &H1907
%GL_RGBA                        = &H1908
%GL_TEXTURE                     = &H1702
%GL_LESS                        = &H0201
%GL_LIGHTING                    = &H0B50
%GL_GREATER                     = &H0204
%GL_LINEAR                      = &h2601&
%GL_POINTS                      = &H0000
%GL_POINT_SPRITE                = &H08861
%GL_COORD_REPLACE               = &H08862

TYPE RECT
    nLeft AS LONG
    nTop AS LONG
    nRight AS LONG
    nBottom AS LONG
END TYPE

TYPE tColorBox
    length AS SINGLE
    r1 AS BYTE
    g1 AS BYTE
    b1 AS BYTE
    r2 AS BYTE
    g2 AS BYTE
    b2 AS BYTE
END TYPE

DECLARE FUNCTION GetClientRect LIB "USER32.DLL" ALIAS "GetClientRect" (BYVAL hwnd AS DWORD, lpRect AS RECT) AS LONG

DECLARE SUB glClearColor LIB "OPENGL32.DLL" ALIAS "glClearColor" (BYVAL red AS SINGLE, BYVAL green AS SINGLE, BYVAL blue AS SINGLE, BYVAL alpha AS SINGLE)
DECLARE SUB glEnable LIB "OPENGL32.DLL" ALIAS "glEnable" (BYVAL cap AS DWORD)
DECLARE SUB glShadeModel LIB "OPENGL32.DLL" ALIAS "glShadeModel" (BYVAL mode AS DWORD)
DECLARE SUB glMatrixMode LIB "OPENGL32.DLL" ALIAS "glMatrixMode" (BYVAL mode AS DWORD)
DECLARE SUB glLoadIdentity LIB "OPENGL32.DLL" ALIAS "glLoadIdentity" ()
DECLARE SUB gluPerspective LIB "glu32.dll" ALIAS "gluPerspective" (BYVAL fovy#, BYVAL aspect#, BYVAL zNear#, BYVAL zFar AS DOUBLE)
DECLARE SUB glClear LIB "OPENGL32.DLL" ALIAS "glClear" (BYVAL mask AS DWORD)
DECLARE SUB glRotatef LIB "OPENGL32.DLL" ALIAS "glRotatef" (BYVAL angle AS SINGLE, BYVAL x AS SINGLE, BYVAL y AS SINGLE, BYVAL z AS SINGLE)
DECLARE SUB glBegin LIB "OPENGL32.DLL" ALIAS "glBegin" (BYVAL mode AS DWORD)
DECLARE SUB glEnd LIB "OPENGL32.DLL" ALIAS "glEnd" ()
DECLARE SUB glColor3ub LIB "OPENGL32.DLL" ALIAS "glColor3ub" (BYVAL red AS BYTE, BYVAL green AS BYTE, BYVAL blue AS BYTE)
DECLARE SUB glVertex3f LIB "opengl32.dll" ALIAS "glVertex3f" (BYVAL SINGLE, BYVAL SINGLE, BYVAL SINGLE)
DECLARE SUB glPushMatrix LIB "OPENGL32.DLL" ALIAS "glPushMatrix" ()
DECLARE SUB glPopMatrix LIB "OPENGL32.DLL" ALIAS "glPopMatrix" ()
DECLARE SUB glTranslatef LIB "opengl32.dll" ALIAS "glTranslatef" (BYVAL SINGLE, BYVAL SINGLE, BYVAL SINGLE)
DECLARE SUB gluLookAt LIB "glu32.dll" ALIAS "gluLookAt" (BYVAL eyex#, BYVAL eyey#, BYVAL eyez#, BYVAL centerx#, BYVAL centery#, BYVAL centerz#, BYVAL upx#, BYVAL upy#, BYVAL upz AS DOUBLE)
DECLARE FUNCTION wglMakeCurrent LIB "OPENGL32.DLL" ALIAS "wglMakeCurrent" (BYVAL hdc AS DWORD, BYVAL hglrc AS DWORD) AS LONG
DECLARE SUB glLineWidth LIB "OPENGL32.DLL" ALIAS "glLineWidth" (BYVAL nWidth AS SINGLE)
DECLARE SUB glGenTextures LIB "opengl32.dll" ALIAS "glGenTextures" (BYVAL DWORD, textures AS ANY)
DECLARE SUB glBindTexture LIB "opengl32.dll" ALIAS "glBindTexture" (BYVAL DWORD, BYVAL DWORD)
DECLARE FUNCTION glGetError LIB "opengl32.dll" ALIAS "glGetError" () AS DWORD
DECLARE SUB glDeleteTextures LIB "opengl32.dll" ALIAS "glDeleteTextures" (BYVAL LONG, textures AS ANY)
DECLARE SUB glClearDepth LIB "opengl32.dll" ALIAS "glClearDepth" (BYVAL DOUBLE)
DECLARE SUB glBlendFunc LIB "opengl32.dll" ALIAS "glBlendFunc" (BYVAL LONG, BYVAL LONG)
DECLARE SUB glDepthFunc LIB "OPENGL32.DLL" ALIAS "glDepthFunc" (BYVAL func AS DWORD)
DECLARE SUB glAlphaFunc LIB "OPENGL32.DLL" ALIAS "glAlphaFunc" (BYVAL func AS DWORD, BYVAL ref AS SINGLE)
DECLARE SUB glHint LIB "opengl32.dll" ALIAS "glHint" (BYVAL DWORD, BYVAL DWORD)
DECLARE SUB glTexCoord2f LIB "opengl32.dll" ALIAS "glTexCoord2f" (BYVAL SINGLE, BYVAL SINGLE)
DECLARE SUB glTexParameteri LIB "opengl32.dll" ALIAS "glTexParameteri" (BYVAL DWORD, BYVAL DWORD, BYVAL LONG)
DECLARE SUB glTexImage2D LIB "opengl32.dll" ALIAS "glTexImage2D" (BYVAL DWORD, BYVAL LONG, BYVAL LONG, BYVAL LONG, BYVAL LONG, BYVAL LONG, BYVAL DWORD, BYVAL DWORD, npixels AS ANY)
DECLARE SUB glPointSize LIB "opengl32.dll" ALIAS "glPointSize" (BYVAL lsize AS SINGLE)
DECLARE SUB glTexEnvi LIB "opengl32.dll" ALIAS "glTexEnvi" (BYVAL DWORD, BYVAL DWORD, BYVAL LONG)

GLOBAL gColor() AS LONG

SUB ColorInit()
    DIM gColor(1 TO 33) AS LONG
    gColor(1)  = RGB(32,32,32)
    gColor(2)  = RGB(0,44,233)
    gColor(3)  = RGB(0,67,210)
    gColor(4)  = RGB(0,89,187)
    gColor(5)  = RGB(0,112,164)
    gColor(6)  = RGB(0,135,142)
    gColor(7)  = RGB(0,159,117)
    gColor(8)  = RGB(0,183,88)
    gColor(9)  = RGB(0,207,58)
    gColor(10) = RGB(0,231,29)
    gColor(11) = RGB(26,234,26)
    gColor(12) = RGB(52,237,23)
    gColor(13) = RGB(79,240,20)
    gColor(14) = RGB(105,243,17)
    gColor(15) = RGB(126,245,14)
    gColor(16) = RGB(147,248,11)
    gColor(17) = RGB(168,250,8)
    gColor(18) = RGB(189,253,5)
    gColor(19) = RGB(210,255,2)
    gColor(20) = RGB(233,255,0)
    gColor(21) = RGB(255,255,0)
    gColor(22) = RGB(255,251,0)
    gColor(23) = RGB(255,235,0)
    gColor(24) = RGB(255,215,0)
    gColor(25) = RGB(255,196,0)
    gColor(26) = RGB(255,176,0)
    gColor(27) = RGB(255,156,0)
    gColor(28) = RGB(253,137,0)
    gColor(29) = RGB(255,117,0)
    gColor(30) = RGB(255,97,0)
    gColor(31) = RGB(255,78,0)
    gColor(32) = RGB(255,58,0)
    gColor(33) = RGB(255,0,0)
END SUB

FUNCTION LevelColr(BYVAL nLevel AS LONG) AS LONG
    LOCAL nColor AS LONG
    nLevel = nLevel + 1: IF nLevel > 33 THEN nLevel = 33
    nColor = 0: IF nLevel > 0 THEN nColor = gColor(nLevel)
    FUNCTION = nColor
END FUNCTION

'// The main exported plugin's function would be bbProc, like this:
FUNCTION BBProc ALIAS "BBProc" (BYREF BBP AS BBPLUGIN) EXPORT AS LONG
    STATIC rXangle, rYangle, rZangle, LastTime AS DOUBLE
    DIM PulseMemory(0 TO 128) AS STATIC tColorBox

    LOCAL nRet AS LONG

    DIM mt(1 TO 1) AS STATIC BBPTEXTURE

    nRet = %BBP_SUCCESS

    SELECT CASE LONG BBP.Msg
    CASE %BBP_RENDER
         '// Draw the scene using BBP.LeftPeak and BBP.RightPeak
         LOCAL K, nLValue, nRValue, RGBColor AS LONG
         LOCAL xD, pulse AS SINGLE, R1, G1, B1, R2, G2, B2 AS BYTE
         LOCAL PulseMemorySample AS tColorBox
     
         nLValue = (BBP.Lpeak / 700)
         nRValue = (BBP.Rpeak / 768)
     
         rXangle = rXangle + 0.3 '// grDXangle
         rYangle = rYangle + 0.5 '// grDYangle
         rZangle = rZangle + 0.7 '// grDZangle
     
         pulse = MAX(nLValue, nRValue) / 7
     
         '// Pulsating section
         CALL glMatrixMode(%GL_PROJECTION)
         CALL glLoadIdentity()
         CALL gluPerspective(35.0 - pulse, 1.25, 0.1, 150.0)
     
         CALL glMatrixMode(%GL_MODELVIEW)
         '// Velocity section
         pulse = ABS(pulse / 4)
         rXangle = rXangle + pulse '// grDXangle
         rYangle = rYangle + pulse '// grDYangle
         rZangle = rZangle + pulse '// grDZangle
     
         '// Very important we must reassign UseRC to the new UseDC
         '// Note: don't use permanent DC, this produce better and smoother display
         CALL wglMakeCurrent(BBP.DC, BBP.RC)
     
         CALL glClear(%GL_COLOR_BUFFER_BIT OR %GL_DEPTH_BUFFER_BIT)
         CALL glLoadIdentity()
         CALL gluLookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0)
     
         '// Draw Visualisation
         RGBColor = LevelColr(nLValue)
         R2 = BBP_GetRValue(RGBColor)
         G2 = BBP_GetGValue(RGBColor)
         B2 = BBP_GetBValue(RGBColor)
     
         RGBColor = LevelColr(nRValue)
         R1 = BBP_GetRValue(RGBColor)
         G1 = BBP_GetGValue(RGBColor)
         B1 = BBP_GetBValue(RGBColor)
     
         PulseMemorySample.r1 = r1
         PulseMemorySample.g1 = g1
         PulseMemorySample.b1 = b1
         PulseMemorySample.r2 = r2
         PulseMemorySample.g2 = g2
         PulseMemorySample.b2 = b2
         PulseMemorySample.length = pulse
     
         IF TIMER - LastTime > 0.02 THEN ' Not more frequent than 50 Hz
            ARRAY INSERT PulseMemory(LBOUND(PulseMemory)), PulseMemorySample
            LastTime = TIMER
         END IF
     
         FOR K = LBOUND(PulseMemory) TO UBOUND(PulseMemory)
             CALL glPushMatrix()
                  CALL glTranslatef(0, 0, -K / 10)
                  CALL glRotatef( K * 3, 0, 0, 1)
                  xD = 0.25 * (1 + pulse): GOSUB SubRender
             CALL glPopMatrix()
     
             CALL glPushMatrix()
                  CALL glTranslatef(0, 0, -K / 10)
                  CALL glRotatef(-K * 3, 0, 0, 1)
                  xD = 0.125: GOSUB SubRender
             CALL glPopMatrix()
         NEXT

    CASE %BBP_CREATE
         '// Retrieve plugin details
         BBP.Title    = "The Phoenix"
         BBP.Author   = "Patrice Terrier"
         BBP.Version  = MAKDWD(1, 0) '// Version 1.0"
         BBP.RenderTo = %BBP_OPENGL  '// or %BBP_GDIPLUS, or %BBP_DIRECTX

    CASE %BBP_INIT
         '// Do your code initialisation there

         CALL BBP_SplitColorARGB(BBP.BackARGB, A?, R?, G?, B?)
         Alpha! = A? + 1: Red! = R? + 1: Green! = G? + 1: Blue! = B? + 1
         CALL glClearColor(Red! / 256, Green! /256, Blue! / 256, Alpha! / 256)

         CALL glShadeModel(%GL_SMOOTH) '// Enables Smooth Color Shading
         CALL glClearDepth(1.0)        '// Depth Buffer Setup

         CALL glDisable(%GL_DEPTH_TEST)'// Disable Depth Buffer

         CALL glBlendFunc(%GL_ONE, %GL_ONE)

         CALL glDepthFunc(%GL_LESS)    '// The Type Of Depth Test To Do

         CALL glDisable(%GL_LIGHTING)

         CALL glEnable(%GL_BLEND)
                 
         CALL glAlphaFunc(%GL_GREATER, 0.01)

         CALL glHint(%GL_PERSPECTIVE_CORRECTION_HINT, %GL_NICEST)

         CALL glEnable(%GL_TEXTURE_2D)

         mt(1).FullName = $BBP_PLUGIN_FOLDER + "Texture\MiniStar.jpg":  mt(1).ID = 1: mt(2).Square = 0
         CALL MakeMutipleTexture (BYVAL VARPTR(mt(LBOUND(mt))), UBOUND(mt) - LBOUND(mt) + 1)

         CALL ColorInit()

    CASE %BBP_SIZE
         '// The size of the view port has changed.
         LOCAL rAspect AS DOUBLE, rc AS RECT
         CALL GetClientRect(BBP.ParentWindow, rc)

         CALL glMatrixMode(%GL_PROJECTION)
         CALL glLoadIdentity()
         rAspect = 0: IF rc.nBottom THEN rAspect = rc.nRight / rc.nBottom
         CALL gluPerspective(35.0, rAspect, 0.1, 150.0)
         CALL glMatrixMode(%GL_MODELVIEW)

    CASE %BBP_DESTROY
         '// Free up your resources there

    CASE ELSE
        nRet = %BBP_ERROR
    END SELECT

    FUNCTION = nRet
    EXIT FUNCTION

SubRender:
    CALL glBindTexture(%GL_TEXTURE_2D, mt(1).Texture)
    CALL glBegin(%GL_QUADS)
         CALL glColor3ub(PulseMemory(K).r2, PulseMemory(K).g2, PulseMemory(K).b2)
         CALL glVertex3f( xD, -PulseMemory(K).length, PulseMemory(K).length)
         CALL RenderPhoenix(PulseMemory(K).length * 2)
    CALL glEnd()
    RETURN
   
END FUNCTION

DECLARE FUNCTION gluNewQuadric LIB "glu32.dll" ALIAS "gluNewQuadric"  () AS LONG
DECLARE SUB gluDeleteQuadric   LIB "glu32.dll" ALIAS "gluDeleteQuadric"   (BYVAL state AS ANY)
DECLARE SUB gluQuadricNormals  LIB "glu32.dll" ALIAS "gluQuadricNormals"  (BYVAL quadObject AS ANY, BYVAL normals AS DWORD)
DECLARE SUB gluQuadricTexture  LIB "glu32.dll" ALIAS "gluQuadricTexture"  (BYVAL quadObject AS ANY, BYVAL textureCoords AS DWORD)' ANY)
DECLARE SUB gluSphere          LIB "glu32.dll" ALIAS "gluSphere" (BYVAL qobj AS ANY, BYVAL radius#, BYVAL slices&, BYVAL stacks AS LONG)
%GL_TRUE                       = 1
%GLU_SMOOTH                    = 100000

SUB RenderPhoenix(BYVAL edge AS SINGLE)
    edge = edge / 2
    CALL glTexCoord2f(0.0, 0.0): CALL glVertex3f(-edge,-edge, 0.0)
    CALL glTexCoord2f(1.0, 0.0): CALL glVertex3f( edge,-edge, 0.0)
    CALL glTexCoord2f(1.0, 1.0): CALL glVertex3f( edge, edge, 0.0)
    CALL glTexCoord2f(0.0, 1.0): CALL glVertex3f(-edge, edge, 0.0)
       
    LOCAL quadObj AS LONG
    quadObj = gluNewQuadric()                        ' Pointer to the Quadric Object (Return 0 If No Memory))
    IF quadObj THEN
       CALL gluQuadricNormals(quadObj, %GLU_SMOOTH)  ' Create Smooth Normals
       CALL gluQuadricTexture(quadObj, %GL_TRUE)     ' Create Texture Coords
       CALL gluSphere(quadObj, edge * 3, 2, 2)
       CALL gluDeleteQuadric(quadObj)
    END IF
END SUB

SUB MakeMutipleTexture (BYVAL tp AS BBPTEXTURE PTR, BYVAL N AS LONG)
    LOCAL mtCount, K, nRet, xSize, ySize AS LONG
    DIM mt(1 TO N) AS BBPTEXTURE AT tp
    mtCount = UBOUND(mt()) - LBOUND(mt()) + 1
    IF mtCount THEN
       DIM Texture(1 TO mtCount) AS LONG
       CALL glDeleteTextures(mtCount, Texture(1))
       CALL glGenTextures(mtCount, Texture(1)): nRet = glGetError()
       IF nRet = 0 THEN
          FOR K = 1 TO mtCount
              REDIM PixelArray(0) AS BYTE
              IF BBP_CreateGLTextureFromFile(mt(K).FullName, xSize, ySize, PixelArray(), mt(K).Square) THEN
                 mt(k).Texture = Texture(K)
                 CALL glBindTexture(%GL_TEXTURE_2D, Texture(K)): nRet = glGetError
                 IF nRet = 0 THEN
                    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
          NEXT
       END IF
    END IF
END SUB

Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Petr Schreiber

#491
Hi Patrice,

your current code produced GL_INVALID_OPERATION, there were 2 reasons:

  • passing 5 vertices to %GL_QUADS ( fixed as using more versatile %GL_POLYGON )
  • that yet mentioned quading inside glBegin/glEnd

... now the bad news - the surround beams looked as they looked thanks to some weird transformation crossbreeding with error on stack.
Here is my best try so far, still does not look like original but like angry parrot feathers :). But no GL error.

'+--------------------------------------------------------------------------+
'|                                                                          |
'|                                Phoenix                                   |
'|                          BassBox OpenGL plugin                           |
'|                                                                          |
'|                              Version 1.00                                |
'+--------------------------------------------------------------------------+
'|                                                                          |
'|                         Author Patrice TERRIER                           |
'|                                                                          |
'|                            copyright(c) 2008                             |
'|                                                                          |
'|                Patrice Terrier http://www.zapsolution.com                |
'|                                                                          |
'+--------------------------------------------------------------------------+
'|                  Project started on : 06-10-2008 (MM-DD-YYYY)            |
'|                        Last revised : 06-10-2008 (MM-DD-YYYY)            |
'+--------------------------------------------------------------------------+
'

#COMPILE DLL "Phoenix.dll"
#INCLUDE "Include\BBPlugin.inc"

%GL_MODELVIEW                   = &H1700
%GL_PROJECTION                  = &H1701
%GL_DEPTH_TEST                  = &H0B71
%GL_SMOOTH                      = &H1D01
%GL_TRIANGLE_FAN                = &H0006
%GL_DEPTH_BUFFER_BIT            = &H00000100
%GL_COLOR_BUFFER_BIT            = &H00004000
%GL_LINES                       = &H0001???
%GL_LESS                        = &H0201

%GL_ONE                         = &h0001&
%GL_BLEND                       = &h0BE2&
%GL_GREATER                     = &H0204
%GL_PERSPECTIVE_CORRECTION_HINT = &h0C50&
%GL_NICEST                      = &h1102&
%GL_QUADS                       = &h0007&
%GL_POLYGON                        = &H0009???
%GL_TEXTURE_2D                  = &h0DE1&
%GL_TEXTURE_MAG_FILTER          = &h2800&
%GL_TEXTURE_MIN_FILTER          = &h2801&
%GL_LUMINANCE                   = &h1909&
%GL_RGB                         = &H1907
%GL_RGBA                        = &H1908
%GL_TEXTURE                     = &H1702
%GL_LESS                        = &H0201
%GL_LIGHTING                    = &H0B50
%GL_GREATER                     = &H0204
%GL_LINEAR                      = &h2601&
%GL_POINTS                      = &H0000
%GL_POINT_SPRITE                = &H08861
%GL_COORD_REPLACE               = &H08862

TYPE RECT
    nLeft AS LONG
    nTop AS LONG
    nRight AS LONG
    nBottom AS LONG
END TYPE

TYPE tColorBox
    length AS SINGLE
    r1 AS BYTE
    g1 AS BYTE
    b1 AS BYTE
    r2 AS BYTE
    g2 AS BYTE
    b2 AS BYTE
END TYPE

DECLARE FUNCTION GetClientRect LIB "USER32.DLL" ALIAS "GetClientRect" (BYVAL hwnd AS DWORD, lpRect AS RECT) AS LONG

DECLARE SUB glClearColor LIB "OPENGL32.DLL" ALIAS "glClearColor" (BYVAL red AS SINGLE, BYVAL green AS SINGLE, BYVAL blue AS SINGLE, BYVAL alpha AS SINGLE)
DECLARE SUB glEnable LIB "OPENGL32.DLL" ALIAS "glEnable" (BYVAL cap AS DWORD)
DECLARE SUB glShadeModel LIB "OPENGL32.DLL" ALIAS "glShadeModel" (BYVAL mode AS DWORD)
DECLARE SUB glMatrixMode LIB "OPENGL32.DLL" ALIAS "glMatrixMode" (BYVAL mode AS DWORD)
DECLARE SUB glLoadIdentity LIB "OPENGL32.DLL" ALIAS "glLoadIdentity" ()
DECLARE SUB gluPerspective LIB "glu32.dll" ALIAS "gluPerspective" (BYVAL fovy#, BYVAL aspect#, BYVAL zNear#, BYVAL zFar AS DOUBLE)
DECLARE SUB glClear LIB "OPENGL32.DLL" ALIAS "glClear" (BYVAL mask AS DWORD)
DECLARE SUB glRotatef LIB "OPENGL32.DLL" ALIAS "glRotatef" (BYVAL angle AS SINGLE, BYVAL x AS SINGLE, BYVAL y AS SINGLE, BYVAL z AS SINGLE)
DECLARE SUB glBegin LIB "OPENGL32.DLL" ALIAS "glBegin" (BYVAL mode AS DWORD)
DECLARE SUB glEnd LIB "OPENGL32.DLL" ALIAS "glEnd" ()
DECLARE SUB glColor3ub LIB "OPENGL32.DLL" ALIAS "glColor3ub" (BYVAL red AS BYTE, BYVAL green AS BYTE, BYVAL blue AS BYTE)
DECLARE SUB glVertex3f LIB "opengl32.dll" ALIAS "glVertex3f" (BYVAL SINGLE, BYVAL SINGLE, BYVAL SINGLE)
DECLARE SUB glPushMatrix LIB "OPENGL32.DLL" ALIAS "glPushMatrix" ()
DECLARE SUB glPopMatrix LIB "OPENGL32.DLL" ALIAS "glPopMatrix" ()
DECLARE SUB glTranslatef LIB "opengl32.dll" ALIAS "glTranslatef" (BYVAL SINGLE, BYVAL SINGLE, BYVAL SINGLE)
DECLARE SUB gluLookAt LIB "glu32.dll" ALIAS "gluLookAt" (BYVAL eyex#, BYVAL eyey#, BYVAL eyez#, BYVAL centerx#, BYVAL centery#, BYVAL centerz#, BYVAL upx#, BYVAL upy#, BYVAL upz AS DOUBLE)
DECLARE FUNCTION wglMakeCurrent LIB "OPENGL32.DLL" ALIAS "wglMakeCurrent" (BYVAL hdc AS DWORD, BYVAL hglrc AS DWORD) AS LONG
DECLARE SUB glLineWidth LIB "OPENGL32.DLL" ALIAS "glLineWidth" (BYVAL nWidth AS SINGLE)
DECLARE SUB glGenTextures LIB "opengl32.dll" ALIAS "glGenTextures" (BYVAL DWORD, textures AS ANY)
DECLARE SUB glBindTexture LIB "opengl32.dll" ALIAS "glBindTexture" (BYVAL DWORD, BYVAL DWORD)
DECLARE FUNCTION glGetError LIB "opengl32.dll" ALIAS "glGetError" () AS DWORD
DECLARE SUB glDeleteTextures LIB "opengl32.dll" ALIAS "glDeleteTextures" (BYVAL LONG, textures AS ANY)
DECLARE SUB glClearDepth LIB "opengl32.dll" ALIAS "glClearDepth" (BYVAL DOUBLE)
DECLARE SUB glBlendFunc LIB "opengl32.dll" ALIAS "glBlendFunc" (BYVAL LONG, BYVAL LONG)
DECLARE SUB glDepthFunc LIB "OPENGL32.DLL" ALIAS "glDepthFunc" (BYVAL func AS DWORD)
DECLARE SUB glAlphaFunc LIB "OPENGL32.DLL" ALIAS "glAlphaFunc" (BYVAL func AS DWORD, BYVAL ref AS SINGLE)
DECLARE SUB glHint LIB "opengl32.dll" ALIAS "glHint" (BYVAL DWORD, BYVAL DWORD)
DECLARE SUB glTexCoord2f LIB "opengl32.dll" ALIAS "glTexCoord2f" (BYVAL SINGLE, BYVAL SINGLE)
DECLARE SUB glTexParameteri LIB "opengl32.dll" ALIAS "glTexParameteri" (BYVAL DWORD, BYVAL DWORD, BYVAL LONG)
DECLARE SUB glTexImage2D LIB "opengl32.dll" ALIAS "glTexImage2D" (BYVAL DWORD, BYVAL LONG, BYVAL LONG, BYVAL LONG, BYVAL LONG, BYVAL LONG, BYVAL DWORD, BYVAL DWORD, npixels AS ANY)
DECLARE SUB glPointSize LIB "opengl32.dll" ALIAS "glPointSize" (BYVAL lsize AS SINGLE)
DECLARE SUB glTexEnvi LIB "opengl32.dll" ALIAS "glTexEnvi" (BYVAL DWORD, BYVAL DWORD, BYVAL LONG)

GLOBAL gColor() AS LONG

SUB ColorInit()
    DIM gColor(1 TO 33) AS LONG
    gColor(1)  = RGB(32,32,32)
    gColor(2)  = RGB(0,44,233)
    gColor(3)  = RGB(0,67,210)
    gColor(4)  = RGB(0,89,187)
    gColor(5)  = RGB(0,112,164)
    gColor(6)  = RGB(0,135,142)
    gColor(7)  = RGB(0,159,117)
    gColor(8)  = RGB(0,183,88)
    gColor(9)  = RGB(0,207,58)
    gColor(10) = RGB(0,231,29)
    gColor(11) = RGB(26,234,26)
    gColor(12) = RGB(52,237,23)
    gColor(13) = RGB(79,240,20)
    gColor(14) = RGB(105,243,17)
    gColor(15) = RGB(126,245,14)
    gColor(16) = RGB(147,248,11)
    gColor(17) = RGB(168,250,8)
    gColor(18) = RGB(189,253,5)
    gColor(19) = RGB(210,255,2)
    gColor(20) = RGB(233,255,0)
    gColor(21) = RGB(255,255,0)
    gColor(22) = RGB(255,251,0)
    gColor(23) = RGB(255,235,0)
    gColor(24) = RGB(255,215,0)
    gColor(25) = RGB(255,196,0)
    gColor(26) = RGB(255,176,0)
    gColor(27) = RGB(255,156,0)
    gColor(28) = RGB(253,137,0)
    gColor(29) = RGB(255,117,0)
    gColor(30) = RGB(255,97,0)
    gColor(31) = RGB(255,78,0)
    gColor(32) = RGB(255,58,0)
    gColor(33) = RGB(255,0,0)
END SUB

FUNCTION LevelColr(BYVAL nLevel AS LONG) AS LONG
    LOCAL nColor AS LONG
    nLevel = nLevel + 1: IF nLevel > 33 THEN nLevel = 33
    nColor = 0: IF nLevel > 0 THEN nColor = gColor(nLevel)
    FUNCTION = nColor
END FUNCTION

'// The main exported plugin's function would be bbProc, like this:
FUNCTION BBProc ALIAS "BBProc" (BYREF BBP AS BBPLUGIN) EXPORT AS LONG
    STATIC rXangle, rYangle, rZangle, LastTime AS DOUBLE
    DIM PulseMemory(0 TO 128) AS STATIC tColorBox

    LOCAL nRet AS LONG

    DIM mt(1 TO 1) AS STATIC BBPTEXTURE

    nRet = %BBP_SUCCESS

    SELECT CASE LONG BBP.Msg
    CASE %BBP_RENDER
         'LOCAL gl_Err AS LONG
         'gl_Err = glgeterror()
         'IF gl_Err <> 0 THEN MSGBOX STR$(gl_Err), 0,"OpenGL Error Ocurred" : EXIT FUNCTION
         '// Draw the scene using BBP.LeftPeak and BBP.RightPeak
         LOCAL K, nLValue, nRValue, RGBColor AS LONG
         LOCAL xD, pulse AS SINGLE, R1, G1, B1, R2, G2, B2 AS BYTE
         LOCAL PulseMemorySample AS tColorBox

         nLValue = (BBP.Lpeak / 700)
         nRValue = (BBP.Rpeak / 768)

         rXangle = rXangle + 0.3 '// grDXangle
         rYangle = rYangle + 0.5 '// grDYangle
         rZangle = rZangle + 0.7 '// grDZangle

         pulse = MAX(nLValue, nRValue) / 7

         '// Pulsating section
         CALL glMatrixMode(%GL_PROJECTION)
         CALL glLoadIdentity()
         CALL gluPerspective(35.0 - pulse, 1.25, 0.1, 150.0)

         CALL glMatrixMode(%GL_MODELVIEW)
         '// Velocity section
         pulse = ABS(pulse / 4)
         rXangle = rXangle + pulse '// grDXangle
         rYangle = rYangle + pulse '// grDYangle
         rZangle = rZangle + pulse '// grDZangle

         '// Very important we must reassign UseRC to the new UseDC
         '// Note: don't use permanent DC, this produce better and smoother display
         CALL wglMakeCurrent(BBP.DC, BBP.RC)

         CALL glClear(%GL_COLOR_BUFFER_BIT OR %GL_DEPTH_BUFFER_BIT)
         CALL glLoadIdentity()
         CALL gluLookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0)

         '// Draw Visualisation
         RGBColor = LevelColr(nLValue)
         R2 = BBP_GetRValue(RGBColor)
         G2 = BBP_GetGValue(RGBColor)
         B2 = BBP_GetBValue(RGBColor)

         RGBColor = LevelColr(nRValue)
         R1 = BBP_GetRValue(RGBColor)
         G1 = BBP_GetGValue(RGBColor)
         B1 = BBP_GetBValue(RGBColor)

         PulseMemorySample.r1 = r1
         PulseMemorySample.g1 = g1
         PulseMemorySample.b1 = b1
         PulseMemorySample.r2 = r2
         PulseMemorySample.g2 = g2
         PulseMemorySample.b2 = b2
         PulseMemorySample.length = pulse

         IF TIMER - LastTime > 0.02 THEN ' Not more frequent than 50 Hz
            ARRAY INSERT PulseMemory(LBOUND(PulseMemory)), PulseMemorySample
            LastTime = TIMER
         END IF

         FOR K = LBOUND(PulseMemory) TO UBOUND(PulseMemory)
             CALL glPushMatrix()
                  CALL glTranslatef(0, 0, -K / 10)
                  CALL glRotatef( K * 3, 0, 0, 1)
                  xD = 0.25 * (1 + pulse): GOSUB SubRender
             CALL glPopMatrix()

             CALL glPushMatrix()
                  CALL glTranslatef(0, 0, -K / 10)
                  CALL glRotatef(-K * 3, 0, 0, 1)
                  xD = 0.125: GOSUB SubRender
             CALL glPopMatrix()
         NEXT

    CASE %BBP_CREATE
         '// Retrieve plugin details
         BBP.Title    = "The Phoenix"
         BBP.Author   = "Patrice Terrier"
         BBP.Version  = MAKDWD(1, 0) '// Version 1.0"
         BBP.RenderTo = %BBP_OPENGL  '// or %BBP_GDIPLUS, or %BBP_DIRECTX

    CASE %BBP_INIT
         '// Do your code initialisation there

         CALL BBP_SplitColorARGB(BBP.BackARGB, A?, R?, G?, B?)
         Alpha! = A? + 1: Red! = R? + 1: Green! = G? + 1: Blue! = B? + 1
         CALL glClearColor(Red! / 256, Green! /256, Blue! / 256, Alpha! / 256)

         CALL glShadeModel(%GL_SMOOTH) '// Enables Smooth Color Shading
         CALL glClearDepth(1.0)        '// Depth Buffer Setup

         CALL glDisable(%GL_DEPTH_TEST)'// Disable Depth Buffer

         CALL glBlendFunc(%GL_ONE, %GL_ONE)

         CALL glDepthFunc(%GL_LESS)    '// The Type Of Depth Test To Do

         CALL glDisable(%GL_LIGHTING)

         CALL glEnable(%GL_BLEND)

         CALL glAlphaFunc(%GL_GREATER, 0.01)

         CALL glHint(%GL_PERSPECTIVE_CORRECTION_HINT, %GL_NICEST)

         CALL glEnable(%GL_TEXTURE_2D)

         mt(1).FullName = $BBP_PLUGIN_FOLDER + "Texture\MiniStar.jpg":  mt(1).ID = 1: mt(2).Square = 0
         CALL MakeMutipleTexture (BYVAL VARPTR(mt(LBOUND(mt))), UBOUND(mt) - LBOUND(mt) + 1)

         CALL ColorInit()

    CASE %BBP_SIZE
         '// The size of the view port has changed.
         LOCAL rAspect AS DOUBLE, rc AS RECT
         CALL GetClientRect(BBP.ParentWindow, rc)

         CALL glMatrixMode(%GL_PROJECTION)
         CALL glLoadIdentity()
         rAspect = 0: IF rc.nBottom THEN rAspect = rc.nRight / rc.nBottom
         CALL gluPerspective(35.0, rAspect, 0.1, 150.0)
         CALL glMatrixMode(%GL_MODELVIEW)

    CASE %BBP_DESTROY
         '// Free up your resources there

    CASE ELSE
        nRet = %BBP_ERROR
    END SELECT

    FUNCTION = nRet
    EXIT FUNCTION

SubRender:
    CALL glBindTexture(%GL_TEXTURE_2D, mt(1).Texture)
    CALL glPushMatrix()
    ' -- glEnd is called in RenderPhoenix :P
    CALL glBegin(%GL_POLYGON)
         CALL glColor3ub(PulseMemory(K).r2, PulseMemory(K).g2, PulseMemory(K).b2)
         CALL glVertex3f( xD, -PulseMemory(K).length, PulseMemory(K).length)
         CALL RenderPhoenix(PulseMemory(K).length * 2)
    CALL glPopMatrix()
    RETURN

END FUNCTION

DECLARE FUNCTION gluNewQuadric LIB "glu32.dll" ALIAS "gluNewQuadric"  () AS LONG
DECLARE SUB gluDeleteQuadric   LIB "glu32.dll" ALIAS "gluDeleteQuadric"   (BYVAL STATE AS ANY)
DECLARE SUB gluQuadricNormals  LIB "glu32.dll" ALIAS "gluQuadricNormals"  (BYVAL quadObject AS ANY, BYVAL normals AS DWORD)
DECLARE SUB gluQuadricTexture  LIB "glu32.dll" ALIAS "gluQuadricTexture"  (BYVAL quadObject AS ANY, BYVAL textureCoords AS DWORD)' ANY)
DECLARE SUB gluSphere          LIB "glu32.dll" ALIAS "gluSphere" (BYVAL qobj AS ANY, BYVAL radius#, BYVAL slices&, BYVAL stacks AS LONG)
%GL_TRUE                       = 1
%GLU_SMOOTH                    = 100000

SUB RenderPhoenix(BYVAL edge AS SINGLE)
    edge = edge / 2

      CALL glTexCoord2f(0.0, 0.0): CALL glVertex3f(-edge,-edge, 0.0)
      CALL glTexCoord2f(1.0, 0.0): CALL glVertex3f( edge,-edge, 0.0)
      CALL glTexCoord2f(1.0, 1.0): CALL glVertex3f( edge, edge, 0.0)
      CALL glTexCoord2f(0.0, 1.0): CALL glVertex3f(-edge, edge, 0.0)
    CALL glEnd()

    LOCAL quadObj AS LONG
   
   
    glTranslatef   -edge, edge, 0.0
   
    quadObj = gluNewQuadric()                        ' Pointer to the Quadric Object (Return 0 If No Memory))
    IF quadObj THEN
       CALL gluQuadricNormals(quadObj, %GLU_SMOOTH)  ' Create Smooth Normals
       CALL gluQuadricTexture(quadObj, %GL_TRUE)     ' Create Texture Coords
       CALL gluSphere(quadObj, edge * 3, 2, 2)
       CALL gluDeleteQuadric(quadObj)
    END IF
 
END SUB

SUB MakeMutipleTexture (BYVAL tp AS BBPTEXTURE PTR, BYVAL N AS LONG)
    LOCAL mtCount, K, nRet, xSize, ySize AS LONG
    DIM mt(1 TO N) AS BBPTEXTURE AT tp
    mtCount = UBOUND(mt()) - LBOUND(mt()) + 1
    IF mtCount THEN
       DIM Texture(1 TO mtCount) AS LONG
       CALL glDeleteTextures(mtCount, Texture(1))
       CALL glGenTextures(mtCount, Texture(1)): nRet = glGetError()
       IF nRet = 0 THEN
          FOR K = 1 TO mtCount
              REDIM PixelArray(0) AS BYTE
              IF BBP_CreateGLTextureFromFile(mt(K).FullName, xSize, ySize, PixelArray(), mt(K).Square) THEN
                 mt(k).Texture = Texture(K)
                 CALL glBindTexture(%GL_TEXTURE_2D, Texture(K)): nRet = glGetError
                 IF nRet = 0 THEN
                    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
          NEXT
       END IF
    END IF
END SUB


I have a bit busy time now, so not sure when 100% visually same version will be online, but wanted to put here at least temporary version without GL errors.

Emil - will do the code for gl cursor, but not sooner than in horizont of few weeks, busy times :(
Basically it is just unprojecting mouse coordinates, setting up ortho mode (2D) and drawing textured quad, ideally alpha masked.

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

psch.thinbasic.com

Emil Weiss

#492
QuoteEmil - will do the code for gl cursor, but not sooner than in horizont of few weeks, busy times
Basically it is just unprojecting mouse coordinates, setting up ortho mode (2D) and drawing textured quad, ideally alpha masked.
yes thanks :)
i have build a GLWindow Component for my VisPlugin
i can wait .. ;)

greets Emil

Patrice Terrier

#493
Emil,

It is exactly the same than for drawing text.

See BBP_DrawGLText in BBPlugin.inc


    SUB BBP_DrawGLText (BYVAL glWnd AS LONG, UseFont AS ZGLFONT, BYVAL x AS LONG, BYVAL y AS LONG, zTxt AS ASCIIZ, BYVAL ARGB AS LONG)
        LOCAL rc AS RECT, A, R, G, B AS BYTE, cAlpha, cRed, cGreen, cBlue AS SINGLE, WasTexture, WasLighting AS LONG
       
        CALL GetClientRect(glWnd, rc)
   
        WasTexture = glIsEnabled(%GL_TEXTURE_2D)
        IF WasTexture THEN CALL glDisable(%GL_TEXTURE_2D)        ' Turn off textures, didn't want our text textured
        WasLighting = glIsEnabled(%GL_LIGHTING)
        IF WasLighting THEN CALL glDisable(%GL_LIGHTING)         ' Disable Lighting
   
        CALL glMatrixMode(%GL_PROJECTION)
        CALL glPushMatrix()
        CALL glLoadIdentity()
        CALL glOrtho(0.0, rc.nRight, 0.0, rc.nBottom, -1.0, 1.0)
        CALL glMatrixMode(%GL_MODELVIEW)
        CALL glPushMatrix()
        CALL glLoadIdentity()
   
      ' Set color
        CALL BBP_SplitColorARGB(ARGB, A, R, G, B)
        cAlpha = A + 1: cRed = R + 1: cGreen = G + 1: cBlue = B + 1
        CALL glColor3f(cRed / 256, cGreen / 256, cBlue / 256)
      ' Set X,Y location
        CALL glRasterPos2i(x, rc.nBottom - (UseFont.fontHeight - 4) - y)
      ' Draw the text
        CALL glPushAttrib(%GL_LIST_BIT)                           ' Pushes The Display List Bits
             CALL glListBase(UseFont.fontBase - UseFont.charStart)' Sets The Base Character to 0
             CALL glCallLists(LEN(zTxt), %GL_UNSIGNED_BYTE, zTxt) ' Draws The Display List Text
        CALL glPopAttrib()                                        ' Pops The Display List Bits
   
        CALL glPopMatrix()
        CALL glMatrixMode(%GL_PROJECTION)
        CALL glPopMatrix()
        CALL glMatrixMode(%GL_MODELVIEW)
   
        IF WasTexture THEN CALL glEnable(%GL_TEXTURE_2D)          ' Enable texture mode
        IF WasLighting THEN CALL glEnable(%GL_LIGHTING)           ' Enable Lighting
   
        CALL glColor3f(1, 1, 1)                                   ' Back to default color
   
    END SUB


Also check its use in the LaserBeam.bas plugin.


Added:
All you have to do is to provide a 16 x 16 texture (arrow or whatever you want). And BBP_CreateGLTextureFromFile allows you to use PNG files to create the texture.

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Emil Weiss

Thanks for this ..
i will nothing change in the plugin self only use a OpenGl cursor in to BassVis
think this is not a problem ;)

greets Emil