Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

136 Neutral

About SirViver

  • Rank
  1. SirViver

    C++ to C#

    Please be aware that C# is a completely different language than C++. They may share a common letter in their name and their basic syntax is vaguely similar, but overall C# is a lot closer to Java than it is to C++. Just make sure you clear your head of any preconceptions and treat this as a completely new thing to learn. It will make your life easier in the long term if you don't try to follow C++ paradigms while coding C# [smile]
  2. Now, I don't have the time for a proper analysis, but a few minor quick things to do would be: Use [Vector2].LengthSquared() wherever possible when the actual length is not required (for example, when just comparing which vector's length is longer), as well as use Vector2.DistanceSquared(v1, v2) < radiusSum * radiusSum. This avoids a square root calculation which could help a bit. (I hope these methods exist, I'm only somewhat familiar with SlimDX, not XNA.) Create a constant for commonly used... constants. Like Math.PI/2. Not sure if the compiler optimizes that away, but cannot hurt to make sure. Also try to multiply instead of divide, like Math.PI * 0.5f instead of Math.PI / 2f, but that's really minor. I assume your bucketlists are pre-allocated with an appropriate size? (Sorry if I missed it in your text somewhere.) If not, make sure they are, and that you constantly reuse the existing List instances instead of destroying and recreating them every frame. Overall it'd be really important to figure out which parts of your handleCollide (or other methods) actually take up the most time. If whatever profiler you're using cannot provide that info, profile manually. Use the most accurate timer available (QueryPerformanceCounter?) to make manual measurements of the individual code parts to see how much time they take. No point in optimizing if you don't know what code actually causes the bottleneck.
  3. These two blog posts should be of interest if you haven't already read them: Managed Code Performance on Xbox 360 for XNA: Part 1 - Intro and CPU Managed Code Performance on Xbox 360 for XNA: Part 2 - GC and Tools You need to keep in mind that the peculiarities of the XBox hardware and the limitations of the Compact Framework make this a whole different beast to optimize well compared to running it on a desktop PC. For example the .NET CF does not have a generational GC - every garbage collection is a full one - so avoid allocating lots of temporary objects. Floating point math isn't as fast on the CF as the XBox hardware could do either. If you need to do lots of calculations you should make full use of the 4 available threads (3 cores, 6 threads due to hyperthreading, 2 reserved).
  4. SirViver

    Performance and Efficiency problems

    I unfortunately don't really know about the relative performance of modern mobility GFX chips (I stopped following the whole graphics card circlejerk a few years ago, tbh), but a PixelShader might be a problem if the card has poor support for it. Then again your PS is probably not doing all that much - to get anything useful, the actual implementation of PointLight() would be interesting. In case that's a built-in function forget about that, I have only rudimentary HLSL knowledge so bear with me. That said, on a hunch, have you checked if maybe VSync is enabled/forced on your laptop? I've had a problem with VSync in the past due to using D3DPRESENT_INTERVAL_DEFAULT instead of D3DPRESENT_INTERVAL_ONE, the difference being that the former uses a less precise timer apparently, which screwed up my framerate big time.
  5. SirViver

    Performance and Efficiency problems

    I can't go any more in depth right now but I have two pieces of advice for you: Profile your code. Measure which calls take the most time. Just looking at the code and blindly trying to optimize it without even knowing which part of your code causes the most slowdown to begin with is pointless. It doesn't even need to be a full-fledged profiler. Just use the same time measurement techniques (probably QueryPerformanceCounter?) you're already using for frame-timing. Put one call at the start of the code part you want to measure, one at the end and the difference between the two calls is the time taken to execute (may require some maths to get the amount in milliseconds). Ideally write yourself a few helper tools that allow you to create named sections for timing, then at the end of your loop generate a summary report and display it in realtime on the screen too. Just take care to let the measurement tools have as little impact as possible, so they don't influence the result significantly. It's also completely sufficient to do rough measurements first, to see where the main performance draws lie. Then once a function is identified as such, you can create other measurements within that function to pin down which code parts actually cause it, etc. Forget about fps measurements as performance indicator. The only value they have is telling you whether you get a high enough framerate and if it is stable. Realize that fps counts are not linear, either: If your update & render code takes for example 1 ms total to execute, you have 1000 fps. If you increase that by just another millisecond to 2 ms, suddenly there was a "massive" loss of 500 fps, which in reality amounts to nothing. If your base loop already takes a more realistic 10 ms, you get 100fps. If you again add 1 ms, the loss is suddenly only 9.1 fps, down to 90.9 fps. Losing high amounts of fps can look dramatic, but may in reality be ultimately meaningless.
  6. Quote:Original post by GeirGrusom Quote:Original post by EricRRichards Thanks for the link, but it's not so much the emacs keystrokes that I prefer, but the way the completion algorithm runs, i.e. defaulting to the most commonly/recently used token. Isn't this the default behaviour of IntelliSense in 2010? Yes, I'm pretty sure that is the case. However, I just checked tools > options and only C# has an IntelliSense section with the "Pre-select most recently used member" option. No such thing can be found for the C/C++ one, so maybe you need to use a plugin after all.
  7. Strange, can you post a screenshot maybe? Do you have any other code that messes around with the form's size? Cannot really think of anything else, to be honest.
  8. I think the StartPosition is screwing things up for you. This should work: public Form1() { InitializeComponent(); this.StartPosition = FormStartPosition.Manual; this.DesktopBounds = Screen.PrimaryScreen.WorkingArea; } Alternatively, putting the code in the form's Load event will make sure the StartPosition property has no influence on the form's location after you set it. Note that this causes different form behaviour if you hide/show the same form instance multiple times, since Load gets called every time you show the form, whereas the constructor obviously only gets called once. private void Form1_Load(object sender, EventArgs e) { this.DesktopBounds = Screen.PrimaryScreen.WorkingArea; } [Edited by - SirViver on July 10, 2010 12:57:52 PM]
  9. SirViver

    [C#] - How do I post C# code?

    The FAQ is there for a reason, you know...
  10. SirViver

    Sleep less than 1ms?

    VSync never caused input lag problems for me, but then again I always turn the "max frames to render ahead" GFX card setting down to 1, so that might be the reason for that. The only beef I have with VSync is if it's only double buffered and the game scene is complex enough so my system cannot guarantee reaching the monitor's refresh rate in fps. If this happens, the framerate will immediately be cut in half due to missing one monitor refresh and having to wait for the next, without being able to do anything in the meantime. The sleep every nth cycle does sound like a very good alternative to using VSync for CPU/GFX usage reduction, though, so I gotta give that a try!
  11. Oh wait I got one: Edit & Continue support for anonymous methods. It is such a nice feature that can save you lots of time fixing and immediately retesting small bugs that would otherwise require you to restart the whole application and reaching the state where the bug occurred again. Unfortunately this becomes more and more impossible as Lambda expressions and LINQ gets added to the code :( Speaking of which, I find LINQ to be very useful, and yes I actually mean the query syntax with that, not just chained extension methods; just by reading the query you naturally know what the code is doing. Sure, coding that filter / sort / group by manually might be marginally faster, but it also results in code that is a maintenance nightmare. Manual, chained expressions are okay if they're short and simple, but shunning the LINQ syntax even for more complex stuff kind of defeats the point IMO, as Lambda expressions aren't exactly natural to read. A long chain full of parentheses and arrows just isn't that easy to parse.
  12. Quote:Original post by phresnel Even with finally, things are not easy: try { Console.WriteLine("Foo"); throw new Exception(); } finally { Console.WriteLine("Bar"); throw new Exception(); Console.WriteLine("Frob"); } -> only "Foo" gets printed. try { Console.WriteLine("Foo"); throw new Exception(); } catch { } finally { Console.WriteLine("Bar"); throw new Exception(); Console.WriteLine("Frob"); } -> only "Foo" and "Bar" gets printed. "Frob" is still bad. Just a note, the first example is only true if the exception isn't handled at all in your program. As soon as the exception is caught somewhere above, both examples will print "Bar". I must admit when I tried this out I was surprised, probably because I never ran across a situation where an exception was truly unhandled in my five years of C# programming before. You learn something new every day :)
  13. Sorry if I'm overlooking something, but why not just store a pointer/reference to the current TeamMember target in your Monster class? That way you always have access to all information of your target without needing to copy anything. Of course you could design this in a more abstract way, letting the target be a pointer to a common base class (of which both TeamMember and Monster would be derived) and deciding which attack patterns to use depending on what type the actual target is. That way you could make monsters attack each other too, for example when they're under a mind control spell or something like that.
  14. SirViver

    DirectX with C#

    I'd recommend SlimDX. Yes, it's a thin wrapper, but that doesn't really mean much. It comes with a bunch of samples that can get you started very quickly, all of which are building upon a shared SampleFramework, which sort of mimics the XNA base game loop. That sample framework, while not really intended to be used as full game engine, can still work as a good starting point and can be fully adjusted to your needs, as it is of course also written in C# and the source code is included. You'll still have to build the main engine yourself, but all that annoying stuff like window creation, DX initialization and lost device handling is basically covered by it.
  15. SirViver

    Java pointer or similar

    This thread is amazing(ly pointless). Java does not pass by reference, ever, unless you for some arbitrary reason choose to redefine what "pass by reference" itself means. This would be quite a silly thing to do, however, at least if you plan to have a meaningful discussion with other people in your field using the same term. Now, for all I care you can call apples oranges in your private time, but sowing this kind of confusion in the beginners section of all places is really unnecessary.
  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!