
reanjr
Members-
Posts
19 -
Joined
-
Last visited
Personal Information
-
Visual Studio .NET Version
Visual Studio .NET 2003 Enterprise Edition
-
.NET Preferred Language
VB.NET
reanjr's Achievements
Newbie (1/14)
0
Reputation
-
I was actually hoping to sort them the other way. If you draw from front to back, then alot more polygons will be cut out due to the z-buffer; you would only draw to each pixel once. I wanted to play around with the idea for performance reasons. It seems that a scene with only a few translucent polygons would render better front to back with a stencil buffer, while one with lots of translucent polys would run better back to front with the more efficient alpha. In addition you could play with only doing real easy (processor wise) sorts and not worrying about testing certain polys which may or may not be an efficient way of doing things, I'm not sure. I was just kind of floating the idea around and wondering if anyone else has tried it or thinks it might work in some cases. For instance what I am working on right now will rarely have translucency, so it would be nice to be able to speed up the rest of the engine for when there aren't. It's still in the early stages which is why I haven't really tested the theory.
-
Has anyone tried/had any success with using the Stencil Buffer to do Translucency. The primary benefit as I see it would be that you wouldn't have to render polygons behind a transluscent object prior to rendering the transluscent object. It seems like this would be a viable way of doing a front to back method of transluscency, but I've never heard of it, so I was wondering if anyone else has seen it done.
-
Blocking Element - Tetris like game using GDI+
reanjr replied to wyrd's topic in Graphics and Multimedia
Huh... that's odd. In VB, CurrentThread.Sleep exists, but in C# it doesn't seem to. Oh... if the app isn't already multithreaded, you should try to do that. Two or three threads (maybe one for user input/form, one for main game loop, and one for drawing) in conjunction with some ThreadPriority tweaking could increase performance greatly. If you're not familiar with doing multithreaded development it can be a bit of a bear to grasp, but it is well worth it. For instance, the actual game loop I imagine is mostly waiting on its frame incrementer (whatever tells it it's time to do a new frame). If that had its own thread, it could be told to sleep for 10 milliseconds or before checking to see if it's ready to do something (which I imagine takes far less than 10ms). And/or it could be set to a low thread priority, giving the Drawing loop more time to do its thing when it needs to. I've never done multithreaded development in C#, so I'm not quite sure how to go about doing it, but judging from VB, it's very clean, it just introduces some new complications. Oh, and System.Threading.Mutex is your friend (it took me a while to figure out that existed, meanwhile I was writing my own) -
Blocking Element - Tetris like game using GDI+
reanjr replied to wyrd's topic in Graphics and Multimedia
There is something very unintuitive about the game play that I'm not sure I can fully place. I do have a suggestion for improvement though. Once a block is in the corner, it's done for. There's no way to get rid of it. And, of course, accidental maneuverings will sometimes cause more blocks to get next to it, in turn becoming indestructible. There should be some kind of mechanism to get rid of these blocks if they are unwanted. Perhaps a special block that destroys all surrounding blocks or something. P4 2.6GHz Hyperthreaded with 512 MB DDR runs at very steady 33 FPS. Also takes up 50% of the processor. I'm sorry I didn't bother looking at the code, but there probably needs to be some System.Threading.Thread.CurrentThread.Sleep() commands placed in a few places. I have a feeling the program eats up the processor just waiting for its turn to do something. Can I do something? No... Ok... How about now? No... Ok... How about now? No... Ok... How about now? No... Ok... How about now? No... Ok... How about now? No... Ok... How about now? No... Ok... -
There is one time you would need to use it. If you plan on running the program through a Command Window, of course. But this also includes if you are telneting to the machine or sshing to the machine. Both of these use the Console.
-
I do not believe you can distribute any software you create with VS.NET Academic, whether you sell it or give it away.
-
Sounds like you played with the section labeled Windows Form Designer generated code. The Sub New you are referring to, what class does it inherit from? And is the MyBase.New() the first think that runs when you begin debugging by stepping into the code?
-
In short, the answers to your questions are: 1. As far as I know, you have to use something outside of the .NET framework to do so. 2. I do not believe there is a way to do this. Windows sends mouse messages whether you want them or not. 3. Use the Bitmap's Dispose method before it goes out of scope or is set to a new Bitmap. At length, the answers to your questions are: The following should give you something else to think about: Remove the PictureBox Set Form1.FormBorderStyle to None Try this: Private Pics() As String Private position As Int16 Private bmpCurrent, bmpOld As Bitmap Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.CenterToScreen() Pics = System.IO.Directory.GetFiles("C:\Fractals") position = 0 bmpCurrent = Bitmap.FromFile(Pics(position)) End Sub Private Sub Form1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyUp Me.Close() End Sub Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove Static bCaughtMove As Boolean If bCaughtMove Then Me.Close() Else bCaughtMove = True End If End Sub Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint e.Graphics.DrawImage(bmpCurrent, 0, 0) End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick position += 1 If position = Pics.GetUpperBound(0) Then position = 0 bmpOld = bmpCurrent bmpCurrent = Bitmap.FromFile(Pics(position)) bmpOld.Dispose() Me.Refresh() End Sub This is what I did: I changed the global variables to Private instead of Public. Just a good habit. 1. I moved all of the Painting/Pictures directly to the form. No need to worry about mouse events on the PictureBox anymore. 2. Put the MouseChecking variable into the Mouse Event Handler. It's a bit cleaner that way. As far as I know there is no way to flush it. 3. Now the bitmap is drawn during the Form's Paint event. When updating the picture what I did was set bmpOld to whichever bitmap was currently being used. I then set bmpCurrent to the new pic about to be displayed. I then call Dispose on bmpOld. This is why you had a memory leak. Any Class that implements the IDisposable Interface (quickest way to check is to just see if it has a Dispose Method) does not clean itself up automatically. You have to call the Dispose method to get it to clean up internal resources (in this case an HBITMAP Windows API Structure). The reason I didn't simply call bmpCurrent.Dispose and then set it to the new one is because that might cause problems if the form's Paint event went off while it was loading the new one. 4. Sorry if I was a bit lengthy, but I like to espouse good coding practices whenever possible. The more people who code in a clean, structured (possibly Object Oriented) manner, the more code there will be around for others to see and understand.
-
I just want to make sure you know that that pattern will match the following string: ...RUNDLL32 1ST PROBLEM I FORESEE... It will match the "LL32 1ST" part of it If you would like to make it a bit more robust, you might want: \b[A-Z]{1,2}\d{1,2}\s{1,3}\d[A-Z]{2}\b I'm not familiar with the English post codes, but are all of the following valid? These would all be caught by the expression A1 2BC DE3 4FG H56 7IJ KL89 0MN
-
Easier method that just as efficient: ---------------------------------------------------------------- System.Threading.Thread.CurrentThread.Sleep(0) ---------------------------------------------------------------- Sleeps the thread and allows waiting threads to execute. Downside is you could lose a tiny bit of performance on the game loop when there is no user activity, but this shouldn't be a problem since your code is really just looping to wait on something anyway.
-
If you are running VS.NET 2002, this is an issue I've heard about from MS. If you are running VS.NET 2003, not only does it do it alot quicker, but there are some advanced options in there to make it even snappier (somehow you can have the IDE ignore certain projects or some such thing; I really do not recall)
-
/* This should work. I tried it in VB real quick, but not C# Should be a lot quicker than the other version as well Warning: may have problem with signed integers I don't know how .NET treats them on bit shifts */ val = (val << 1) | (val >> 31);
-
Try something along the lines of i = (i << 1) | (i >> 31);
-
I wanted to make a quick addendum. If you know some of the indicated information you may be able to ascertain the rest through complex trigonometry. May I ask why you are doing this? I can't seem to think of a reason to, since you usually know the information or you wouldn't have been able to create the matrix.