Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

125 Neutral

About Hybrid666

  • Rank

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Hybrid666

    Thread synchronisation question

    Thanks for the advice guys, I wanted to avoid a sleep, or a per-task wait.. based on your feedback I don't think there is a nice way to achieve what I'm after. I think I should stick to synchronising when the entire task queue is done Thanks again!
  2. Hi, I'm trying to figure out the best approach to solve a problem I'm having waiting for a group of 'tasks' to finish. I have a task based model where N worker threads consume tasks added to a task list. I'm trying to add sync points into the task list, so i can wait for a group of tasks to complete. i.e. ... AddTask s = AddSyncPoint AddTask AddTask RemoveSyncPoint( s ) AddTask ... then later on, i can WaitForSyncPoint( s ) which will wait until those 2 tasks between the sync markers are processed. I thought about using a semaphore, but I can't quite figure out how to make it work. The problem I'm having is that i (think i) want each task to be able to lock the sync object, and then reacquire the lock in the 'wait' function to say all is done. But because my tasks can be processed on any worker thread, I don't know how to make this approach work. Thanks for any help, i'm a bit stuck, but am convinced I'm missing something obvious... my current best attempt is to use an atomic and a while( numActiveTasks ) { sleep( 0 ); } inside my wait function. I'm sure this is not good
  3. Hybrid666

    checking if LOGFONT exists?

    Amazing! You took like 3 minutes to reply or something! Have put it in and it works, easy when you know how ;) Thanks a lot!!!
  4. Hi, I have written a C++ program that, as part of its save file, writes out the contents of a LOGFONT structure. However, if someone else loads up that file on a different PC, which does not have the selected LOGFONT installed, it just ends up magically using Arial, gives no errors/warnings and doesn't even update the LOGFONT structure with the Arial font. Is there a way to detect whether a LOGFONT is valid? I've googled etc and can't find anything useful. Thanks, Rich
  5. ah thanks a lot!! :)
  6. Hi, In Cg, is there a way to find out the profiles of the vertex and fragment programs defined in an effect? If I write an effect for arbvp1 and arbfp1, I want some way of getting those enums out of the effect, but can't seem to find one! Is this possible? Thanks, Rich
  7. ok, thanks for the help :)
  8. Hmmm... this is a good question, and has just prompted me to do some googling, because I was thinking the inheritance approach would incur some extra function call overhead due to vtable lookups etc.. but because none of the functions I am using are overriden virtuals, I don't think there is any runtime penalty for using inheritance? Google seems to corroborate this theory.. is there any runtime penalty for using the inheritance approach, if I'm only using the dervied class for adding extra functionality, not for overriding base class functionality?
  9. Ha, yeah std::string is good, but my problem applies to other non-string related problems :) In your example, surely I then have to pass through a lot of tArray functionality in the string class, e.g. the [] operator, GetSize() function, etc etc ? or use the string by making calls to a GetStorage() member in a lot of places? I don't think C++ has a nice solution to offer me for this problem :(
  10. Hybrid666

    Returning pointers

    Hi, If returning NULL is an acceptable output from the function, (e.g. you're trying to find something, but it's fine that it might fail sometimes) then you're going to have to handle NULL in the calling code. However, if it's an error that it should fail to find something, it should still return NULL, but should probably assert or throw an exception when that happens, so you know something has gone wrong. It's more up to you at that point whether you would prefer your program to crash and force you to fix some problem, or write extra code that attempts to handle the unexpected situation and carry on functioning in whatever way it can. If it's really bad for it to fail, beware silently coping with it returning NULL - this may lead to you missing a really bad bug in your code [smile]
  11. Hi, I'm trying to find a nice way to implement a string class that is based on an array class.. currently i have this working: template<sint32 MaxLength> class tString : public tArray<char, MaxLength> However, I don't really want my string class using inheritance like this, I'd rather it used template specialisation, but I can't figure out a nice way of doing it :( The closest I've gotten is using a typedef embedded in a class, but that leaves me having to say: tString<64>::Type Variable; Ideally I just want to be using something like: tString<64> Variable; Has anyone found a way of achieving this? Am i missing something obvious? I've considered using a #define for it.. which would leave me with: #define tString(MaxLength) tArray<char, MaxLength> tString(64) Variable; I suppose that's ok.. but I don't like it much.. :) Thanks for any help, Hybrid
  12. Hybrid666

    Convert Z Buffer value to W

    Hi, Thanks for the info, but I'm still a bit confused :( I know how to do a lerp to move a value into a 0-1 range, but my understanding was that Z buffer values weren't linear between ZNear and ZFar, and so a lerp wouldn't work? I didn't really phrase my original question correctly either tho - I do want to understand the process rather than just be told "yes it's right" / "no it's wrong" :) Cheers for the help
  13. Hybrid666

    Convert Z Buffer value to W

    Thanks for the advice on linear Z :) but is my Z to W conversion formula correct?
  14. Hybrid666

    Convert Z Buffer value to W

    Hi, I've been trying to convert Z buffer values to linear W values in a pixel shader. I've looked at http://en.wikipedia.org/wiki/Z-buffer, but that didn't seem to give me the results I was looking for, so then I looked on here and found (in another thread) this: float fFarOverNear = (fFar / fNear); return fDepth / (fFarOverNear - (fFarOverNear - 1) * fDepth); which seems to work fine.. but looks too simple to be correct.. is the the right way to do this? Thanks in advance, Hybrid PS. I've also considered making my Z buffer linear so no conversion is necessary, but I'm unsure of the pitfalls of such an approach... but regardless of this, I'd still like to be sure I can convert between Z and W values properly.
  15. I had to find the current working directory (using GetCurrentDirectory) and pass that as an include directory to the Cg compiler (using -I). Strange that I never used to need to do this for it to work.. :\
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!