Various

BlitzMax Forums/BlitzMax Programming/Various

dmoc(Posted 2005) [#1]
1) Where are "function pointers" documented?

2) I need a variable sized array of my own UDT that is contiguous in memory (to pass data to opengl). So far I have ruled out normal arrays (non-contiguous) and now looking at using banks. To do so I need a ptr var to my UDT which points to the bank. I'm having no luck assigning the banks buffer address to the ptr var. From other posts it looks as if this is not possible or at least very messy. Is there a *clean* way to manipulate contiguous data using UDT ptrs? This IMO is/will be a common requirement.

2) Don't most systems (MS, Linux, OSX) now provide a timer with better resolution than std milli-secs? If so why only provide lo-rez timer functions?

3) Is (safe) multi-threading going to added to bmax (os-independent)? In my app I need to download my data, convert it and then update my model. The first two steps are lengthy and in PureBasic I use threads to avoid significant fps reduction. In BB3D I managed it by interleaving data-processing and rendering but I would like to avoid this because the code gets very messy and unmanageable (hence the move to PB). If threads are not coming soon do you have a suggestion about the best way to get bmax communicating with a seperate program, ie, sys messages, pipes, share mem, stdio redirection or any other form of IPC? Without threads I cannot see how bmax can efficiently act as a network server (for local comms).

4) Is there a better OSX editor coming soon?

5) In what situation do I extend/use a TLink? In my small progs to discover how to implement a tree I haven't used them at all.

6) Are TGA loading problems solved?


rdodson41(Posted 2005) [#2]
1. I don't think they are documented, but they are very simple. A function pointer is just like any variable in that you can have a function myfunc() that is defined somewhere in your code, and then anywhere just say funcptr() = myfunc() and then calling funcptr() is the same as calling myfunc(). You can also pass function pointers as arguments into functions such as dosomething(5, "hello world", myfunc()) would be the call, and in the definition you have Function dosomething(num:Int, str:String, func()).

3. I haven't heard anything about threads coming in for BMX, but i read somewhere that someone was working on a Win32 thread-handling module.

4. I think they are going to release a better IDE when the Win32 and Linux versions are released.

5. TLinks aren't used for trees, they are used for the TList data structure which is a linked list. Look into linkedlist.mod, I think you can see how to use it. A TLink is just one of the items in a TList linked list.

Hope it helps.


FlameDuck(Posted 2005) [#3]
2) Don't most systems (MS, Linux, OSX) now provide a timer with better resolution than std milli-secs? If so why only provide lo-rez timer functions?
No. Some are actually only accurate down to about 10-50 ms. In a timesharing non-realtime OS, that's probably as accurate as you're gonna get - for reliable timing, anyway.

Incidently you have two number 2 questions.

If threads are not coming soon do you have a suggestion about the best way to get bmax communicating with a seperate program, ie, sys messages, pipes, share mem, stdio redirection or any other form of IPC?
You cannot share memory without threads. Anyway in it's current state I would recomend using the TCP/IP stack.

Without threads I cannot see how bmax can efficiently act as a network server (for local comms).
I agree. Unfortunately I'm not entirely sure it was intended to.

4) Is there a better OSX editor coming soon?
Try Eclipse and a suitable plugin.

6) Are TGA loading problems solved?
Who cares? Use PNG instead.


dmoc(Posted 2005) [#4]
Thanks for the info guys. Should have mentioned I'm on a MAC.

BMax has already made use of open-source libs so maybe Mark would consider including Pthreads? Re "server" - needed for networked games. Multi-threading, while not essential, makes a lot of sense.

You cannot share memory without threads


On Windows (in PureBasic) I already use shared-mem without threads by simply sending messages when the shared-mem has been updated (threads do come into it though if async comms required).

Re TCP/IP: Can streams be used with a "raw" protocol and custom ports?

Re TGA: All my graphics are in TGA and ATM I don't want to maintain two sets. Besides, it's still a bug if bmax cannot load a TGA.

Q2 (the first) was the important one here. I've since seen the error of my ways so I've done a new post in the form of a suggestion to Marky Mark in the hope that he will grant me my wish (see programming forum).


Dreamora(Posted 2005) [#5]
From what posted in the last histories (see in your BM installation), the image loading problems should be solved.

The networking isn't really in so far, the stream stuff is meant for file loading at the moment, although they allow you to use http / ftp for internet access.


btw: for windows there is an unofficial threading module if you need it that bad :)


dmoc(Posted 2005) [#6]
Yeah, I saw that the TGA prob should be fixed but I'm still getting null object from TGA loader. If/when I have time (assuming I can be bothered) I'll step through the code to see where it's failing.

I'm doing a win-purebasic to mac bmax/cocoa conversion (most likely cocoa at this stage) but thanks for the info anyway.


Michael Reitzenstein(Posted 2005) [#7]
[quote]Who cares? Use PNG instead. [quote]
We used TGAs in Juno - when 7-Zipped, they're significantly smaller than PNGs. It's not an insignificant format that can simply be ignored.


skidracer(Posted 2005) [#8]
dmoc, email me any tga files that are still failing for you and I'll sort out the problem


dmoc(Posted 2005) [#9]
email sent