PDA

View Full Version : thinFX



kryton9
01-12-2006, 00:38
Having a problem. I am running a TBGL window full screen and having the dialog box show up, but I lose the mouse. Spent some time trying to figure it out, but have had no luck. I have a feeling openGL must hide it when in fullscreen mode. Is there a way to turn it on?

This is just the skeleton I have right now. Just trying to set it up in separate files, so a lot of the files are empty for the moment.

Petr Schreiber
01-12-2006, 01:51
Hi kryton9,

not OpenGL, but me personally :-[

I was thinking that when you are running fullscreen, you do it for maximizing performance and to see all graphic clearly, so cursor would block few pixels of the view :)

If this is problem, I can add it as option to next TBGL release.
Meanwhile, just modify thin.fx.v1.tbasic to this.
I use ShowCursor to switch it on.



'---Information in thin.fx.readme.txt
#INCLUDE "thin.fx.inc"
Uses "TBGL"
Uses "UI"

Dim hWnd, hDlg, Msg, wparam, lparam As Dword

' ************
DECLARE FUNCTION ShowCursor LIB "USER32.DLL" ALIAS "ShowCursor" (BYVAL bShow AS LONG) AS LONG
' ************

hWnd = TBGL_CreateWindow("invisible",1024,768,32)
TBGL_ShowWindow

' ************
ShowCursor 1
' ************

DIALOG NEW PIXELS , 0, "thinFX v1 - ESC to exit", 0, 0, 200, 400, %WS_SYSMENU, 10 TO hDlg
DIALOG SHOW MODELESS hDlg

GetAsyncKeyState(%VK_ESCAPE)

While IsWindow(hWnd)

tbgl_ClearFrame

tbgl_DrawFrame

If GetWindowKeyState( hWnd, %VK_ESCAPE) Then Exit While

Msg = GetMessage(hDlg, wParam, lParam)

select case Msg
CASE %WM_COMMAND
SELECT CASE wParam
case 100

end select

CASE %WM_SYSCOMMAND
if wParam = %SC_CLOSE then EXIT WHILE

END SELECT
Wend
' ************
DIALOG END hDlg
' ************
TBGL_DestroyWindow


I'm sorry for confusing you.
I also added DIALOG END before script ends to clean up.
TBGL_DestroyWindow kills only TBGL window.


Bye,
Petr

kryton9
01-12-2006, 03:26
THanks Petr, that is wonderful and thanks for pointing out things I don't know about in thinBasic, which is really quite a lot. But I jumped in knowing you guys are very helpful and will help me learn while I try to do good things. Never apologize for teaching me or pointing out mistakes, the only way to learn..I appreciate it.

This process gives me a good start now for a few more hours of putting this together to play with, thanks again.

kryton9
01-12-2006, 08:19
I am very happy with the help you gave Petr, although it is very simple at the moment, the main thing is the test passed.
That is a test to see if we can use a control and have it update the TBGL screen without having to use a set button each time.
So I was very happy that this all works. That means our goal to make these kind of tools will work.

I got a strange bug though that now the clean up program subroutine doesn't work as it used to. I think sening messages might
mess it up somehow.

Anyways, I thought while thinFX and our other tools are in early stages might as well keep the chatter for development here
compared to coding monkeys and then we are at a version that does something take it over there so the other users will not
get bombarded with posts from us back and forth in for them maybe not interesting converstion, although for us it is. But when
something is fun to play with that everyone can enjoy then we can put it there and talk there.

I know the program is going to be huge, so I want to plan a way to break it into smaller units as i am doing now. So that you can get
to code right away. This way in the correct inc file then you can use the sub function box to find the routine right away. On the other hand it is a pain not having everything in one place. Which way would you prefer. With bookmarking coming in the next version of thinAir, I know I can work either way. For now I will continue this way, till we decided one way or another.

Are you going to turn your panel shrinking work into subs or functions we can use, or do you want me to work on that from your code?
I think it will prove very beneficial for all the work we plan to do. I guess we can wait to see what Eros does with the tabs too as that might solve the problem too. Well need to head off to sleep. I am excited to see this kind of dynamic updating working with sending messages. The new zip is attached.

ErosOlmi
01-12-2006, 09:02
I kryton9.

First thanks a lot for your efforts with thinBasic. Your development is helping us to improve thinBasic and fix/tune a lot of things.

Regarding message pump on TBGL window, I'm trying to find a solution with Petr in order to inject UI module message pump to TBGL window. Still not working well together but I'm quite confident we will reach a good point.

On the problem you are facing, see if this will help.
Mainly it moves TBGL logic into "idle" time of main dialog window instead of being outside. In this way main window is able to get all the messages and TBGL window is updated only during "idle" time of dialog:


While IsWindow(hWnd)


Msg = GetMessage(hDlg, wParam, lParam)
select case Msg
case %WM_INITDIALOG
PlaceControls 'subs

CASE %WM_COMMAND
SELECT CASE wParam
'case 100

end select

CASE %WM_SYSCOMMAND
if wParam = %SC_CLOSE then EXIT WHILE

case else
tbgl_ClearFrame
tbgl_Camera 0,0,3,0,0,0
DrawScene 'subs
tbgl_DrawFrame
If GetWindowKeyState( hWnd, %VK_ESCAPE) Then Exit While

END SELECT
Wend

Petr Schreiber
01-12-2006, 11:51
Hi,



Are you going to turn your panel shrinking work into subs or functions we can use, or do you want me to work on that from your code?


I promised I'll do it, so please consider it done till end of this weekend :)

Bye,
Petr

ErosOlmi
01-12-2006, 12:53
Another little change can be to get screen resolution from DESKTOP GET functionality like:

SUB MakeWindows()
LOCAL x as long
local y as long
local d as long
'---set your screen resolution here
'DESKTOP GET client TO x, y '---To get client area only
DESKTOP GET size TO x, y '---To get full screen resolution
d = 32

hWnd = TBGL_CreateWindow("invisible",x,y,d)
TBGL_ShowWindow
ShowCursor 1 'declares

x = 200 : y = 480
DIALOG NEW PIXELS , 0, "thinFX Tests", 0, 0, x, y,_
%WS_SYSMENU, 10 TO hDlg
DIALOG SHOW MODELESS hDlg
END SUB


BUT PLEASE WAIT NEXT thinBasic update because there was a bug in DESKTOP GET functionality :-[

Sorry
Eros

Petr Schreiber
01-12-2006, 13:16
Good idea Eros,

this will ensure safer execution ( in case of (unprobable) script crash no problem with recovering to previous resolution, although TBGL should cover this already ).

Nice second sample kryton !


Petr

kryton9
01-12-2006, 21:38
Thanks guys I woke up and found all of this great useful info. Thanks for your efforts, I am really enjoying working in thinBasic and a lot of that is working with great guys as yourselves.

No rush Petr, I know you are in school, I was just wondering if it was on your list or if you wanted me to start it. Studies always come first in my book. Glad to know it is on your list, work on it when you feel like it, if the weekends are your only time off, spend it doing what you look forward to doing.

Having thinBasic this interactive with the user is really making me happy. That sort of interaction, the user moves a slider and the impact is seen right away is something I think really adds to professional quality.

I have a strange idea I will test next, that is just to have the minimal contols, and have just mode buttons for the various properties. I guess the only way to know will be to try it. Hope to have something else to look at in a day or 2 as the weekend evenings are game night for me and my friends here online.

Thanks for the code samples Eros, it helps me to program better and to understand more. And Petr, don't feel rushed on the panel functions, do them when in the mood, spend your weekend working on what you looked forward to :)

Petr Schreiber
01-12-2006, 23:50
Hi kryton9,

no problem for me. I have something usable yet, but I am still not sure if it is enough.
So there is typical dilemma :):

keep it simple ( few commands with few parameters ), but knowing the sections must be one below another
... or make it more complex allowing placing the section anywhere in dialog, but with need for extra manual definitions ?

What do you think ?


Petr

kryton9
02-12-2006, 04:30
Petr, If I understand correctly, the way your samples ones were presented would be the simple version... If so, that is more than enough I would think. I couldn't figure out how else it could be, so you must be thinking of something I haven't seen to imagine how else it could work. So I will leave it up to you. Not knowing, I would say do the simple one and if you find it not enough for what you would like to do then you can make that in the future. Sorry not much help, but all I can think at the moment.

Petr Schreiber
02-12-2006, 20:31
Hi kryton,

thank you !
So here comes the latest version of "panels".
As you wanted, all functions are inside include file.

I have also arranged some serious bugs old version had and added new statement to process user interaction.
Also section ID is not generated as 1000 for first, 2000 for second ... but as 10001, 10002 ... This will allow more sections, and less troubles with ID conflict I think.
I hope you will find it comfortable :)

Bye,
Petr

kryton9
02-12-2006, 21:53
Thanks Petr, I downloaded it and will take a quick look. Won't be able to really look at till later tonight as have to go out, but thanks in advance. I will put it to good use, I promise. I know it will really be very very useful in not worrying about having too many controls, this unit you did is very valuable, thanks!! Can't wait to come home and start using it.

kryton9
02-12-2006, 22:22
Just browsed through it, WOW!!! Absolutely beautiful. Will be so easy to use and such a pleasure, thanks so much Petr. Great looking code and so well organized, Wish I didn't have to go out so I can start using it right away, well later tonight will come soon enough. Thanks so much again, a super wonderful addition!!!

Petr Schreiber
02-12-2006, 22:32
:),

I am happy you found it ok.
looking forward to see how you will use it in your scripts !

Thanks,
Petr

kryton9
06-12-2006, 07:27
I have been trying out various ideas for interfacing via a form with the designer of the effects. All of these are just partial ideas as I abandonded them before putting all the required fields. But it helps as tonight it occured to me, like the position trackbars, can need very different range values, I was just assuming it will be at 0,0,0 for developing in, but if it is to tie into the final game, then it could anywhere in a world, so I need to add range min and max values to lots of these so the user has total control. But even without fitting all the fields in you can see that it is becoming quite huge. See the attached jpg.

So another idea occured to me, using dos type help, or like help from the old days. Use the function keys as a main menu and then the user just presses a number for the value he wants to change. I will work on that and it will be good because I will get to start programming with TBGL and learn more. Hope to have an idea and something to look at by the end of this weekend. So for now, I am putting using forms away at least for thinFX and trying this other idea now.

Petr Schreiber
06-12-2006, 14:19
Hi kryton9,

thanks for the screens !
I think when tabbing support will be present in thinBASIC, most of problems with space will disappear.

I'm not sure I understand your "dos type help" idea.
Do you mean to create dialog with complex menu, where by clicking some label you could set variable ?

Thanks,
Petr

P.S. Which tool did you used to create the right-most dialog, it has different look ?

kryton9
06-12-2006, 22:11
Petr, the one on the right is one I did in Turbo Delphi. It is the third in Turbo Delphi.
I was trying out your shrink panel, but it still needs the full size of all the panels open to make room for them to be placed. Even in Max, if you shrink all the panels you still have the main form still big, so it is not something you missed, it is just the way they work and really I don't know how else you could do it. I wanted to write this in case you are wondering why you don't see your great shrink panel in these.

Quick new idea I call DOS type Menu:

F1-Help F2-Position F3-Size F4-Rotation F5-Speed F6-Color F7-and so on for main sections

If F2 is pressed this would show up:
Mode$ would "Position"
Message would appear:
Position Mode
Select:
1 or B for Begin Position
2 or E for End Postion
Esc to go Back
User press 1:
Mode$ would be "Begin Position"
Message Appears:

Begin Position Mode

X Axis: Left / Right Arrow
Y Axis: Up / Down Arrow
Z Axis: CTRL+Up Arrow / CTRL+Down Arrow
Esc to go Back

As the user presses the keys the values would show up on the screen also.
The messages alpha can be adjusted to the users preference and even not display
for advanced users, once the learn the interface.
Like I said that is the plan, will see if it works out OK.
Can't wait to do work on this as it means TBGL coding finally!!!

kryton9
07-12-2006, 05:07
Petr, looking at some of your elegant TBGL code. I have a feeling I am making my ideas too complicated. In working with Unreal Editor for 2004 Tournament, I liked a lot of what I saw with it being OOP, but on the other hand the properties for all the objects were really huge and in many cases you never assigned values to the properties maybe 4 or 5 of them the most.

I am seeing that kind of bloat in my types for emitter and particle.

Just so you know what I m referring too. I am currently looking at your code for:
TBGL_ParticlesMiniDemo.tbasic(pmd) and what you did with particle_experiment.tbasic(pe)

I like the simplicity and elegance of pmd, your nice whole program is shorter than my stupid type definition for an emitter :)
That right there tells me something is wrong with my solution so far and efforts.

PE is interesting in using the EVAL module, but if you notice the program is quite a bit longer, using EVAL has lots of overhead it seems and loses some of the elegance of PMD. On the other hand there is lots of form code in PE and so that could be misleading.

Anyways I am going to study these too and try to come up with a solution based on these fine examples you made.
I will try to put a system of flexibilty to these elegant examples you made.

kryton9
07-12-2006, 06:06
Ok here is the thought, we make a type as:
formula as string
x,y,z,a,b,c,i,j,k as variant

this way we could have up to 9 variables per formula that can be adjusted dynamically via sliders or spinner or direct input.
I am going to modify your eval example and see if I can make this work, let me know what you think of this idea. You don't need all nine variables you can use up to 9, I can't imagine more than that being needed in a formula, can you? We can make it whatever you think the most we would need be.

hmm while writing this came up:
x y z for position, vx, vy, vz for velocity, rx, ry, rz for rotation, sx, sy, sz for size, r, g, b, a for color and alpha, 15 variables so far, oh... time... so t1, t2, t3, d1, d2, d3 for 3 divisors, f1, f2, f3 for factor? so about 24 variables, the user can use any or all, so will need to come up an interface idea for that. and of course the lines for the formula entry.

I will wait to hear your thoughts about this since it has been almost 30 years since I took any math, of course I read up on it on the web and learning all my 3d math that way, but I am sure you will have more ideas on variables and how many and what we can name them. I hope I explained the concept correctly.

theses variables will be availabel for any formula as you used in particle_experiment.tbasic. We can add more lines to cover all aspects of a particle.

Petr Schreiber
07-12-2006, 15:05
Hi kryton9,

thanks !
The power of EVAL module is you can make expressions on the fly, for the final editor it may not be needed, but I wanted to test it out. It is good module I think.

Your thoughts are very interesting, I'm still not sure if we took the easiest part of engine for the start ;D.
I must put it on paper and think it again.

I'm not sure what you mean by "factors" and "divisors" now. Could you explain it please ? Do they both apply to time handling ?


Bye,
Petr

P.S. Still seeking for UE videos, hope I will have better luck on video.google.com or youtube.

kryton9
07-12-2006, 21:02
yes imagine your formulas you used, instead of using fixed values to type in the line, they would be variables that the effect designer could alter via controls. FOr example your formula here: cos( time/1000 + i * 10 )* 10"

could be, that is the effect designer has these variables at his disposal to work with, we could even make an expression builder with the keywords that eval understands and variables they can use.

cos (t1/d1 + i * f1) *f2
sliders controls for with an edit box so direct entry could be made also would be made then for:
t1
d1
f1
f2
i would need to be a fixed variable to represent a particle in the array, maybe pnum or something.

Petr Schreiber
07-12-2006, 22:32
Hi kryton9,

Your ideas are really great!
The number of slides could be in some way dynamic to the variables used in expression, to save dialog space.

Maybe I could study tokenizer functions more deeply. Maybe user ( designer person ) could type any variable names in, and we could get the names and handle it internally in some array or whatever.

The system vars could be then:
* time [ms]
* pnum [-]

My idea is to have some XYZ,SIZE, ROTATE formula setup in one dialog, and then you could apply it like "Apply for particles 1 TO 30, 32 TO 64".

Thanks a lot,
Petr

P.S. Regarding panels - I could add something like "ending panel" which would clip rest of Y size of dialog at real time. Don't know if it could really help, but it just occured to me.

kryton9
07-12-2006, 23:51
I am glad you are seeing what I got from looking at your examples and trying to make it dynamic as you say.
Also if we make a formula expression builder we could have the following:

1. Eval recognized commands (keywords)
2. For Now I will call these System Variables, these could be variables we would decide upon to represent system values, like time elapsed, start time, etc.
3. Game Engine Variables, these would be other variables from our game engine that would be known as globals and accessible formulas and procedures, like the max number of particles, current particle, whatever we come up with

4. Then there would be the user variables that the user can use in the formulas. If we could make it so it could be any name that was not taken for a variable that would be neat.

We could also have predefined formula templates they could start with too, maybe from a list or option selection or combo box.
I think this way it will be very efficient all the way around.

I was even thinking of making it all in opengl sort of how blender has their controls, so I am working with text, then panels and such and maybe a routine to mimic a slider control all in opengl for a very slick interface. Programming should be as fun as playing or making the game :)

kryton9
12-12-2006, 06:11
Petr, can you program in C and C++. The reason I am asking is with so many libraries and engines out there, maybe we should look at and evaluate some to see what we could use as a base for our stuff to build off of. As I am making tests and I am sure you are too you can see that even if you we use such libraries putting together a nice engine for thinBasic will still be a tremendous amount of work. What do you think?

If you like the idea we can try out different libraries and once we find something we like, we can work on making modules then as nice basic keywords for thinBasic, sort of how you did tbgl. Let me know your thoughts. And good luck with your tough schedule the next few days.

This part is a few hours later after the first part:
I decided since we are doing just some tests, to combine all of thinFX back into one file instead of separate files for now. It will just make it easier while we test. It will be easy enough to separate once we have something to save. This way everything is easy to get to using Roberto's cool dropdown box for the subs and functions. Just CTRL+HOME to get to the program and use the dropdown to get to anywhere else.
@Petr, Eros or Roberto
Anyways, I am having a strange problem with the alpha for the control window. I don't know where we can put the code to make it stop flickering.
The 2 subroutines that are involved are MakeWindows and CheckSliders. As you will see I commented out the line in MakeWindows so that it won't flicker till the user uses the slider. Then you have to remember where the close box was on the window or you can just do ALT+F4 to exit out.

Well here is the source, once this is solved will work on using your panels to add the eval and some dynamic sliders to play with:)

includes
constants
types
globals
declarations
'+--------------------------------------------------------------------------------------------------------------------+
'| program start |
'+--------------------------------------------------------------------------------------------------------------------+
makewindows
getasynckeystate(%vk_escape)
while iswindow(hwnd)
msg = getmessage(hdlg, wparam, lparam)
select case msg
case %wm_initdialog
placecontrols
case %wm_hscroll
checksliders
case %wm_command
select case wparam
'case 100
end select
case %wm_syscommand
if wparam = %sc_close then exit while
case else
tbgl_clearframe
tbgl_camera 0,0,3,0,0,0
drawscene
tbgl_drawframe
if getwindowkeystate( hwnd, %vk_escape) then exit while
end select
wend
cleanupprogram
'+--------------------------------------------------------------------------------------------------------------------+
'| program end |
'+--------------------------------------------------------------------------------------------------------------------+
sub declarations()
'---mouse related
declare function ShowCursor lib "user32.dll" alias "ShowCursor" (byval bshow as long) as long
declare function GetCursorPos lib "user32.dll" alias "GetCursorPos" (lppoint as txy) as long
declare function ScreenToClient lib "user32.dll" alias "ScreenToClient" (byval hwnd as dword, lppoint as txy) as long

'---translucent window related
declare function SetWindowLong lib "user32.dll" alias "SetWindowLongA" (byval hwnd as dword, byval nindex as long, byval lnewlong as long) as long
declare function SetLayeredWindowAttributes lib "user32.dll" alias "SetLayeredWindowAttributes" (byval hwnd as dword, byval crkey as dword, byval balpha as byte, byval dwflags as dword) as long
declare function GetWindowLong lib "user32.dll" alias "GetWindowLongA" (byval hwnd as dword, byval nindex as long) as long
end sub

sub includes()
uses "tbgl"
uses "ui"
end sub

sub constants()
local c as integer = 10
%hdlgalphaslider = c: c += 1
%hdlgalphaslidertextbox = c: c += 1
end sub

sub types()
type txy
x as double 'position on x axis or x value
y as double 'position on y axis or y value
end type

type txyv
x as double 'position on x axis or x value
y as double 'position on y axis or y value
v as double 'velocity
end type

type txyz
x as double 'position on x axis or x value
y as double 'position on y axis or y value
z as double 'position on z axis or z value
end type

type txyzv
x as double 'position on x axis or x value
y as double 'position on y axis or y value
z as double 'position on z axis or z value
v as double 'velocity
end type

type trgb
r as integer 'red color
g as integer 'green color
b as integer 'blue color
end type

type trgba
r as double 'red color
g as double 'green color
b as double 'blue color
a as double 'alpha value
end type

'---petr schreiber's collapse panel
type tsection
cid as long ' control id

numcontrols as long ' number of controls in section
hide as long ' section is hidden ? 0 = no, 1 = yes

oweshift as long ' info for colapsing and expanding
posy as long ' y position in dialog
hdialog as long ' parent dialog handle
end type
end sub

sub globals()
global hwnd, hdlg, msg, wparam, lparam as dword
global hdlgalphasliderid as long
global csection(32, 64) as tsection ' max 32 sections, max 64 controls for each; this is resized automatically when needed
global csectionwidth as long
global csectionnum as long
end sub

sub makewindows()
local x,y,d integer
'---set your screen resolution here
x = 1440 : y = 900 : d = 32
hwnd = tbgl_createwindow("invisible",x,y,d)
tbgl_showwindow
showcursor 1 'declares

x = 200 : y = 480
dialog new pixels , 0, "thinfx tests", 0, 0, x, y,_
%ws_sysmenu, 0 to hdlg
'SetWindowLong hDlg, %GWL_EXSTYLE, GetWindowLong(hDlg, %GWL_EXSTYLE)OR %WS_EX_LAYERED
'SetLayeredWindowAttributes hDlg, 0, 255, %LWA_ALPHA
dialog show modeless hdlg
end sub

sub placecontrols()
control add textbox , hdlg, %hdlgalphaslidertextbox, "textbox"+str$(%hdlgalphaslidertextbox), 4, 40, 192, 24
control add "msctls_trackbar32", hdlg, %hdlgalphaslider, "sliderh"+str$(%hdlgalphaslider), 4, 4, 192, 32,_
%ws_child or %ws_visible or %tbs_autoticks
control handle hdlg, %hdlgalphaslider to hdlgalphasliderid
control send hdlg, %hdlgalphaslider,%tbm_setlinesize, 0, 5
control send hdlg, %hdlgalphaslider,%tbm_setticfreq, 5, 0
control send hdlg, %hdlgalphaslider,%tbm_setrange,1 , maklng(0, 255)'min 0 ,max 255
control set focus hdlg, %hdlgalphaslider
end sub

sub drawscene()
local r integer
r = sendmessage (hdlgalphasliderid, %tbm_getpos, 0, 0)
control set text hdlg, %hdlgalphaslidertextbox, "the curent red value: "+str$(r)
tbgl_beginpoly %gl_triangles
tbgl_color r, 128, 0
tbgl_vertex -1,0,0
tbgl_vertex 1,0,0
tbgl_vertex 0,1,0
tbgl_endpoly
end sub

sub cleanupprogram()
dialog end hdlg
tbgl_destroywindow
end
end sub

'---call this first to specify dialog width, section width will be derived from this
sub section_init( dialogwidth as long )
csectionwidth = dialogwidth - 10
end sub

'---assigns control to section
sub section_assign( section as long, ctrl as long )
csection(section,1).numcontrols += 1
local n as long = csection(section,1).numcontrols
if n > ubound(csection(2)) then redim preserve csection( ubound(csection(1)), n )
csection(section,n).cid = ctrl
end sub

'---creates new section
function section_new( hdialog as long, sname as string, y as long )
incr csectionnum
if csectionnum > ubound(csection(1)) then redim preserve csection( csectionnum, ubound(csection(2)))
control add label, hdialog, 10000+csectionnum, sname, 5, y, csectionwidth, 15, %ss_center or %ss_centerimage or %ws_border or %ss_notify
control set color hdialog, 10000+csectionnum, rgb(0,0,0), rgb(255,128,0)
csection(csectionnum,1).posy = y
csection(csectionnum,1).hdialog = hdialog
function = 10000+csectionnum

end function

'---collapses section
sub section_collapse( section as long )
local posmoveby as long
local j,k,l as long
local x,y as long
posmoveby = csection(section+1,1).posy-(csection(section,1).posy+20)
csection(section,1).oweshift = posmoveby
for j = 1 to csection(section,1).numcontrols
control get loc csection(csectionnum,1).hdialog, csection(section,j).cid to x,y
control set loc csection(csectionnum,1).hdialog, csection(section,j).cid, x+10000,y
control disable csection(csectionnum,1).hdialog, csection(section,j).cid
next
for j = section+1 to csectionnum
for l = 1 to 10
control set loc csection(csectionnum,1).hdialog, 10000+j, 5, csection(j,1).posy - posmoveby/10*l
control redraw csection(csectionnum,1).hdialog, 10000+j
for k = 1 to csection(j,1).numcontrols
if csection(j,k).cid = 0 then iterate for
control get loc csection(csectionnum,1).hdialog, csection(j,k).cid to x,y
control set loc csection(csectionnum,1).hdialog, csection(j,k).cid, x,y-posmoveby/10
control redraw csection(csectionnum,1).hdialog, csection(j,k).cid
next
sleep 5
next
csection(j,1).posy = csection(j,1).posy - posmoveby
next
end sub

'---expands section
sub section_expand( section as long )
local posmoveby as long
local j,k,l as long
local x,y as long
for j = 1 to csection(section,1).numcontrols
control enable csection(csectionnum,1).hdialog, csection(section,j).cid
control get loc csection(csectionnum,1).hdialog, csection(section,j).cid to x,y
control set loc csection(csectionnum,1).hdialog, csection(section,j).cid, x-10000,y
next
for j = csectionnum to section+1 step -1
for l = 1 to 10
control set loc csection(j,1).hdialog, 10000+j, 5, csection(j,1).posy+csection(section,1).oweshift/10
control redraw csection(j,1).hdialog, 10000+j
csection(j,1).posy = csection(j,1).posy+csection(section,1).oweshift/10
for k = 1 to csection(j,1).numcontrols
if csection(j,k).cid = 0 then iterate for
control get loc csection(j,1).hdialog, csection(j,k).cid to x,y
control set loc csection(j,1).hdialog, csection(j,k).cid, x,y+csection(section,1).oweshift/10
control redraw csection(j,1).hdialog, csection(j,k).cid
next
sleep 5
next
next
dialog redraw csection(section,1).hdialog
end sub

'---handles behaviour of all sections
sub section_behaviour( msg as long, wparam as long )
if msg = %wm_command then
local i as long
for i = 1 to csectionnum
if wparam = 10000+i then
csection(i,1).hide = csection(i,1).hide xor 1
if csection(i,1).hide = 1 then
section_collapse(i)
else
section_expand(i)
end if
end if
next
end if
end sub

sub checksliders()
local r integer
if lParam = Dialog_GetControl(hDlg, %hdlgalphaslider) then
r = sendmessage (hdlgalphasliderid, %tbm_getpos, 0, 0)
SetWindowLong hDlg, %GWL_EXSTYLE, GetWindowLong(hDlg, %GWL_EXSTYLE)OR %WS_EX_LAYERED
SetLayeredWindowAttributes hDlg, 0, r, %LWA_ALPHA
end if
end sub

I was playing around with the case tools in thinAir, I got to lazy to rewrite the code to upper and lower case, that is why it is mostly lowercase and some mixed.

Petr Schreiber
13-12-2006, 19:27
Hi kryton,

does it mean the dialog with slider flickers ?

I had no opportunity to test on XPs yet, only WinME with window alpha blend turned off ( commented out).
Maybe the way it works on XPs does not awaits the window "below" is redrawing very frequently.
I don't know, I will try to see it on my own on XP box.

Thanks for this experiments !

Bye,
Petr

kryton9
13-12-2006, 21:55
Yes this is on XP. I think you are right in the gl screen updating is causing the flicker, but not sure.

I installed thinBasic on my notebook after I did the dual boot setup on it. Anyways that is an ATI video card in there and it too crashes on the mouse with light lesson. So it could be an XP thing too then, as my Desktop has nvidia and the notebook ATI.

Fun doing these tests, I don't know why, I always doing stuff like this.

kryton9
14-12-2006, 05:28
Well got something going tonight, a foundation sort of... But I can see need a major rewrite is needed. I want to make this thing really flexible, but you can see it is going to be fun. Need to plan it out more and allow maximum power to the user.

There are 7 textures to flip through and you can set the colors. I got Petr's collapse panel and particle demo from the mini demo into the code tonight. But now that I see that we can on the fly change settings and it updates fine. Getting lots of ideas while playing with it. Need to think how to make it neater and wide open with flexibility.

Petr, I am going to tackle as a full out test using my original idea of a big type for the particle, got rid of the emitter as it was making the particle, so eliminated duplicate work in the end. I want to push this idea as far as I can.

I placed the source and a few bmps I made tonight into a zip file.

I added some more stuff before going to bed, Petr, can you show me how to start with all panels collapsed. I guess I am sleepy, been trying, I can have them collapsed, but when you click they never expand after that. So I am missing something, heading off to sleep.Thanks.

Petr Schreiber
14-12-2006, 21:42
;)

this looks cool !
I will seek for the way to make them collapsed from start, hope to post it very very soon.

Thanks a lot,
Petr

kryton9
14-12-2006, 21:49
That will be great, thanks Petr.

Petr Schreiber
14-12-2006, 22:28
Hi kryton9,

may I modify your code to cause less message traffic ? It could increase a speed and reduce flicker.
The inital collapse will need little tweak from my side too :)

Petr

Petr Schreiber
14-12-2006, 23:41
Hi kryton,

as you are I silent, I presume yes ;)
Please see new version in attachment.

What's new ?

Speed - original version ran on my PC about 6-10 FPS due to frequent message queries, new version goes 50 FPS !
... checksliders procedure made faster - no need to retrieve control handle, as we know it from beginning. SELECT CASE is powerful for drop-one-then-out :) conditions.
Panels can be collapsed at start - my fault in design made this impossible/hard in old version
Program will start in users desktop size resolution automatically to prevent unexpected troubles


... jusy few notes more. Instead of TRIM$(STR$(number)) use just FORMAT$(number), it is faster.
On other side, I can see stuff like "Number is: "+STR$(number). As STR$() converts number to string AND adds leading space (" ") character, it would create double-space between ":" and number. I arranged that.

I like the thinFX very much, looking forward to next evolution !


Hope you will like tweaked version,
Petr

kryton9
15-12-2006, 03:05
Petr, thanks sorry I missed your earlier post, I was out of the apartment doing errands. Came home and found your present in terms of many new additions and tweaks, Thanks, can't wait to test it out and study your great work.

AS I worked on the program last night many new ideas came and I need to do a rewrite but will use most of this work in one way or another. Thanks, having the collapsing panels as you made them will be essential because there will be many options.

The main thing and easy way to explain it as I don't have the total picture in my mind yet, just ideas, is like how 3d Max handles modifications to objects. You can add the modifications dynamically, change the order in which they effect the object, remove them. I want to make the whole program like that.

The other thought is that our engine just be a core that knows how to handle plugins and all of the functionality is added via plugins by us and others who get into this stuff.

I never did plugins, but I have a feeling it would be like how thinBasic does modules. That is we make dll's that are the whole program module, so thinFX would be a plugin. The game engine can then read this plugin and offer its features.

I think if we worked in Delphi and with object oriented programming we can make this all work easier, but not sure. This is the direction of what I will be testing the next few days to see how far we can push it. I will read up on plug ins to see how they work, if you know any good links let me know.

The other nice thing if we could do this is to support animated textures or wmv files as textures and media files we can play in our engine. I know it is doable as Dark Basic Pro supports it, but since DBPro uses directx, that is what might allow it, I am not sure if opengl does or not. Any ideas?

Anyways off to test out your new code, thanks in advance. Will write again after I play with it and study it. Thanks!!

kryton9
15-12-2006, 03:13
Petr you are the man, and project leader for a reason!! That is awesome. What a peformance improvement and with messy code I provided as just trying to put it together quickly like building a frankenstein. You are amazing. Starting out collapsed with the panels is GREAT!! This way can have access to so much from the start.

It is so much fun working with you, what a pleasure, thanks so much!! Not only you too but to Eros and Roberto and Catventure. Makes working and hanging out here a real pleasure!!

Well off to do some crazy tests and see what other crazy ideas I can throw out. I just know by doing this we are going to have an incredible fun and powerful system in the end!!

kryton9
15-12-2006, 07:29
I was having more fun with your collapsable panels, while thinking I make them expand and collapse, it reminds me of those cool transporter rings they use on Stargate SG-1, looks really cool!!

Petr Schreiber
15-12-2006, 10:26
Thanks ;D,

your code was not messy, it was pretty easy to follow. It is just artifact in my head from calculator programming to not do more checking than necessary, so this was the reason I simplified messaging process.

Animated textures, hmm :)
There is even simplier way how to do it than trying to play some video.

Imagine texture where multiple animations are stored in "rows", each frame in "columns". Even Quake 3 has made fire animation this way. Then just shifting texture coordinates you can do some basic stuff.

But if you want repeated animated texture, you have to use multiple textures. I'll try to encapsulate it in few procedures and post here.

Regarding out engine as DLL, sure. We would just need to created DLLs and proper headers with declares for it.
I think it is good to use thinBASIC for the process of design of features now, then we can make it into the compiled module to get some extreme speed. thinBASIC script would just use #include to get functions "linked".

Yesterday was memorable day for me :D, as I finally got how OpenGL extensions work. So I was happily practising multitextured polygons in PowerBASIC for the first time in my life -> make it TBGL module should be easy, just need some time.


Bye,
Petr

kryton9
15-12-2006, 18:45
Petr, I am very happy you figured out another breakthrough. Sounds like we will have more cool goodies to play with. I have to run again to do some errands with my Dad, will write more later tonight my time. Thanks, the texure idea is a great solution about shifting the position to get the animated feel!! I will put that in as a programmable feature then.

More later when i get back, thanks again!!

Petr Schreiber
15-12-2006, 22:02
Hi kryton9,

hope your errands go OK.
Please see very basic texture animation demo attached to this post.

ErosOlmi
15-12-2006, 22:41
I've changed image to negative.
Seems some top pixels are from bottom.

Petr Schreiber
15-12-2006, 22:52
Hi Eros,

good eye ;).

This artifacts appear because of texture filtering. To perform filtering, OpenGL goes "over the corner" to get better results. Imagine white texture, which would have black borders just because it would filter border like interpolation between most left pixel and black...

In many cases this problems does not cause problems, here, I must agree, can.

To fix it, but get awful quality, you can use %TBGL_TEX_NEAREST instead of %TBGL_TEX_MIPMAP or %TBGL_TEX_LINEAR. The image won't be antialiased at all, but no artifacts should be visible.
I will seek for some work around, thanks !

Bye,
Petr

Petr Schreiber
15-12-2006, 23:02
I remember now,

but you will need to add this just after USES:


#include "%APP_INCLUDEPATH%thinbasic_gl.inc"


and this before main rendering loop:


glTexParameteri(%GL_TEXTURE_2D, %GL_TEXTURE_WRAP_S, %GL_clamp)
glTexParameteri(%GL_TEXTURE_2D, %GL_TEXTURE_WRAP_T, %GL_clamp)


This will make texture to be not able to be repeated, with precise filtering. So you can use %TBGL_TEX_MIPMAP.

What does it actually do?

%GL_TEXTURE_2D
is generally expression for 2D textures. This is only type of textures currently supported in TBGL.

%GL_TEXTURE_WRAP_S
%GL_TEXTURE_WRAP_T
Well, S and T are X,Y texture coordinates ( also known as U,V to make us all confused more ).

%GL_clamp
As the word says, it will "clamp" or "stretch" texture coordinates to interval [0,1]. This protects the reading pixel value from previous repetition. Opposite would be default %GL_REPEAT.

Questions :) ?

Bye,
Petr

ErosOlmi
15-12-2006, 23:20
I had one question but ... I forgot it :D

kryton9
16-12-2006, 00:30
I go out to do errands come back home and find another goodie to play with, thanks Petr. It will give me something to think about as we develop all of this.

I went to the library today while my Dad was at his meeting. Found some books on Delphi and DirectX. They have some on OpenGL, but they need to request it from another library in Florida. But I was impressed that they had books on the subject. They have a couple of openGL books for game development type books. I will research about them and then place an order for a book, so I can finally learn the ins and outs of opengl, hopefully.

It will be great to be able to use wmv files for video, imagine a big screen and you have the talking head of the dictator or emporer uttering propoganda like in the Half-Life 2 and other games I have seen. It really ads to the atmosphere to see things like that in a game.
But something we can aim for down the road, we got enough to do as it is :)

Anyways thanks for today's cool code and wow Eros does have a good eye. It took me awhile to notice the artififacting on his reverse image bmp.

ErosOlmi
16-12-2006, 09:32
Well, I'm just able to get very very little problems.
Petr is able to create so many beautiful examples in a snap! Thanks a lot Petr. Your work (and the speed you take to create it) always impress me.

Ciao
Eros

Petr Schreiber
16-12-2006, 16:26
Thanks Eros and kryton9 :)

Fixing small problems is also important, it helps to make things better. With my speed solution it is also not so hot, as this problem occured in the Forrest demo on skybox. So quite old one :-[ But I will try to solve problems ASAP.

Regarding OpenGL book, in my ( czech ) language only one book was released - and it was this autumn and it is just pure translation of OpenGL Red Book which is available for free :(. Only thing it has more was part about shaders, but covered on only 40 pages and with very few samples. Hope you will have better luck in library search.
Usually you can get lot of info from specialized magazines - luckily library near my house has covered even magazine stuff so it is good source to learn.

Bye,
Petr

kryton9
16-12-2006, 21:39
@Eros Eros, your work is the foundation for everything we are working with, so what is trivial to you is a key and important thing to us, so energy to you and a clear mind to keep doing the magic of thinBasic!!

@Petr Petr, you mentioned OpenGL extensions and having your breakthrough with them. What will they offer and can we provide the things so the user doesn't have to install anything? I will do some reading about them today, just to see if I can understand.
this part added later: Petr, while reading about gl extensions, then came upon this page. It sure sounds like something of use to us, what do you think? http://allegrogl.sourceforge.net/

I also looked at code last night, well in Delphi you an write to memory, that is draw to memory into a bmp and use it in your code or save it out to a file in bmp format. It would be neat to be able to draw in memory to a bmp in thinBasic and be able to use that code generated textures in our work. Do you have any ideas of how I can get started on this bringing this in, it might be in thinBasic already and I don't know about it.

@Petr, Eros
I have been doing tests on..... missed a simple error. Thanks. I found the problem, in my type for the controls, i had fields named keywords in thinBasic, I thought since they were part of a field in a UDT that the .min or .max would be safe, but that is what was causing the strange problem. I just put vmin and vmax and also a vsec for sec. Sleep does help in finding strange problems

kryton9
17-12-2006, 10:31
Petr, was reading about particles tonight. From my reading, it will be nearly impossible to have one simple interface for every type of effect possible with particles. I am thinking about breaking it up into smaller units, specific to the type of effect, many cool effects are made from mutiple different types of particles, so I am going to rethink about how to make it start small, but addable with modules or code and to generate the particle of each type that can then be combined to make the final effect. So it will be like thinParticleCreator, then thinFX, that uses paricle creator output to put the effect together. Need a shorter name for the first part, but you get the idea. thinEmitter and then thinFX that just came to me :)

On another note: I read about opengl extentions and in the paper they mentioned a lot of cool ideas that they use to keep files from overlapping. Mainly using prefixes. We need to come up with a naming scheme so similar procedures and files are not mixed up and our engine and other smaller co-engines know what to use and allow us to build up our stuff in useable modules/scripts.

So think about it, we are still doing tests and have many many more to do, but good to take a break and think about this stuff too :)

Petr Schreiber
17-12-2006, 18:53
Hi kryton9,

rush week starts tommorow, so I will be little bit telegraphic:

kryton9, as you have mentioned Half Life 2 and it's use of animated textures - I think the in-game screens where doctors are apearing or the guy with beard ( sorry, played just demo so don't know precise details, names... ) are done using rendering to texture, not AVI or WMV. So you make multipass scene, where you put the "studio" with actor somewhere, take snapshot into texture and this texture you than map to polygon in final scene. It is very handy stuff, TBGL_RenderToTexture is present in TBGL 0.1.7 but not documented as I have to improve and optimize it. I wanted to put here some sample script using this, but better to wait to version which will support it with no problems.
Dynamic textures, ( even programmed ) would be interesting, I was thinking about TBGL_m15SaveModel to save geometry done using script writing to model buffer too.

Extensions ... OpenGL 1.2 + ( approxiamtely ) is "extended" to next one using ... extensions :) If you have properly installed drivers for your card, you can reach them without problem.
But... for example my radeon 9600 has support for OpenGL 1.5. To use the extra functions, I need to call wglGetProcAddress function to get pointer to that function, if it is zero I have no support of it. Then I have to call it using "function prototype" which contains predefined parameters I can pass. All this I must do In PowerBASIC/C/... to invoke this feature. Quite complicated but the results are worth the trouble :)
TBGL module supporting this will have some simplified way to do this. But you must be more careful while coding it or at least test if the script is ran on architecture supporting all this features. So I have to invent some easy "checker" to do it for you. Good thing with this dynamic calls is that they won't produce "Missing export from OpenGL32.dll" and stop the application, it is up to programmer to decide if this missing feature can or must not be left out for the script run.

I will have a look at Allegro later, I'm very curious about it but I must have some stuff done first :(


Thanks,
Petr

kryton9
17-12-2006, 21:56
Petr, good luck this week. Concentrate on school and work, no worries if can't reply or write this week. I will do a lot more studying and not post much this week too then. Every day I start out with a test idea and it leads to 3 more ideas to test. So the days and time just fly by!! Anyways good luck!!