Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - tictac

#1
Thank you, but I need to combine objects at runtime.

QuoteYou can write such a combiner with the X_GETFACE commands.

It means there is no built-in function to make this?
Ok, thank you!
#2
Hello,

I need to create a lot of basic objects at runtime, in 3D, so I need to "group" (combine) objects to reduce the draw-calls.
Is there any native function in GLBasic to do that? Or is there someone who was able to create such function?

Thank you for help!
#3
Good! So I'm not so old!!!  =D :lol:
#4
Don't worry @Kitty, a genuine discussion is always welcome!  =)
(I'm 38, and I'm a programmer since when I was 13 (Texas Instruments TI-994A),
so imagine how many "discussions" I made in the time! =D )
#5
@Ocean, I fully agree with you  :booze:
#6
Hello,

First "interpretation": first block is shorter than second one  =)

One hint more... try to substitute this line in your code...

test = RND(3*360) - 360

With this one...

test = RND(100*360)

The problem is you didn't make a real world example, since you made a test calibrated for your algorithm. In fact, generating random numbers as you made, you created many numbers within 0..360, so no while..wend was made.
If you try to change the code with mine (real, pure range between 0 and 360000) the things are different...

MOD time calculation is always the same, instead your code (since it must execute many while..wend) takes a LONGER time.
In my computer these are the results:

1) With your original RND code ( test = RND(3*360) - 360 ):

--My Algorithm = 0.59 secs
--Your algorithm = 0.43 secs

2) With neutral code (  test = RND(100*360)  )

--My Algorithm = 0.59 secs
--Your algorithm = 1.46 secs

2) With neutral code (  test = RND(1000*360)  )
  (I incremented from "100" -> "1000")

--My Algorithm = 0.59 secs
--Your algorithm = 10.58 secs

Ok, now please believe me I don't want to create a "flame" in this topic. I only wanted to create a pure, simple, constructive discussion about code optimization.

Thank you!












#7
Generally speaking, loops and conditions are "slow", since the CPU must "brake" internal cache to load another piece of machine code. Statements that "jump", generally speaking, must be used only if the generated code can reside inside the CPU internal cache. Furthermore, other kind of "jumps", like function call, should be avoided in fast calculations, since they constrain the computer to store jumping point in the stack (to come back there later, with a "return" statement).
This is the reason it is better use passive calculations like "mod" and avoid to use IF, GOTO, GOSUB, FOR, WHILE, etc...
Statements like FOR are good for the programmer but not for performance.
Example, this block of code....

a = 0
FOR i=1 to 3
  a = a + 1
NEXT

is slower than...

a = 0
a = a + 1
a = a + 1
a = a + 1

Because linear programming allow better caching algorithms inside CPU.

Some heavy duty applications use very small (compact) algorithms (less than 1Mb) in order to put all the code inside CPU cache, or they try to manually split calculations in several threads executed over multiple CPUs  =)

#8
So I only need to add my file/library to the project, and it will be avaiable to the other files! Cool!

Thank you!

#9
Thank you! I tried to setup a higher resolution via IDe but it seems it does not work (I will try with the command).
About include: "handled automatically via IDE"? How? Is there any interface to setup include files? Do I need to put my libraries (to be included) in a specific place?

Thank you!
#10
Day by day I'm discovering this great product.
Now I found two "small" problems:

1) How can I include a source code inside another one (something like "include" or "import")?
2) Can I set screen resolution, Fullscreen, more than 1024x768?
3) Does GLBasic support video other than 4:3 (e.g.: 1024x600? 1440x900? 1680x1050?)

Thank you!

#11
Thank you, I will check it!

#12
Hello,

I cannot find a function to change screen resolution via code, how can I do it?
(for example, I want to let the user change game resolution).

Thank you (even without restarting the game!)
#13
Yes, I think automatic wrapping (for the functions) is a good feature, but a real programmer must take full control of its application.
Thank you because I discovered even fmod and not only mod  :booze:

#14
Hello, I'm new in GLBasic, and this is my first official post!  :booze:

I wish to give my contribute in calculation optimization (tricks!).

1) I noticed that many people, to get a sprite rotating (forever!), they use something like this:

Code (glbasic) Select

counter = 0
while true
  inc counter, 1
  if counter >= 360 then counter = 0
wend


Even if it is correct, using an if is usually a "slow" procedure. Istead, you can use this code:

Code (glbasic) Select

counter = 0

WHILE TRUE
INC counter, 1

PRINT MOD(counter, 360), 100, 100

SHOWSCREEN
WEND


In this way, the "mod" makes the "dirty" job, and it is faster than using "if".

Another trick is about values switching:

1) true -> false -> true ....
2) 1 -> 0 -> 1 -> ......

You can use the following code:

BOOLEAN:
Code (glbasic) Select

boolValue = FALSE

WHILE TRUE
boolValue = bNOT(boolValue)
PRINT boolValue, 100, 100

SHOWSCREEN
WEND


FOR "1" AND "0" ......

Code (glbasic) Select

boolValue = 0

WHILE TRUE
boolValue = 1 - boolValue
PRINT boolValue, 100, 100

SHOWSCREEN
WEND


In order to see the result, you can put, in the first line, an FPS limiter:

Quote
limitfps 3 ; 3 frames per second.

I hope this small tutorial will help some people! (my 0.02$ contribution!)
#15
On US keyboard or on Italian keyboards the symbol "_" it should be printed using SHIFT key (it is under the symbol "-").
Sometimes its typing is very annoying.

Thank you!