• What Are You Working On? V13
    5,003 replies, posted
[QUOTE=Siemens;25802659][/QUOTE] Even though the compiler probably ends up changing it to that anyway, I always end up doing that myself.
[QUOTE=yngndrw;25802691]Even though the compiler probably ends up changing it to that anyway, I always end up doing that myself.[/QUOTE] Not at all. Unless the compiler treats specific stdlib methods specially, it can't guarantee that any method will not have side effects, and therefore it cannot optimize several calls (even with the same parameters) into one, unless the language supports memoization. [editline]2nd November 2010[/editline] Also, fixed my BBS by adding a Console.Clear() up the top of Program.Main(). Fuck you Mono.
[QUOTE=BlkDucky;25790302] [QUOTE=Downsider;25790258]The performance of your app isn't really relevant when you're only rendering a model; the performance drops actually get less severe over time, it's not a perfectly linear relationship between polygon/texel and framerate.[/QUOTE] What, really? Why is that?[/QUOTE] Its not that the perf drops get less severe, its that it appears that way if you measure by frame rate. Frame rate isn't linear, what I mean is... Say you have a program that finishes a frame in 30 ms, and you add something that takes 10 ms. Total frame time is 40 ms, right? The frame drops from (1000/30=) 33.33 fps to (1000/40=) 25 fps. Now imagine a program that takes 16 ms, then the same 10 ms effect is added. The frame drop is from (1000/16=) 62.5 fps to (1000/26=) 38.46 fps. The difference in the first example is: 8.33 The difference in the second example: 24.04
double post what the filesystem check [editline]2nd November 2010[/editline] turning a content-less post into a content-full post: [img]http://ahb.me/Pm2[/img] Logout works. [editline]2nd November 2010[/editline] Also, I could [b]really[/b] use Chandler's hue library here: [img]http://ahb.me/Pm9[/img]
Ugh the fuck float f = .1f; f += .1f; f -= .1f; f displays as ".1" but f == .1f is false :\. [QUOTE=Siemens;25801513]Stack Exchange has an API, and you could probably use tags to find suitable questions. [editline]2nd November 2010[/editline] Except there is not a single alphanumeric character there.[/QUOTE] I need multiple choice ones though :(.
I should probably get into XNA coding again, so easy yet so flexible.
[QUOTE=high;25803257]float f = .1f; f += .1f; f -= .1f; f displays as ".1" but f == .1f is false :\.[/QUOTE] You can't accurately compare floating point values for equality. See [url]http://msdn.microsoft.com/en-us/library/system.double(VS.80).aspx:[/url] [quote][list][*]Two floating-point numbers that appear equal for a particular precision might not compare equal because their least significant digits are different.[/list][/quote]
The best thing to do is pick a precision level and do something like [code] const float precisionLevel = 0.0001; bool SortOfEqual(float a, float b) { if(abs(a-b) < precisionLevel) return true; return false; } [/code]
[QUOTE=Siemens;25803295]You can't accurately compare floating point values for equality. See [url]http://msdn.microsoft.com/en-us/library/system.double(VS.80).aspx:[/url][/QUOTE] This, you should never use == on 2 floating point variables. Check here for a safe equality function using relative error: [url]http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm[/url]
[QUOTE=Siemens;25803295]You can't accurately compare floating point values for equality. See [url]http://msdn.microsoft.com/en-us/library/system.double(VS.80).aspx:[/url][/QUOTE] Your link broke. Top tip - don't put a colon on the end. Fixed: [url]http://msdn.microsoft.com/en-us/library/system.double%28VS.80%29.aspx[/url] Also just had a java lab session at university. I did 35 minutes of coding for 3 classes with some inheritance. It compiled and worked 100% first time :smugdog:
Yeah: Java can't know that getEventKey() isn't changed by the call to getEventKey(), so it has to evaluate it twice (in a functional programming language, this optimisation might well happen, however). For instance, if you have a function that increments a static number, and returns the result, inc() == 1 && inc() == 1 can never be true.
Why couldn't getEventKey() change between the two calls? I mean, that would take real skill but nothing is saying that it can't change, amirite?
[QUOTE=i300;25798390]How do you know this?[/QUOTE] Probably a decompiler like [url=http://www.varaneckas.com/jad]JAD[/url]
[QUOTE=Matthew0505;25804008]Exactly, which means it is hard to optimise. Optimisers can't compensate for bad programming.[/QUOTE] Not entirely true but I know what you mean.
[QUOTE=Robber;25804452]Probably a decompiler like [url=http://www.varaneckas.com/jad]JAD[/url][/QUOTE] JAD sucks try this: [url]http://java.decompiler.free.fr/[/url] Easy and fast.
I think I have a problem with get and set methods in C#. I think they make code less obvious in a sense that you could just be doing something like SomeString = "asd"; when in the background there's a setter method that does some heavy calculations. Is there a special way of indicating that some getter/setter does more than just modify the private value?
[QUOTE=Darwin226;25805186]I think I have a problem with get and set methods in C#. I think they make code less obvious in a sense that you could just be doing something like SomeString = "asd"; when in the background there's a setter method that does some heavy calculations. Is there a special way of indicating that some getter/setter does more than just modify the private value?[/QUOTE] If the getter or setter does calculations which makes it more than a simple getter or setter, use a named method instead which more accurately describes the operation. In other words, no, you're acting by convention only, much like with operator overloads.
[QUOTE=jA_cOp;25805345]If the getter or setter does calculations which makes it more than a simple getter or setter, use a named method instead which more accurately describes the operation. In other words, no, you're acting by convention only, much like with operator overloads.[/QUOTE] But then why can they have bodies? I think they were made to do calculations. Not sure what is meant by "heavy calculation", but stuff like a health property that calls a certain method if it falls below 0, and that limits it at 100, etc.
[QUOTE=Xeon06;25805378]But then why can they have bodies? I think they were made to do calculations. Not sure what is meant by "heavy calculation", but stuff like a health property that calls a certain method if it falls below 0, and that limits it at 100, etc.[/QUOTE] They have bodies so you can seamlessly have more elaborate code for operating on member fields, using it for something else is abusing the reader's trust. I didn't say you should only do a single assignment operation in a setter and a single member field read operation in a getter. What goes in the names "setter" and "getter" is entirely up to you, but like operator overloading, you're bound by common sense if you don't want to obfuscate your interfaces. I agree that your example getter is indeed perfectly justified use of a getter and I'm not going to claim that there are strict guidelines for where the line of common sense is drawn, all I'm telling him is that you're only bound by convention. edit: Quoting [url=http://msdn.microsoft.com/en-us/library/bzwdh01d(VS.71).aspx#cpconpropertyusageguidelinesanchor1]MSDN guidelines[/url] for choosing Properties vs. Methods: [quote] Use a method when: The operation is a conversion, such as Object.ToString. The operation is expensive enough that you want to communicate to the user that they should consider caching the result. Obtaining a property value using the get accessor would have an observable side effect. Calling the member twice in succession produces different results. The order of execution is important. Note that a type's properties should be able to be set and retrieved in any order. The member is static but returns a value that can be changed. The member returns an array. Properties that return arrays can be very misleading. Usually it is necessary to return a copy of the internal array so that the user cannot change internal state. This, coupled with the fact that a user can easily assume it is an indexed property, leads to inefficient code. In the following code example, each call to the Methods property creates a copy of the array. As a result, 2n+1 copies of the array will be created in the following loop. [/quote] Darwin226's example falls under at least point #2.
Fair point about the method call doing stuff, didn't think. Even with a method marked with const you still can't guarantee it doesn't make a change. [QUOTE=Jallen;25803396]The best thing to do is pick a precision level and do something like [code] const float precisionLevel = 0.0001; bool SortOfEqual(float a, float b) { if(abs(a-b) < precisionLevel) return true; return false; } [/code][/QUOTE] I've always been taught to use the epsilon for the "precision level". (C++: FLT_EPSILON, C#: Float.Epsilon.)
SlimDiks porting progress #2 [img]http://s3.amazonaws.com/data.tumblr.com/tumblr_lb9j3h9tTK1qclar3o1_1280.jpg?AWSAccessKeyId=0RYTHV9YYQ4W5Q3HQMG2&Expires=1288796938&Signature=i3GP0GmwEaMtsU4Hini4qdjSJEM%3D[/img] Everything is going smoothly so far :) ( also the GUI stuff isn't finished yet which is why you might find it too blurry )
Anyone know of some good resources for 2D games in java? *wish the teacher would let us use C++ or even C#* [editline]2nd November 2010[/editline] [QUOTE=Xerios3;25805925]SlimDiks porting progress #2 [img_thumb]http://s3.amazonaws.com/data.tumblr.com/tumblr_lb9j3h9tTK1qclar3o1_1280.jpg?AWSAccessKeyId=0RYTHV9YYQ4W5Q3HQMG2&Expires=1288796938&Signature=i3GP0GmwEaMtsU4Hini4qdjSJEM%3D[/img_thumb] [/QUOTE] Hmm very nice :D whats with the sparks? [editline]2nd November 2010[/editline] [QUOTE=Xerios3;25805925]SlimDiks porting progress #2 [img_thumb]http://s3.amazonaws.com/data.tumblr.com/tumblr_lb9j3h9tTK1qclar3o1_1280.jpg?AWSAccessKeyId=0RYTHV9YYQ4W5Q3HQMG2&Expires=1288796938&Signature=i3GP0GmwEaMtsU4Hini4qdjSJEM%3D[/img_thumb] [/QUOTE] Hmm very nice :D whats with the sparks?
[QUOTE=Xerios3;25805925]SlimDiks porting progress #2 [img_thumb]http://s3.amazonaws.com/data.tumblr.com/tumblr_lb9j3h9tTK1qclar3o1_1280.jpg?AWSAccessKeyId=0RYTHV9YYQ4W5Q3HQMG2&Expires=1288796938&Signature=i3GP0GmwEaMtsU4Hini4qdjSJEM%3D[/img_thumb] Everything is going smoothly so far :) ( also the GUI stuff isn't finished yet which is why you might find it too blurry )[/QUOTE] If you are going for something like SlimDX (basically DirectX bindings for .NET, right?) why not use OpenGL instead?
[QUOTE=Darwin226;25806405]If you are going for something like SlimDX (basically DirectX bindings for .NET, right?) why not use OpenGL instead?[/QUOTE] because he wants to use directx i imagine directx is like opengl but nice to use but i use opengl anyway idk
[QUOTE=Catdaemon;25806422]because he wants to use directx i imagine[/QUOTE] Hence the "why" in my sentence...
[QUOTE=Darwin226;25806434]Hence the "why" in my sentence...[/QUOTE] personal preference why use opengl
[QUOTE=Catdaemon;25806468]personal preference why use opengl[/QUOTE] I smell an argument :ohdear:
[QUOTE=Jallen;25803396]The best thing to do is pick a precision level and do something like [code] const float precisionLevel = 0.0001; bool SortOfEqual(float a, float b) { if(abs(a-b) < precisionLevel) return true; return false; } [/code][/QUOTE] [code] bool AreEqual(float a, float b) { return ((int)a).ToString() == ((int)b).ToString(); } [/code] :pseudo:
[QUOTE=Catdaemon;25806468]personal preference why use opengl[/QUOTE] I'm not proposing he uses OpenGL, I'm asking why not. I realize that maybe he doesn't need the game to be multi platform, but if he later decides otherwise he'll have to port it to something else again.
[QUOTE=Richy19;25806323] Hmm very nice :D whats with the sparks?[/QUOTE] Just test sparks nothing special =) [QUOTE=Darwin226;25806405]If you are going for something like SlimDX (basically DirectX bindings for .NET, right?) why not use OpenGL instead?[/QUOTE] Well I find DirectX much easier atm since I'm used to XNA's work flow. Who knows, I might make a OpenGL port in the future =)
Sorry, you need to Log In to post a reply to this thread.