PDA

View Full Version : What are the right flags for an window with border but no caption ?



D.J.Peters
05-03-2010, 09:01
i would create shadows with the stencil buffer

how to create a window/dialog with border but no caption ?

thank you

Joshy


' second try native OpenGL
' by D.J:Peters (Joshy)

#INCLUDE Once "%APP_INCLUDEPATH%\thinbasic_gl.inc"
#INCLUDE Once "%APP_INCLUDEPATH%\thinbasic_GLU.inc"
#INCLUDE Once "%APP_INCLUDEPATH%\thinbasic_WGL.inc"

Uses "UI"


' %APP_SOURCEPATH%

'
' consts
'
%PFD_TYPE_RGBA = 0
%PFD_MAIN_PLANE = 0
%PFD_DOUBLEBUFFER = 1
%PFD_STEREO = 2
%PFD_DRAW_TO_WINDOW = 4
%PFD_DRAW_TO_BITMAP = 8
%PFD_SUPPORT_GDI = 16
%PFD_SUPPORT_OPENGL = 32
%PFD_GENERIC_FORMAT = 64

%PM_NOREMOVE = 0
%PM_REMOVE = 1

%CLEAR_ALL = 0
%CLEAR_COLOR_BUFFER = 1
%CLEAR_STENCIL_BUFFER = 2
%CLEAR_ACCUM_BUFFER = 4

'
' types
'
Type PIXFORMAT
nSize As Word ' 2
nVersion As Word ' 4
dwFlags As DWord ' 8
iPixelType As Byte
cColorBits As Byte
cRedBits As Byte
cRedShift As Byte
cGreenBits As Byte
cGreenShift As Byte
cBlueBits As Byte
cBlueShift As Byte
cAlphaBits As Byte
cAlphaShift As Byte
cAccumBits As Byte
cAccumRedBits As Byte
cAccumGreenBits As Byte
cAccumBlueBits As Byte
cAccumAlphaBits As Byte
cDepthBits As Byte
cStencilBits As Byte
cAuxBuffers As Byte
iLayerType As Byte
bReserved As Byte ' 28
dwLayerMask As DWord
dwVisibleMask As DWord
dwDamageMask As DWord ' 40
End Type

Type GLDEVICE
PF As PIXFORMAT ' BufferBits Descriptor
hWin As Long ' Dialog Handle
hDC As Long ' Device Context
hRC As Long ' Render Context
Width As Long ' Curent Client Width
Height As Long ' Curent Client Height
End Type

'
' api proto types
'
Declare Function GetDC Lib "USER32.DLL" Alias "GetDC" (ByVal win As Long) As Long
Declare Function ReleaseDC Lib "USER32.DLL" Alias "ReleaseDC" (ByVal win As Long, ByVal dc As Long) As Long
Declare Function PeekMsg Lib "USER32.DLL" Alias "PeekMessageA" (ByRef msg tagMSG, ByVal win As Long, ByVal wMsgFilterMin As DWord, ByVal wMsgFilterMax As DWord, ByVal wRemoveMsg As DWord) As Long
Declare Function TranslateMessage Lib "USER32.DLL" Alias "TranslateMessage" (ByRef msg tagMSG) As Long
Declare Function DispatchMessage Lib "USER32.DLL" Alias "DispatchMessageA" (ByRef msg tagMSG) As Long

Declare Function DescribePixelFormat Lib "GDI32.dll" Alias "DescribePixelFormat" (ByVal dc As Long, ByVal iPixelFormat As Long,ByVal pfSize As Long, ByRef pf As PIXFORMAT) As Long
Declare Function ChoosePixelFormat Lib "GDI32.dll" Alias "ChoosePixelFormat" (ByVal dc As Long, ByRef pf As PIXFORMAT) As Long
Declare Function SetPixelFormat Lib "GDI32.dll" Alias "SetPixelFormat" (ByVal dc As Long, ByVal iPixelFormat As Integer, ByRef pf As PIXFORMAT) As Long
Declare Function SwapBuffers Lib "GDI32.dll" Alias "SwapBuffers" (ByVal dc As Long) As Long
'
' globals
'
Global GLDevices() As GLDEVICE
Global nGLDevices As Long

'
' sub's / functions
'
Sub InitPixFormat(ByRef PF As PIXFORMAT, _
ByVal ColorBits As Byte, _
ByVal DepthBits As Byte, _
ByVal StencilBits As Byte, _
ByVal AccumBits As Byte)
' 8/16/24/32
ColorBits = (ColorBits +7) And &H38
DepthBits = (DepthBits +7) And &H38
StencilBits = (StencilBits+7) And &H38

With PF
.nSize = 40
.nVersion = 1
.dwFlags = %PFD_DRAW_TO_WINDOW Or _
%PFD_SUPPORT_OPENGL Or _
%PFD_DOUBLEBUFFER
.iPixelType = %PFD_TYPE_RGBA ' 0
.cColorBits = ColorBits
.cDepthBits = DepthBits
.cStencilBits = StencilBits
.cAccumBits = AccumBits
.iLayerType = %PFD_MAIN_PLANE ' 0

End With
End Sub

Function AllocGLDevice() As Long
Dim found,i As Long
If nGLDevices>0 Then
For i=1 To nGLDevices
If GLDevices(i).hRC=NULL Then
found=i
End If
Next
End If
' return free device index
If found>0 Then Return found
' alloc new device
nGLDevices+=1
ReDim Preserve GLDevices(nGLDevices)
Return nGLDevices
End Function

Sub FreeGLDevice(ByRef index As Long)
If nGLDevices<1 Then Return
If index<1 Then Return
If index>nGLDevices Then Return

With GLDevices(index)
wglMakeCurrent(NULL,NULL)
wglDeleteContext(.hRC)
.hRC=NULL
ReleaseDC(.hWin,.hDC)
.hDC=NULL
Dialog End .hWin
.hWin=NULL
End With
index=0
End Sub

Function CreateGLDevice(Optional _
ByVal Width As DWord , _
ByVal Height As DWord , _
ByVal Title As String, _
ByVal ColorBits As Byte , _
ByVal DepthBits As Byte , _
ByVal StencilBits As Byte , _
ByVal AccumBits As Byte) As Long

Dim Style As DWord Value %WS_POPUP Or _
%WS_VISIBLE Or _
%WS_CLIPSIBLINGS Or _
%WS_CLIPCHILDREN Or _
%WS_DLGFRAME Or _
%WS_SYSMENU
Dim MaxWidth,MaxHeight,X,Y,index As Long
Dim tmpWin,tmpDC,tmpRC,iPixFormat As Long
Dim tmpPF As PIXFORMAT

Desktop Get Client To MaxWidth,MaxHeight
' adjust optional params
If ColorBits<8 Then ColorBits=8
If Width =0 Then Width = MaxWidth /2
If Height =0 Then Height = MaxHeight/2
If Len(Title) Then
Style = Style Or _
%WS_CAPTION Or _
%WS_MINIMIZEBOX Or _
%WS_MAXIMIZEBOX
End If
If Width >MaxWidth Then Width =MaxWidth
If Height>MaxHeight Then Height=MaxHeight

' centered
If Width <MaxWidth Then x=MaxWidth /2-Width /2
If Height<MaxHeight Then y=MaxHeight/2-Height/2

tmpWin = Dialog_New(Pixels,NULL, Title, _
x,y, width,height, _
Style,%WS_EX_APPWINDOW)
If tmpWin=NULL Then
MsgBox NULL,"error: create new window !"
Return 0
End If

Dialog Show Modeless tmpWin
Sleep(1000)
tmpDC = GetDC(tmpWin)
If tmpDC=NULL Then
MsgBox NULL,"error: get device context !"
Dialog End tmpWin
Return 0
End If



InitPixFormat(tmpPF, _
ColorBits, _
DepthBits, _
StencilBits, _
AccumBits)
iPixFormat=ChoosePixelFormat(tmpDC,tmpPF)
If iPixFormat<1 Then
MsgBox NULL,"error: choose pixel format !"
ReleaseDC(tmpWin,tmpDC)
Dialog End tmpWin
Return 0
End If

If SetPixelFormat(tmpDC,iPixFormat,tmpPF)=0 Then
MsgBox NULL,"error: set pixel format !"
ReleaseDC(tmpWin,tmpDC)
Dialog End tmpWin
Return 0
End If

tmpRC=wglCreateContext(tmpDC)
If tmpRC=NULL Then
MsgBox NULL,"error: create render context !"
ReleaseDC(tmpWin,tmpDC)
Dialog End tmpWin
Return 0
End If

If wglMakeCurrent(tmpDC,tmpRC)=0 Then
MsgBox NULL,"error: make render context as current !"
wglMakeCurent(NULL,NULL)
wglDeleteContext(tmpRC)
ReleaseDC(tmpWin,tmpDC)
Dialog End tmpWin
Return 0
End If

' ok :-)
index=AllocGLDevice()
With GLDevices(index)
.PF.nSize = 40
.PF.nVersion = 1
DescribePixelFormat(tmpDC,iPixFormat,.PF,40)
.hWin = tmpWin
.hDC = tmpDC
.hRC = tmpRC
.Width = Width
.Height = Height
End With
Return index
End Function

Sub GLDeviceSwap(ByVal index As Long)
If nGLDevices<1 Then Return
If index<1 Then Return
If index>nGLDevices Then Return
With GLDevices(index)
SwapBuffers(.hDC)
End With
End Sub

'
' main !!! close a border only window with [ALT] & [F4] !!!
'
Dim Msg As tagMsg
Dim RC As RECT
Dim DeviceID As Long
Dim rtri As Single
Dim rquad As Single


'DeviceID = CreateGLDevice() ' no border
DeviceID = CreateGLDevice(320,200) ' border no caption
'DeviceID = CreateGLDevice(,,"no size")
'DeviceID = CreateGLDevice(32000,20000,"large resizeable")
'DeviceID = CreateGLDevice(32000,20000,,24,16)
'DeviceID = CreateGLDevice(320,200,"16 BPP no DepthBits",16)
'DeviceID = CreateGLDevice(320,200,"16 BPP 16 DepthBits",16,16)
'DeviceID = CreateGLDevice(320,200,"24 BPP 32 DepthBits",24,32)
'DeviceID = CreateGLDevice(,,"24 BPP 32 DepthBits 8 StencilBits",24,32,8)

If DeviceID=0 Then
MsgBox "error: can't create GLDevice !"
Stop
End If

With GLDevices(DeviceID)
glViewport 0, 0, .Width,.Height
glMatrixMode %GL_PROJECTION
glLoadIdentity
gluPerspective 45.0, .Width/.Height, 0.1, 100.0
End With

glMatrixMode %GL_MODELVIEW
glLoadIdentity

glShadeModel %GL_SMOOTH
glClearColor 0.0, 0.0, 0.0, 1.0
glClearDepth 1.0
glEnable %GL_DEPTH_TEST
glDepthFunc %GL_LEQUAL
glHint %GL_PERSPECTIVE_CORRECTION_HINT, %GL_NICEST

Do
If PeekMsg(Msg, NULL, 0, 0, %PM_REMOVE) <> 0 Then
Select Case Msg.message
Case 161,274: Exit Do
Case %WM_SIZE
With GLDevices(DeviceID)
glViewport 0, 0, .Width,.Height
glMatrixMode %GL_PROJECTION
glLoadIdentity
gluPerspective 45.0, .Width/.Height, 0.1, 100.0
End With
End Select
TranslateMessage(Msg)
DispatchMessage(Msg)
Else
glClear %GL_COLOR_BUFFER_BIT Or %GL_DEPTH_BUFFER_BIT
glLoadIdentity
glTranslatef -1.5, 0.0, -6.0
glRotatef rtri, 0, 1, 0
glBegin %GL_TRIANGLES
glColor3f 1.0, 0.0, 0.0
glVertex3f 0.0, 1.0, 0.0
glColor3f 0.0, 1.0, 0.0
glVertex3f -1.0, -1.0, 0.0
glColor3f 0.0, 0.0, 1.0
glVertex3f 1.0, -1.0, 0.0
glEnd

glLoadIdentity
glTranslatef 1.5, 0.0, -6.0
glColor3f 0.5, 0.5, 1.0
glRotatef rquad, 1, 0, 0
glBegin %GL_QUADS
glVertex3f -1.0, 1.0, 0.0
glVertex3f 1.0, 1.0, 0.0
glVertex3f 1.0, -1.0, 0.0
glVertex3f -1.0, -1.0, 0.0
glEnd
rtri += 1
rquad += 2
SwapBuffers(GLDevices(DeviceID).hDC)
End If

Loop

FreeGLDevice(DeviceID)

Petr Schreiber
05-03-2010, 09:27
You can request the border in style,
so would this work for you?:


Dim Style As DWord Value %WS_POPUP Or _
%WS_VISIBLE Or _
%WS_CLIPSIBLINGS Or _
%WS_CLIPCHILDREN Or _
%WS_SYSMENU Or _
%WS_DLGFRAME

(added DLGFRAME)

or alrernatively this combo:


Dim Style As DWord Value %WS_POPUP Or _
%WS_VISIBLE Or _
%WS_CLIPSIBLINGS Or _
%WS_CLIPCHILDREN Or _
%WS_SYSMENU


+



tmpWin = Dialog_New(Pixels,NULL, Title, _
x,y, width,height, _
Style,%WS_EX_LEFT Or %WS_EX_CLIENTEDGE)

D.J.Peters
05-03-2010, 10:42
thank you Petr now it works
(see first post)

Joshy

Michael Hartlef
05-03-2010, 10:51
Thats for sharing. It seems that ALT+F4 is the only way to stop the script calmly, right?

D.J.Peters
05-03-2010, 11:14
hello michael

yes this true :-)

Joshy

'
' main !!! close a border only window with [ALT] & [F4] !!!
'

Petr Schreiber
05-03-2010, 11:48
Thanks,

very nice example, worked good here :)


Petr

Petr Schreiber
05-03-2010, 11:56
Version using callback,

thanks to use of timers it should kick CPU usage down even more + ESCAPE key to quit the application:


' second try native OpenGL
' by D.J:Peters (Joshy)

#INCLUDE Once "%APP_INCLUDEPATH%\thinbasic_gl.inc"
#INCLUDE Once "%APP_INCLUDEPATH%\thinbasic_GLU.inc"
#INCLUDE Once "%APP_INCLUDEPATH%\thinbasic_WGL.inc"

Uses "UI"


' %APP_SOURCEPATH%

'
' consts
'
%PFD_TYPE_RGBA = 0
%PFD_MAIN_PLANE = 0
%PFD_DOUBLEBUFFER = 1
%PFD_STEREO = 2
%PFD_DRAW_TO_WINDOW = 4
%PFD_DRAW_TO_BITMAP = 8
%PFD_SUPPORT_GDI = 16
%PFD_SUPPORT_OPENGL = 32
%PFD_GENERIC_FORMAT = 64

%PM_NOREMOVE = 0
%PM_REMOVE = 1

%CLEAR_ALL = 0
%CLEAR_COLOR_BUFFER = 1
%CLEAR_STENCIL_BUFFER = 2
%CLEAR_ACCUM_BUFFER = 4

%myTimer = 1000
%timeOut = 20 ' -- Change refresh in ms here

'
' types
'
Type PIXFORMAT
nSize As Word ' 2
nVersion As Word ' 4
dwFlags As DWord ' 8
iPixelType As Byte
cColorBits As Byte
cRedBits As Byte
cRedShift As Byte
cGreenBits As Byte
cGreenShift As Byte
cBlueBits As Byte
cBlueShift As Byte
cAlphaBits As Byte
cAlphaShift As Byte
cAccumBits As Byte
cAccumRedBits As Byte
cAccumGreenBits As Byte
cAccumBlueBits As Byte
cAccumAlphaBits As Byte
cDepthBits As Byte
cStencilBits As Byte
cAuxBuffers As Byte
iLayerType As Byte
bReserved As Byte ' 28
dwLayerMask As DWord
dwVisibleMask As DWord
dwDamageMask As DWord ' 40
End Type

Type GLDEVICE
PF As PIXFORMAT ' BufferBits Descriptor
hWin As Long ' Dialog Handle
hDC As Long ' Device Context
hRC As Long ' Render Context
Width As Long ' Curent Client Width
Height As Long ' Curent Client Height
End Type

'
' api proto types
'
Declare Function GetDC Lib "USER32.DLL" Alias "GetDC" (ByVal win As Long) As Long
Declare Function ReleaseDC Lib "USER32.DLL" Alias "ReleaseDC" (ByVal win As Long, ByVal dc As Long) As Long

Declare Function DescribePixelFormat Lib "GDI32.dll" Alias "DescribePixelFormat" (ByVal dc As Long, ByVal iPixelFormat As Long,ByVal pfSize As Long, ByRef pf As PIXFORMAT) As Long
Declare Function ChoosePixelFormat Lib "GDI32.dll" Alias "ChoosePixelFormat" (ByVal dc As Long, ByRef pf As PIXFORMAT) As Long
Declare Function SetPixelFormat Lib "GDI32.dll" Alias "SetPixelFormat" (ByVal dc As Long, ByVal iPixelFormat As Integer, ByRef pf As PIXFORMAT) As Long
Declare Function SwapBuffers Lib "GDI32.dll" Alias "SwapBuffers" (ByVal dc As Long) As Long
'
' globals
'
Global GLDevices() As GLDEVICE
Global nGLDevices As Long


Function TBMain()
'
' main !!! close a border only window with [ALT] & [F4] !!!
'
Dim DeviceID As Long

'DeviceID = CreateGLDevice() ' no border
DeviceID = CreateGLDevice(320,200, "", 32, 16, 0, 0) ' border no caption
'DeviceID = CreateGLDevice(,,"no size")
'DeviceID = CreateGLDevice(32000,20000,"large resizeable")
'DeviceID = CreateGLDevice(32000,20000,,24,16)
'DeviceID = CreateGLDevice(320,200,"16 BPP no DepthBits",16)
'DeviceID = CreateGLDevice(320,200,"16 BPP 16 DepthBits",16,16)
'DeviceID = CreateGLDevice(320,200,"24 BPP 32 DepthBits",24,32)
'DeviceID = CreateGLDevice(,,"24 BPP 32 DepthBits 8 StencilBits",24,32,8)

End Function

CallBack Function cbWindow()
Static DeviceID As DWord
Static rtri As Single
Static rquad As Single

Select Case Callback_Message
Case %WM_INITDIALOG

Dialog Set Timer CBHNDL, %myTimer, %timeOut, %NULL

Local tmpWin,tmpDC,tmpRC,iPixFormat, width, height As Long
Local ColorBits, DepthBits, StencilBits, AccumBits As Byte
Local tmpPF As PIXFORMAT


tmpDC = GetDC(Callback_Handle)
If tmpDC=NULL Then
MsgBox NULL,"error: get device context !"
Dialog End tmpWin
Return 0
End If

Dialog Get User tmpWin, 1 To ColorBits
Dialog Get User tmpWin, 2 To DepthBits
Dialog Get User tmpWin, 3 To StencilBits
Dialog Get User tmpWin, 4 To AccumBits

InitPixFormat(tmpPF, _
ColorBits, _
DepthBits, _
StencilBits, _
AccumBits)
iPixFormat=ChoosePixelFormat(tmpDC,tmpPF)
If iPixFormat<1 Then
MsgBox NULL,"error: choose pixel format !"
ReleaseDC(tmpWin,tmpDC)
Dialog End tmpWin
Return 0
End If

If SetPixelFormat(tmpDC,iPixFormat,tmpPF)=0 Then
MsgBox NULL,"error: set pixel format !"
ReleaseDC(tmpWin,tmpDC)
Dialog End tmpWin
Return 0
End If

tmpRC=wglCreateContext(tmpDC)
If tmpRC=NULL Then
MsgBox NULL,"error: create render context !"
ReleaseDC(tmpWin,tmpDC)
Dialog End tmpWin
Return 0
End If

If wglMakeCurrent(tmpDC,tmpRC)=0 Then
MsgBox NULL,"error: make render context as current !"
wglMakeCurent(NULL,NULL)
wglDeleteContext(tmpRC)
ReleaseDC(tmpWin,tmpDC)
Dialog End tmpWin
Return 0
End If

' ok :-)
DeviceID=AllocGLDevice()
Dialog Get Size Callback_Handle To Width, Height

With GLDevices(DeviceID)
.PF.nSize = 40
.PF.nVersion = 1
DescribePixelFormat(tmpDC,iPixFormat,.PF,40)
.hWin = tmpWin
.hDC = tmpDC
.hRC = tmpRC
.Width = Width
.Height = Height
End With

If DeviceID=0 Then
MsgBox "error: can't create GLDevice !"
Dialog End Callback_Handle
End If

With GLDevices(DeviceID)
glViewport 0, 0, .Width,.Height
glMatrixMode %GL_PROJECTION
glLoadIdentity
gluPerspective 45.0, .Width/.Height, 0.1, 100.0
End With

glMatrixMode %GL_MODELVIEW
glLoadIdentity

glShadeModel %GL_SMOOTH
glClearColor 0.0, 0.0, 0.0, 1.0
glClearDepth 1.0
glEnable %GL_DEPTH_TEST
glDepthFunc %GL_LEQUAL
glHint %GL_PERSPECTIVE_CORRECTION_HINT, %GL_NICEST

Case %WM_ERASEBKGND
Return -1
Case %WM_TIMER

glClear %GL_COLOR_BUFFER_BIT Or %GL_DEPTH_BUFFER_BIT
glLoadIdentity
glTranslatef -1.5, 0.0, -6.0
glRotatef rtri, 0, 1, 0
glBegin %GL_TRIANGLES
glColor3f 1.0, 0.0, 0.0
glVertex3f 0.0, 1.0, 0.0
glColor3f 0.0, 1.0, 0.0
glVertex3f -1.0, -1.0, 0.0
glColor3f 0.0, 0.0, 1.0
glVertex3f 1.0, -1.0, 0.0
glEnd

glLoadIdentity
glTranslatef 1.5, 0.0, -6.0
glColor3f 0.5, 0.5, 1.0
glRotatef rquad, 1, 0, 0
glBegin %GL_QUADS
glVertex3f -1.0, 1.0, 0.0
glVertex3f 1.0, 1.0, 0.0
glVertex3f 1.0, -1.0, 0.0
glVertex3f -1.0, -1.0, 0.0
glEnd
rtri += 1
rquad += 2
SwapBuffers(GLDevices(DeviceID).hDC)

GetAsyncKeyState(-1)
If GetAsyncKeyState(%VK_ESCAPE) Then Dialog End Callback_Handle

Case %WM_SIZE
Dialog Get Client Callback_Handle To GLDevices(DeviceID).Width,GLDevices(DeviceID).Height
With GLDevices(DeviceID)
glViewport 0, 0, .Width,.Height
glMatrixMode %GL_PROJECTION
glLoadIdentity
gluPerspective 45.0, .Width/.Height, 0.1, 100.0
glMatrixMode %GL_MODELVIEW
End With

Case %WM_CLOSE
Dialog Kill Timer CBHNDL, %myTimer
FreeGLDevice(DeviceID)

End Select

End Function

'
' sub's / functions
'
Sub InitPixFormat(ByRef PF As PIXFORMAT, _
ByVal ColorBits As Byte, _
ByVal DepthBits As Byte, _
ByVal StencilBits As Byte, _
ByVal AccumBits As Byte)
' 8/16/24/32
ColorBits = (ColorBits +7) And &H38
DepthBits = (DepthBits +7) And &H38
StencilBits = (StencilBits+7) And &H38

With PF
.nSize = 40
.nVersion = 1
.dwFlags = %PFD_DRAW_TO_WINDOW Or _
%PFD_SUPPORT_OPENGL Or _
%PFD_DOUBLEBUFFER
.iPixelType = %PFD_TYPE_RGBA ' 0
.cColorBits = ColorBits
.cDepthBits = DepthBits
.cStencilBits = StencilBits
.cAccumBits = AccumBits
.iLayerType = %PFD_MAIN_PLANE ' 0

End With
End Sub

Function AllocGLDevice() As Long
Dim found,i As Long
If nGLDevices>0 Then
For i=1 To nGLDevices
If GLDevices(i).hRC=NULL Then
found=i
End If
Next
End If
' return free device index
If found>0 Then Return found
' alloc new device
nGLDevices+=1
ReDim Preserve GLDevices(nGLDevices)
Return nGLDevices
End Function

Sub FreeGLDevice(ByRef index As Long)
If nGLDevices<1 Then Return
If index<1 Then Return
If index>nGLDevices Then Return

With GLDevices(index)
wglMakeCurrent(NULL,NULL)
wglDeleteContext(.hRC)
.hRC=NULL
ReleaseDC(.hWin,.hDC)
.hDC=NULL
Dialog End .hWin
.hWin=NULL
End With
index=0
End Sub

Function CreateGLDevice(Optional _
ByVal Width As DWord , _
ByVal Height As DWord , _
ByVal Title As String, _
ByVal ColorBits As Byte , _
ByVal DepthBits As Byte , _
ByVal StencilBits As Byte , _
ByVal AccumBits As Byte) As Long

Dim Style As DWord Value %WS_POPUP Or _
%WS_VISIBLE Or _
%WS_CLIPSIBLINGS Or _
%WS_CLIPCHILDREN Or _
%WS_DLGFRAME Or _
%WS_SYSMENU
Dim MaxWidth,MaxHeight,X,Y,index As Long
Dim tmpWin As DWord

Desktop Get Client To MaxWidth,MaxHeight
' adjust optional params
If ColorBits<8 Then ColorBits=8



If Width =0 Then Width = MaxWidth /2
If Height =0 Then Height = MaxHeight/2
If Len(Title) Then
Style = Style Or _
%WS_CAPTION Or _
%WS_MINIMIZEBOX Or _
%WS_MAXIMIZEBOX
End If
If Width >MaxWidth Then Width =MaxWidth
If Height>MaxHeight Then Height=MaxHeight

' centered
If Width <MaxWidth Then x=MaxWidth /2-Width /2
If Height<MaxHeight Then y=MaxHeight/2-Height/2

tmpWin = Dialog_New(Pixels,NULL, Title, _
x,y, width,height, _
Style,%WS_EX_APPWINDOW)
If tmpWin=NULL Then
MsgBox NULL,"error: create new window !"
Return 0
End If

Dialog Set User tmpWin, 1, ColorBits
Dialog Set User tmpWin, 2, DepthBits
Dialog Set User tmpWin, 3, StencilBits
Dialog Set User tmpWin, 4, AccumBits

Dialog Show Modal tmpWin, Call cbWindow

End Function

Sub GLDeviceSwap(ByVal index As Long)
If nGLDevices<1 Then Return
If index<1 Then Return
If index>nGLDevices Then Return
With GLDevices(index)
SwapBuffers(.hDC)
End With
End Sub


Looking forward to stencil shadows!


Petr

D.J.Peters
05-03-2010, 12:28
thanx Petr i will try your version



Looking forward to stencil shadows!

Petrhere you can see why it is important to get the matrix from TBGL entities.

Joshy

Petr Schreiber
05-03-2010, 12:36
Looks good!

As the matrix is composed by vectors for x, y, z axis + position, you can extract it from entities even now.

TBGL_EntityGet<N>Axis serves to retrieve each axis coordinates + TBGL_EntityGetPos the position.

I will add function to return whole matrix, it will be useful both for graphics and physics.


Petr

P.S. Math module already allows operations on matrix, using simple syntax.

Petr Schreiber
05-03-2010, 14:01
TBGL_EntityGetMatrix developed, will be present in next release.

Michael Hartlef
05-03-2010, 19:18
Which release? 2.x or 1.8?

Petr Schreiber
05-03-2010, 19:27
Hi Mike,

1.8, but it is really last feature for this line :)
It is already developed and documented.


Petr

Michael Hartlef
05-03-2010, 19:55
Ok, thanks for the info. And also good luck with the next line.