• Content count

  • Joined

  • Last visited

Community Reputation

128 Neutral

About Kobo

  • Rank
  1. [quote name='floatingwoods' timestamp='1325785337' post='4900025'] Thanks to both replies. [quote name='Telastyn' timestamp='1325783627' post='4900012'] [quote name='floatingwoods' timestamp='1325783116' post='4900006'] What is the best way of implementing 2 threads that alternatively operate (but never at the same time), by reducing the waiting time to a maximum? [/quote] Have thread A run, and thread B wait. If you've got two threads only working on something, but never at the same time, you're never running them concurrently... and shouldn't use threads. [/quote] I need two non-concurrently running threads for the transition. I have to rewrite a single-threaded application. In future the 2 threads will run concurrently, but until I finished preparing the individual API locks, this intermediate solution is best. "Have thread A run and thread B wait" Yes! But how? e.g. [source] CCriticalSection cs; THREAD1: while (true) { cs.Lock() do some work cs.Unlock() } THREAD2: while (true) { cs.Lock() do some work cs.Unlock() } [/source] Above solution works. But I don't have the guarantee that thread 1 will not run twice before thread 2 runs. I need an alternating pattern. [/quote] You need two locks. Make each one unlock the other. I'm not sure that's really a lock anymore, though. Make one lock start locked and make each thread depend on its own lock. You will have starvation issues, which is one reason this is a bad idea.
  2. Simple C++ questions

    [quote name='dejaime' timestamp='1324829177' post='4897289'] [quote name='boogyman19946' timestamp='1324827893' post='4897286'] I thought arrays were supposed to be "guaranteed" (and I use the term lightly much as with everything else [img]http://public.gamedev.net/public/style_emoticons/default/biggrin.gif[/img]) to be continuous in memory. So creating an array of 20 pointers to point to different arrays would violate that rule. [/quote]That's right, if there's no continuous space to allocate the array there'll be a problem! PS: in most OSs, at least... [/quote] Arrays are contiguous within the context of the address space of the process. It is the operating system's problem outside of that context. This means that you can use pointer arithmetic to access members of an array.
  3. Large objects in a uniform grid

    [quote name='zqf' timestamp='1324556617' post='4896497'] > A parent/Child system where large objects are divided into smaller children, and these children sit in the Grid, moving with their parent and calling them if they collide with something. This technique would presumably have a lot of overhead if a huge object is moving around, as it has to remove and insert many children, but on the other hand it could handle almost any size, particularly giant obects which would be used rarely anyway (for example, huge bosses). And handling of Ray queries would barely change. [/quote] This idea is pretty close to a tree anyway. What you would probably want to do, though, is put bosses higher up in the tree and traverse the tree from the top. If you put the boss in the parent, you should't need to put it in the children.
  4. Problems with switching of textures

    I'm not familiar with Xcode but it looks like you need to make calls to glActiveTexture and send it the gluint id of whichever texture you are going to use next
  5. [quote name='Alaror' timestamp='1323911878' post='4894046'] Now to my question: what affect should should solid blocks that are above the one currently being calculated have? Should a block above reduce the pressure placed on the block below or increase it? The first inkling I have is to make it reduce the pressure since it might help redistribute it, but I'm not so sure. My goal is to keep this system as realistic and simple as possible, so if you have any other suggestions please feel free to share! [/quote] I would ignore it. If you're showing the player a side view of a cave, that block above the block in question should be supported by the foreground and background. You might have to consider it if blocks fall, but it sounds like you're talking about static blocks.
  6. c++ extern command

    [quote name='Pero83' timestamp='1323804222' post='4893606'] well, that is what is confusing the hell out of me. I'll try to make more simple example. I have: - A.h - B.h - B.cpp B.h has : extern D3DApp* gd3dApp; Do note the EXTERN keyword. Now, B.cpp has D3DApp* gd3dApp = 0; No extern keyword. This, i think, i understand. In B.h, you declare an external variable, wich means, that it is define / initialized somewhere farther in the code or in other file. But what gave me a problem, is that A.h already has the " extern D3DApp* gd3dApp", wich B.h also has. Not definition, but (Extern) declaration. B.h then includes this A.h, and as such, you call extern two times on same variables within same file (while definition is in third file - B.cpp). So if understand Kobo correctly, you don't need to call extern command in B.h, because it includes A.h, wich already did that (as in, it already used extern command on that variable)? And B.cpp actually then defines this varible? tnx all for help btw. [/quote] No, you need to use the extern keyword once and not declare it again. If you include a header that has extern D3DApp* gd3dApp, that is the same as putting extern D3DApp* gd3dApp in the file that has the #include directive. if A.h declares "int x = 5;" in it, then if B.cpp includes A.h it will know x = 5. Everything you include gets put into a translation unit by the preprocessor, which is sort of like having all your text from each file you include smashed into a giant wall of text. If you want to use an external variable like gd3dApp, you declare it exactly one time in a header somewhere with the extern keyword. Putting interface in headers that get included and implementation in source files that don't get included in other source files will help you. It will start getting tricky and tempt you to include headers in headers if you are putting logic in some of your headers that might want to know more about gd3dApp than its type (D3DApp *). You want to have "extern D3DApp* gd3dApp" in a header somewhere that gets included by source files. You do not want to declare D3DApp* gd3dApp without the extern keyword.
  7. c++ extern command

    [quote name='Pero83' timestamp='1323719883' post='4893231'] [quote name='yewbie' timestamp='1323719650' post='4893228'] And I have not used extern for awhile but I *think* you need to specify extern for the variable in [b]each[/b] cpp file that is not the one it originates from. [/quote] even if you include file that already used extern command on the same variable? Looks to me like you would use extern command two times on the same variable, since you already include the first file? [/quote] You don't want to use extern if you're including a file that declares that variable. Extern is for when something is declared in a file that you're linking with. If you include a file that makes a global declaration, then you don't need to declare it again.
  8. So, I don't know much about openGL but have you tried using GL_POLYLGON or some other mode instead of GL_TRIANGLE_STRIP ?
  9. Sorting Objects

    [quote name='yewbie' timestamp='1323455096' post='4892270'] [quote name='Kobo' timestamp='1323454898' post='4892265'] You might be doing this on purpose but it looks like you should be starting i at 0 instead of 1. [/quote] Object 0 is added before the loop, starting at 0 would add object zero again. [/quote] Ah, I thought you might be doing that somewhere else but it was right there in the code you posted.
  10. Sorting Objects

    You need to do a sorted insert (what you're doing in your else branch) for your stuff that you add after you do your initial sort and then you won't need to worry about sorting more than once. Try commenting out the front and back checks individually to see if they are slowing you down or speeding you up. You can write X <= Y instead of X < Y || X == Y like the conditional in your else branch You can allocate memory to the list using the member function get_allocator(), which you should probably do before you start sorting since you know how much memory you will need. You might be doing this on purpose but it looks like you should be starting i at 0 instead of 1.
  11. [quote name='kotmfu' timestamp='1323330252' post='4891731'] [quote name='Hodgman' timestamp='1323328755' post='4891728'] Are you asking if it's possible to get correct results with an incorrect sorting order, or are you asking what you should do to achieve a correct sorting order? [/quote] i want to render out of order and achieve a correct result. as i said if i turn on the dx3dsprite class, and not use it, it works fine, but i turn it off and i cant get it to work and id rather not have any references to it in my code [/quote] Consider two sprites, the front one is completely opaque and the back one is transparent. If you process out of order it is possible that you will see the transparent one. The logic to prevent that scenario is probably going to be more expensive than sorting.
  12. I don't know if this is a major consideration for you, but it was for me: 4 year universities that have a wider selection of [b]majors[/b] available also have a wider selection of [b]people[/b] to meet, specifically [i]ladies[/i], which were few and far between in my CIS lectures.
  13. c++ unresolved external symbol help

    [quote name='sniffbaron' timestamp='1323273684' post='4891490'] Hi again. I reading the book "Beginning game programming" by Jonathan S. Harbour, and I just followed the instructions of the book. It is supposed to be a win32 project and it worked for the author. here is the code [code] // Beginning Game Programming, Third Edition // Chapter 1 - HelloWorld program #include <windows.h> int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) { MessageBox(NULL, "Motoko Kusanagi has hacked your system!", "Public Security Section 9", MB_OK | MB_ICONEXCLAMATION); } [/code] [/quote] Your probably need to tell your compiler where to search for windows.h.
  14. [quote name='DarklyDreaming' timestamp='1323169050' post='4891066'] [quote name='Muhammad.B.' timestamp='1323164455' post='4891040'] when I try to decompile a flash game i found online, I get a error saying this game is site locked any tips or helps to go around this am currently searching through google and could use any tips fromm anyone with previous experience so yea any way of going around this currently researching myself for ways Thanks. [/quote] So, you stole another guy's game and source code for (quote): "researching" instead of nicely asking for a copy and explaining [i]why [/i]you need one. Wow. [/quote] Copy pasta ninja gotta do what copy pasta ninja gotta do.
  15. Is it safe to NULL an array?

    Why not declare a pointer and assign it later?