Advertisement Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

722 Good

About RipTorn

  • Rank
  1. Hello, my name is Graham Aldridge. It's been nearly 4 years since I last posted on, so I thought I'd share what I've been up to: Xen is my XNA based API. With an emphasis on high performance 3D, Xen is designed specifically to make XNA code faster, easier to write and less error prone. The project includes a whole bunch of tutorials. New to 1.8 is a large tutorial detailing character relighting; covering topics such as HDR compression, gamma correction, tone mapping, spherical harmonics, etc: Xen does many things to help improve efficiency and automate tedious, error prone tasks. For example, in Xen HLSL shaders automatically generate .NET binding classes. This helps you catch errors much earlier, and it eliminates complex string based property assignment (a Vector4 defined in a shader is a Vector4 property in the binding class). The project also includes a set of optional classes for Animated models, GPU accelerated particle systems and a number of other useful tools. It's open source, and works on both Windows and the Xbox360 I greatly appreciate all feedback, and I love seeing the cool things people create with it [cool] Thanks for reading [smile] Here is another picture from the HDR lighting tutorial: [Edited by - RipTorn on April 11, 2010 8:08:40 AM]
  2. Be wary of any 'free' sms service. Unless they are directly tied to a carrier these companies have to make money somehow - there is no charity - so do not be surprised if you or the people you text start to receive unwanted attention. For example the privacy policy and terms of service pages for '' are blank. And why would a company based in chicago need to register their website in romania? Also it's a previously expired domain - that has only *very recently* been put up. Honestly I wouldn't *ever* trust them with any sensitive information, phone numbers etc. Consider how they are making money? Clickatell on the otherhand has a contact address, customers, privacy policy, a real logo - and their site has been on the web for 7 years.
  3. My understanding is that some extra stuff happens under the hood for threads that run .net code (I guess due to requiring communication with the GC and it's thread, etc). So, the moment you have .net code run on your process thread, you lose the ability to set thread affinity. What is the return value? I'm guessing it's zero. Anyway. I also wonder why you are doing this? You shouldn't be setting thread affinity for performance reasons, if anything it'll only make things slower - the OS is really good at managing threads, especially in vista. Unless you have some very specific code that requires it, I'd say you'd be better without it. Quote: msdn: In most cases, it is better to let the system select an available processor. Process affinity on the otherhand should work fine. If that isn't working, well, I'm not sure what is going wrong. Even so it's still better to leave it up to the OS (in my opinion :))
  4. RipTorn

    [.net] code security?

    I used to be concerned that .net didn't 'protect' my code. Then again C++ doesn't either. Frankly, I now think it's an utterly pointless endeavour. An application by it's nature must be decoded (to run!) so there is no sense in trying to do this. That said data security and data encryption is a very, very valid problem - and something that takes a lot of thought. Usually what it comes down to is knowing if something is legitimate and communication encryption - ie private key encryption/signing of data and signed your code. Let people do what they will with the code (and even data in some cases), just make sure it cannot be recognised as genuine. Unfortunately this requires remote server communication, where the private key is stored (securely), and where some validation occurs.
  5. class boxed<T> where T : struct { public T value; public boxed(T v) { value = t; } } The nature of value types is that they are always temporary in nature when you actually do things with them. Auto boxing won't help either, and dealing with objects as your data type is a very very bad idea. The thing is, if a method takes in an object, which is actually a boxed float, then you can't actually change it. You will be making a reference change, creating a new boxed float, not making a value change (as a ref float would).
  6. Not a direct answer, but might help with your performance issues: Apparently most digital cameras will embed a thumbnail in the image tags:
  7. afaik typeof() and GetType() are both extremely fast, and always return the same object. But in any event you really shouldn't care. If you find your application slowing down, profile it! you will then find it's something totally unexpected.
  8. RipTorn

    [.net] byte [] to an IntPtr

    Quote:Original post by Fiddler For large arrays you should not copy elements around. In this case, if you do not want to resort to unsafe code, use the following snippet: GCHandle h0 = GCHandle.Alloc(array, GCHandleType.Pinned); try { // h0.AddrOfPinnedObject() will get you your IntPtr } finally { h0.Free(); } Awesome. Where/how did you find/figure this out? [smile] This is by far the best way, and safe provided you don't buffer overrun I guess
  9. RipTorn

    [.net] trying out tao

    Quote: what is involved in deployment, to make a tao C# app run on another computer what is required aside from .net framework / mono, do i just make sure to include the appropriate dll's or is there a automatic way to ensure dependences are dealt with or what? You need to include the Tao.* dll and their native equivalent that are non-standard (which is basically all of them). So Tao.DevIL will require you include the devIL native dlls in the project too (as a copied content file works well, not a reference)... glut32 is used by tao.opengl too I think (yet isn't standard). As for tao .dlls themselves, some are very large (eg opengl). What I did here was zip them all up, and include them as a content resource in the project. I then handle the AppDomain.AssemblyResolve event to trigger loading of the .dlls from the included .zip. Quote: what are some good tutorials for using the tao framework with C#? From memory there are loads of samples with the tao distribution. Quote: what consideration are their for cross-platform compliance, to make a C# app that can run on mono in linux or osx, are there any special consideration i need to be aware of? This should be covered in the Tao docs. There are (or at least used to be) differences in compiling Tao. And of course differences at the wrapped API level are still there (eg WGL in opengl).
  10. RipTorn

    [.net] byte [] to an IntPtr

    Assuming you are using C#, I believe the best way is as follows, using the System.Runtime.InteropServices.Marshal class: byte[] data = ...; IntPtr ptr = Marshal.AllocHGlobal(data.Length); try { Marshal.Copy(data,0,ptr,data.Length); //deal with ptr } finally { Marshal.FreeHGlobal(ptr); } There are very few cases where you need to use unsafe code. This is not one of them. This is far, far safer (not that pointers are safe at all). It is also debatable if it's actually any slower. UnsafeAddrOfPinnedArrayElement is dangerous as the address in memory of the array may well change at any time. It is intended for use with pinned memory in C++/Cli (as is my understanding) It also does *not* validate the input is pinned. Apparently you can pin memory in C# using GCHandle, but I haven't done this before, so I don't know how safe it is - and importantly I can't see how you pin an Array, not an IntPtr. So in summary I don't think it's a safe option. GCHandle gch = GCHandle.FromIntPtr(ptr); .. gch.Free();
  11. Microsoft.DirectX.Direct3D.CustomVertex.TransformedTextured.StrideSize DO NOT USE UNSAFE CODE UNLESS YOU ABSOLUTELY NEED IT. And if you think you need it, you almost certainly don't. [wink][wink][wink][wink][wink]
  12. Some of these are hints and tricks.. but still good to know :-) Not a class but syntax: have you ever done this? if (myString != null) return myString; else return "Empty"; well.. how about: return myString ?? "Empty"; Both are equivalent [wink] System.BitConverter and System.Buffer are very useful for bit/byte manipulation. Need memcpy? Marshal.Copy(). A lot of operators work on integers by default, ie 1 << 15 will be integer. However so will 1 << 42. This will actually be the same as 1 << 10. However 1L << 42 will be fine. Bytes always get converted to integer when doing bitwise operations on them. unchecked and checked blocks: checked { byte b = 255; b++; // exception, overflow } can also be used in an equation: int z = checked(b+100); There is a very subtle issue with floating point byte conversions. If you have a float array, and want to manually set a value in that array (as 4 bytes) - eg, you are dumping byte RGBA colours into a float array.. BitConverter.ToSingle() won't work... In the event the bytes are X Y Z 255, the resulting float is NaN, which automatically gets converted to X Y 240 255 (iirc). The way to get around it is by using Buffer.BlockCopy() to copy an array with the 4 bytes into the float array. This one took a while to track down. For threading, AutoResetEvents and ManualResetEvents are awesome. As are ReadWriteLocks. If you have a large number of tasks running, and you want to react when one finishes, you can do: WaitHandle[] handles = {threadOneCompletedTaskEvent,threadTwoCom.... }; while (tasksToDo) threads[WaitHandle.WaitAny(handles)].AssignNextTask(...); Each handle will be an AutoResetEvent in this case. There will be another autoreset event that signals the worker to start up again (set in AssignNextTask). Use WaitHandle.SignalAndWait(..,..); when a task finishs. Never have ushort,ubyte,uint or ulong as parametres for public methods. Unless: you have them as an overload with the following attribute: [CLSCompliant(false)] Self managed events... What may not be obvious is that a Property can be an event too... This is *really* useful for roll-your-own events. public event MyEventHandler MyEvent { add {} remove {} } AppDomain.CurrentDomain has some very useful events. such as: AppDomain.CurrentDomain.AssemblyResolve If .net can't find an assembly you reference, it will call this event (instead of crashing). You can load it manually with Assembly.Load() here if you want (say, from a .zip file - to keep your app nice and small) AppDomain.CurrentDomain.UnhandledException Should be obvious :-) - although use it as a last resort Assembly.Load(byte[]) does not correctly load assembly evidence, however Assembly.ReflectionOnlyLoad(byte[]) does. So you can call Assembly.ReflectionOnlyLoad, then use the evidence in Assembly.Load(byte[],assembly.Evidence,...) Sometimes, you want to scan all the .dll files your application has, and find all classes implementing an interface (or class, etc). Eg you might have an editor, and it wants to know what entities it can let you add. Here is how to do it: Store the interface/class that you want to scan for in it's own assembly. This should probably be *recursive* foreach (AssemblyName an in current_assembly.GetReferencedAssemblies()) { Assembly assembly = Assembly.ReflectionOnlyLoad(an.FullName); if (assembly.GetReferencedAssemblies().Contains(interface_assembly_name)) { assembly = Assembly.Load(an.FullName); foreach (Type t in assembly.GetExportedTypes()) { if (interface_type.IsAssignableFrom(t)) types.Add(t); } } } This will be *MUCH* faster than loading every .dll in the directory, or similar operations. When using XML classes, eg XmlElement, do not use SelectNodes() or SelectSingleNode(), as these use xpath (I think). Use GetElementsByTagName(). Want to confuse someone? Have a Queue filled with delegates: if (taskQueue.Count > 0) taskQueue.Dequeue()(); System.Array has loads of useful static methods. Such as Array.Resize() [wink] System.Activator can be used to create objects from a type. You can also do this by using reflection to get the ConstructorInfo of a Constructor on a type. This can even be done for remote objects over the web. System.Environment contains loads of stuff. there are of course loads and loads more. I'm just browsing some of my code and picking out interesting things. [Edited by - RipTorn on March 25, 2007 11:42:10 AM]
  13. Select the file in the list, Properties, Set 'Build action' to Content, then set 'Copy to output directory' to 'copy if newer'
  14. as dalep said, there are two interfaces for IComparer, IComparer and IComparer<T> Dont use the templated interface, just use the old object based one. so do: private void Sort(TreeNode node, ref IComparer group_comp, ref IComparer item_comp) not private void Sort(TreeNode node, ref IComparer<ToDoGroup> group_comp, ref IComparer<ToDoItem> item_comp) Either that or implement the non generic IComparable interface on the base class, and call Sort() without any comparer.
  15. I probably should of added: you use it like so: RichTextConstructor rtc = new RichTextConstructor("Courier New", 20); //font ... rtc.AddSegment("hi",Color.Black,Color.White); // black 'hi' with white background rtc.AddSegment("yay",Color.Green,Color.Purple); //green 'yay' with purple background myRichTextBox.Rtf = rtc.ConstructRichTextString(); rtc.Clear(); //can now do it again very basic. but did the job for my needs (and way faster than using methods in the richtextbox class)
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. 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!