BlockLeftTop, PRELOAD BlockLeftBottom, PRELOAD BlockLeftStretch, PRELOAD BlockTop, PRELOAD BlockBottom, PRELOAD BlockStretch, PRELOAD BlockRightTop, PRELOAD BlockRightBottom, PRELOAD BlockRightStretch, PRELOAD
Latest Game

3 Mio FPS

by Benjamin Nitschke 23. April 2010 16:46

No, I am not kidding, after a week of optimizing I just reached almost 3 Mio FPS with our engine. I had to disable Clearing/Present and Input, but this is my log output (thanks to PerformanceCounters this is also pretty accurate):

 

FPS: 2703785

 

With Input enabled I can easily go above 200000 FPS, most time of each frame is in whatever platform Input GetState method does:

 

FPS: 202099

 

With Present (clear is not needed in my test as I draw a fullscreen quad) it goes down to ~13000 FPS, which is not shabby, but almost all time is lost in Present of XNA 4.0 CTP, which hasn't been optimized a lot yet by the XNA Team (the main module I use currently, but we support many different graphic frameworks as well, XNA is just the best for Windows IMO). Might sound crazy, but for performance checking I disable Present because then I immediately see whats slow in the render code.

 

FPS: 12680

 

Other platforms are much worse, but it is always waiting for the graphic card or some external library, so I would say our engine is quite fast as of now. I obviously did not have much enabled in my test (just a test screen drawing a big quad, and Time, Input, Graphic, SceneManager, MaterialManager and Profiling modules enabled), but even doing more stuff does not hurt FPS wise. A more complex 2D screen could still achieve 10000 FPS. Next up is 3D optimization, which is much harder obviously (we are still not fast enough, especially on other platforms).

Passing touch events from UIScrollView to the parent UIViewController

by Benjamin Nitschke 18. March 2010 15:07
This post is about Objective-C iPhone stuff!

Just because this took me some time to figure out (and might be useful in the future or for other people): In the iPhone SDK a UIScrollView class will eat up all touch events (touchesBegan, touchesEnded, touchesMove, etc.) and not pass them along to your view controller where all your view logic might be (like in my case). If you know this, you can just create a new class for each ScrollView and then have some of your logic there, but in my case all I want is to pass these events along to the UIViewController (like all the other controls behave like). For this reason I just created a simple class called PassTouchesScrollView, which looks like this:
//  PassTouchesScrollView.m
//  Simple helper class for UIScrollViews that need to pass touchesBegan to the
//  UIViewController above it (see all the Controller classes here).
#import "PassTouchesScrollView.h"

@implementation PassTouchesScrollView

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event
{
	UIView *result = nil;
	for (UIView *child in self.subviews)
		if ([child pointInside:point withEvent:event])
			if ((result = [child hitTest:point withEvent:event]) != nil)
				break;

	return result;
}

- (void)dealloc
{
    [super dealloc];
}

@end

Note: This is only useful if you really do not need any touch events in the UIScrollView because even the scrolling drag touch events will be ignored and send to the UIViewController. If you want to be more selective, e.g. just pass the touchesEnded event on to the parents via:
-(void) touchesEnded: (NSSet *) touches withEvent: (UIEvent *) event
{
	// Pass to parent
	[super touchesEnded:touches withEvent:event];
	[self.nextResponder touchesEnded:touches withEvent:event];
}

References: Found helpful tips on StackOverflow and other sites (including this apple support forum).

How to preload website images

by Benjamin Nitschke 18. March 2010 14:53
Pretty quick tip because it was a little annoying that the huge background on this site took so long to load sometimes and reading the text was not very easy until all the panel images were loaded too. To make sure that the panel images for all the content are loaded first I just had to add this to the main css file:
#preload img
{
height: 0; width: 0; border-width: 0;
position: absolute;
bottom: 0;
left: 0;
z-index: -30;
}

And then just below the html tag (in my case in the master layout file) add the following code:
BlockLeftTop, PRELOAD etc. for each image ..

  • Found on this good old article from 2006 :)
  • In case you update to Mac OS X Snow Leopard

    by Benjamin Nitschke 17. March 2010 17:03
    Yes, first of all ask yourself, wtf are you doing on a mac anyway (well, in my case Objective-C, just implemented this on the iPhone (still work in progress btw), omg).

    Well, for testing the new iPad stuff I had to install OS X 10.6.2 (Snow Leopard) on that old crappy Mac Mini I use for developing (via VNC of course) since the newest version of XCode (Visual Studio for poor mac guys) 3.2.2 (iPad beta 4) only works on the newest OS X 10.6.2.

    Anyway, after updating for over an hour, everything looked the same, but not much worked anymore. My keychain was not working anymore because all my certificates were gone, dunno why, but I needed to renew them anyway. Then in the XCode Organizer I could not connect or see any iPhone or iPod anymore, no matter how many times I reconnected the devices. On other computers everything was still working fine, the iPods, iPhones and cables were all working, the Organizer was not working anymore.

    Only after I installed the new XCode version (iPhone SDK 3.2.2 beta 4), everything was working fine again. Maybe this helps someone sometime in the future :)

    Right Margin Line in Visual Studio 2008

    by Benjamin Nitschke 25. February 2010 15:12
    I might have blogged about this before, but I could not find my own blog post, so why not blog it again.
    Since the recent CodeRush 10 beta, which works in VS2010 RC finally, there is no more Right Margin line that can be enabled under Options->Editors->Painting. I also tried to enable some modules, but I cannot see the margin line anymore (works fine with CodeRush 9).

    Well, in Visual Studio you can also enable a margin line with a registry entry at:
    [HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\9.0\Text Editor]
    "Guides"="RGB(64,64,192) 79"
    
    This will produce a blue margin line right before the 80th column. It looks good on white and black backgrounds, but you can of course change it easily to any color and position. If you don't want to go into regedit, just execute this handy RightMarginLineVS2008.reg (280 bytes) file.

    Seattle 2010 - MVP Summit - Day 5

    by Benjamin Nitschke 17. February 2010 22:37
    This day we MVPs will go deep into sessions about lots of cool new technology. Everything is under NDA, so we are not allowed to talk about it. Most of my picture will just show people and what happened over the day. There might be information out in the web, but we MVPs are not allowed to comment on that ^^

    Seattle 2010 Day 5
    First thing of the day is to get some breakfast, which was very good in my hotel.

    Seattle 2010 Day 5
    I tried to take the last bus at 08:30, which was not such a good idea because the bus was late 20 minutes, which leaded to getting a little late on the first meeting at 09:00. But at least I met another new nice MVP from Korea: Dong-Hoon Kim

    Seattle 2010 Day 5
    The bus ride to Microsoft Campus was pretty quick once the bus finally arrived.

    Seattle 2010 Day 5
    We are almost at building 92, where Studio A is just a walking distance away.

    Seattle 2010 Day 5
    While searching for Building Studio A we went through building 92 and saw the company store right there (must have moved, last time it was somewhere completely different).

    Seattle 2010 Day 5
    There were lots of guys and girls standing around helping us with directions.

    Seattle 2010 Day 5
    We finally reached Studio A, pretty colorful posters up here, but finding the actual conference room was not very easy, 5000 room numbers, wtf?

    Seattle 2010 Day 5
    Lots of XNA MVPs here.

    Seattle 2010 Day 5
    And even more on the other side.

    Seattle 2010 Day 5
    And some guys from the XNA team.

    Seattle 2010 Day 5
    Dong-Hoon is also taking pictures. Funniest thing he told me yet was a joke from Korea: If someone asks you when the shuttle is coming, answer: You are not Protoss, there is no Shuttles for you.

    Seattle 2010 Day 5
    This is Nick Gravelyn, a former XNA, which now is part of the Borg, erm, Microsoft XNA team :)

    Seattle 2010 Day 5
    This is was happens to gramophone record here ..

    Seattle 2010 Day 5
    XNA guys running around, I am too lazy to tag them now ..

    Seattle 2010 Day 5
    Almost there at the new conference room location.

    Seattle 2010 Day 5
    A big room with lots of MVPs, big meeting ahead. Sorry, not allowed to disclose any more details .. at least it was interesting stuff.

    Seattle 2010 Day 5
    And finally walking back to the bus stop, the day is almost over. Time for a XNA party.

    Seattle 2010 Day 5
    Kathleen explains that we will go to the Big Picture bar and whats going on in general.

    Seattle 2010 Day 5
    On the bus ride everyone was checking and hacking on their phone. Most people have iPhones, which is kinda funny ..

    Seattle 2010 Day 5
    We had some extra time, so like last year we visted the Game Workshop board game shop, but I don't think anyone bought anything.

    Seattle 2010 Day 5
    The problem with the bar this time was that we were way to few people to fill it. Lots of room, but only a few guys in each. Last year this party was at this very same location, but we had some other teams here too and it was more crowded and party-like.

    Seattle 2010 Day 5
    XNA guys like Nick talking to XNA MVPs Andy and George.

    Seattle 2010 Day 5
    Everyone was taking pictures.

    Seattle 2010 Day 5
    After a while the UK and Irish MVPs were suggesting that we go to the Irish pub again because there is not much going on here (even though we had Pizza and free beer, yeah). This is a quick picture from the Big Picture ^^

    Seattle 2010 Day 5
    Some guys have their hotel right here, so they were quickly dropping of their stuff. I didn't want to go all the way to my hotel and back, so I just waited a bit here.

    Seattle 2010 Day 5
    Don't really know how this picture happend, but from the time stamp I can see this was taken BEFORE I was even drunk, which makes not much sense. I still think this is a cool photo.

    Seattle 2010 Day 5
    We stayed way too long in the pub, it was almost 1am when we finally left and I walked back to my hotel. At 7am my roommate got up, so there wasn't a long night sleep. Hopefully I won't be too exhausted the next day.

    How to keep the Intellisense info box short and tidy

    by Benjamin Nitschke 15. January 2010 08:39

    If you ever have wondered why you need all these Object class method in your class intellisense list, this is the right article for you. I recently wrote an Assert class for our own unit testing system (as reported yesterday we were pretty unhappy with TestDriven.net+xunit in our engine). Even though I have only written 10 methods in the Assert class, which I think are the most essential ones for unit testing, whenever I write Assert. Intellisense pops up with 15 Items instead of 10. In my case (statically accessing Assert) the following 5 Items were displayed without my consens:

    • The Contains method appears 2 times because one is using strings, the other overload is using generics
    • object.Equals appears because every class is derived from object!
    • Same for object.ReferenceEquals
    • The sub class Tests appears to, but I only need it for unit testing (but it needs to be public for xunit)
    • And finally there is a delegate ThrowsDelegate, which is needed for the Throws method.

    Additionally if you access a class via an instance (not statically) you will get the following object methods displayed in your intellisense too:

    • Equals (there is one static method with 2 arguments and a non static one with 1 argument)
    • GetType
    • GetHashCode
    • And finally ToString

     

    I cannot remember the last time I really needed those object methods in any classes intellisense. Luckily there is an easy solution to fix this, but you need to be aware that it does not work in every situation. But as you can see I managed to reduce my Assert class intellisense list down to the 10 items I really wanted:

     

    Basically you just add the following attribute to any method, sub class or property that you do not want to appear in the intellisense list:

    [EditorBrowsable(EditorBrowsableState.Never)]
    

    This works fine and dandy with your own methods (like in my example the ThrowsDelegate and the Tests sub class, but what about those nasty object methods? Well, static methods you can just re-implement with the new keyword (overwriting the original methods) and just specify the EditorBrowsable attribute there:

    #region Hide object.Equals and object.ReferenceEquals
    /// 
    /// Equals
    /// 
    [EditorBrowsable(EditorBrowsableState.Never)]
    public new static bool Equals(object objA, object objB)
    {
    	return object.Equals(objA, objB);
    } // Equals(objA, objB)
    
    /// 
    /// Reference equals
    /// 
    [EditorBrowsable(EditorBrowsableState.Never)]
    public new static bool ReferenceEquals(object objA, object objB)
    {
    	return object.ReferenceEquals(objA, objB);
    } // ReferenceEquals(objA, objB)
    #endregion
    

    For the non-static methods we can even use a simpler trick by deriving your class from the following IHideObjectMembers interface, which already adds the required attributes to the 4 annoying object methods.

    /// 
    /// Helper interface used to hide the base  members from
    /// your classes to make intellisense much cleaner. Note: This ONLY works
    /// from other assemblies AND you MUST NOT have the project using this
    /// interface in your solution (else VS will still show them).
    /// 
    [EditorBrowsable(EditorBrowsableState.Never)]
    public interface IHideObjectMembers
    {
    	[EditorBrowsable(EditorBrowsableState.Never)]
    	Type GetType();
    
    	[EditorBrowsable(EditorBrowsableState.Never)]
    	int GetHashCode();
    
    	[EditorBrowsable(EditorBrowsableState.Never)]
    	string ToString();
    
    	[EditorBrowsable(EditorBrowsableState.Never)]
    	bool Equals(object obj);
    } // interface IHideObjectMembers
    

    One final thing I had to do to get rid of my two Contains methods was to rewrite the string one to a generic one, so it appears together with the other generic one (using lists) in the Intellisense list, but that was no biggy.


    When you try this out you might wonder why the hell it is not working for you and sadly the answer is: Yes, it does not work all of the time. As already mentioned in the IHideObjectMembers implementation the hiding only works if you DO NOT HAVE the assembly from the class you are intellisensing in your solution. You need to reference it as an dll (a local file or from the GAC). Even then you might want to create a new solution for testing this out. The strange thing is that after a while VS seems to learn and will use your reduced intellisense even if you have the project in the solution, but I have no idea why this sometimes works (when writing this blog entry it almost always worked inside my Assert assembly even). Anyway, it is still a very useful trick IMO.

    Collapsing Projects in Visual Studio Solutions

    by Benjamin Nitschke 13. January 2010 11:09

    DeltaEngine VS Collapse

    If you have 50+ projects in a single solution it can be annoying that you cannot collapse them all with a single click or keystroke. Expanding everything can be simply done with Numpad * at any node in the solution explorer. Having so many projects in a solution and compiling them all everytime you F5 something is not such a good idea because compile time goes through the roof (even though each single project is compiled really quickly, usually in much less than a second). Please note that our projects are mostly very simple and having so many projects is by design because they only implement certain features and can be easily replaced (or there are several modules for the same feature, just doing differently or for different platforms). We should blog about that too, I think it is a pretty good idea and makes refactoring and multiplatform development much easier than big projects and lots of ugly defines (we have almost no defines right now and are pretty happy with it).

     

    To solve this we have a little helper tool that recursively selects the projects you need for any given project you want to work on, then you end up with 3-4 projects instead of 50+ (we have like 10-20 new projects every month, so this will probably increase for a while). An alternate solution is to fiddle with the build settings in the Configuration Manager to just compile some projects, but not the rest. But this is very error prone and can cause many headaches because you forgot to compile some project you changed some little thing and then your code will still execute the old .dll with the old code missing your newly implemented functionality.

     

    But the problem with so many projects, and usually in any kind of Visual Studio solution, is that you cannot easily collapse all projects at once. Instead you have to collapse them one by one, which can be fun with 5 projects, but it is certainly not funny with 50+ projects anymore and you practically have to do it every day to keep the solution explorer short and tidy. Luckily some clever people solved this problem many years ago with macros or extensions and I like the simple macro version. There is a great tutorial with all required steps available, which you can use to set it up for your Visual Studio. We use a slightly modified macro that works better with our sub folders that have projects too:

     

    Imports System
    Imports EnvDTE
    Imports System.Diagnostics
    
    Public Module Collapse
        Sub CollapseAll()
            ' Get the the Solution Explorer tree
            Dim UIHSolutionExplorer As UIHierarchy
            UIHSolutionExplorer = DTE.Windows.Item(Constants.vsext_wk_SProjectWindow).Object()
            ' Check if there is any open solution
            If (UIHSolutionExplorer.UIHierarchyItems.Count = 0) Then
                ' MsgBox("Nothing to collapse. You must have an open solution.")
                Return
            End If
            ' Get the top node (the name of the solution)
            Dim UIHSolutionRootNode As UIHierarchyItem
            UIHSolutionRootNode = UIHSolutionExplorer.UIHierarchyItems.Item(1)
            UIHSolutionRootNode.DTE.SuppressUI = True
            ' Collapse each project node
            Dim UIHItem As UIHierarchyItem
            For Each UIHItem In UIHSolutionRootNode.UIHierarchyItems
                'UIHItem.UIHierarchyItems.Expanded = False
                If UIHItem.UIHierarchyItems.Expanded Then
                    Collapse(UIHItem)
                End If
            Next
            ' Select the solution node, or else when you click 
            ' on the solution window
            ' scrollbar, it will synchronize the open document 
            ' with the tree and pop
            ' out the corresponding node which is probably not what you want.
            UIHSolutionRootNode.Select(vsUISelectionType.vsUISelectionTypeSelect)
            UIHSolutionRootNode.DTE.SuppressUI = False
        End Sub
    
        Private Sub Collapse(ByVal item As UIHierarchyItem)
            ' Recursively collapse
            For Each eitem As UIHierarchyItem In item.UIHierarchyItems
                If eitem.UIHierarchyItems.Expanded AndAlso eitem.UIHierarchyItems.Count > 0 Then
                    Collapse(eitem)
                End If
            Next
    
            ' First try to collapse
            item.UIHierarchyItems.Expanded = False
    
            ' Check if it failed, if yes, then do it manually
            If item.UIHierarchyItems.Expanded = True Then
                item.Select(vsUISelectionType.vsUISelectionTypeSelect)
                DTE.ToolWindows.SolutionExplorer.DoDefaultAction()
            End If
        End Sub
    End Module
    

    Visual Studio 2010 Delayed, VS2010 RC coming in February 2010

    by Benjamin Nitschke 13. January 2010 09:59

    VS2010 logo

    It is almost old news that Visual Studio 2010 was delayed from March 2010 to some unanounced date a few weeks later (plus the beta period was extended). However, many people I know are not doing anything with VS2010 Beta2 yet and only want to switch to VS2010 when it is really stable plus many addins are available. As reported 3 months ago (when VS2010 came out in Oct2009) we were pretty happy with VS2010 Beta 2, most things worked just fine, but we could not use CodeRush. Without CodeRush most team members were far less productive, so we switched back to VS2008 after a few days. Since DevExpress has not released a VS2010 compatible version of CodeRush yet (see their 2010 roadmap, CodeRush 2010 will be released when VS2010 is final), we are still using VS2008.

     

    However, I am currently writing an addin for our engine and I really want to replace xunit/TestDriven.net because it just does not work for us anymore. We have a lot of problems with other platforms, with static unit tests, graphical tests, logging, etc. Instead of living or circumventing all these problems (this is what we have done in the last few months) we really want to be more productive and have things just work, which is especially important for unit tests IMO. I like writing VS2010 addins much more than to fiddle around with the VS2008 SDK and since we will switch soon anyway, I will write this plugin in VS2010. In the meantime we will try to use some simple VS macros to accomplish basic testing jobs. I will blog more about this in a bit.

     

    How to write unmaintainable code

    by Benjamin Nitschke 22. December 2009 10:47

    In case you are afraid of being laid off, there are some tips how to make yourself irreplaceable by writing really unmaintainable code. It is a really funny read and every sane person will suggest the exact opposite. My only question is how can you really do any work when your own code is so unmaintainable ..

    http://phpadvent.org/2009/unmaintainable-php-by-stoyan-stefanov

     

     

     

     

     

     

     

     

     

     

     

    Have a nice christmas and a happy new year in case no one blogs here anymore. But we will probably take a few photos from our christmas party today and post something fun for christmas ..

     

    Disclaimer: The opinions expressed in this blog are own personal opinions and do not represent the companies view.
    © 2000-2010 exDream GmbH & MobileBits GmbH. All rights reserved. Legal/Impressum

    Recent Games

    Fireburst

    ArenaWars Reloaded

    Jobs @ exDream

    Current Poll

    Do you know what the Delta Engine is?



    Show Results Poll Archive

    Calendar

    <<  September 2010  >>
    MoTuWeThFrSaSu
    303112345
    6789101112
    13141516171819
    20212223242526
    27282930123
    45678910

    Blogs

    Download OPML file OPML