Vankwysha
Squire
Australia
43 Posts |
Posted - Jun 15 2005 : 01:49:52 AM
|
I'm a total Direct3D n00b, and due to the small number of tutorials that I've been able to find on using D3D to draw 2D graphics, I'm posting yet again.
I've followed all of the tutorials to the letter, and D3D initialises fine, and I can even display a sprite, but when I try to exit the program, I get a NullReferenceException. I can't figure out why!!! I've used stubs, flags, debug output lines, made sure that I dispose of everything and it still doesn't work!!! GRRRR!!!! So, anyway, I've uploaded my source code and if anyone can tell me what the blatantly obvious problem that I'm sure is right under my nose is I would be very grateful. This is not really a major problem I know, but I think it would be incredibly sloppy to leave my engine like this, especially as I plan to DLL it and use it again.
Download Attachment: Engine Source Code.txt 5.55 KB |
|
ardman
Squire
15 Posts |
Posted - Jun 15 2005 : 02:25:39 AM
|
I think that your problem is in your Do Loop. At the end of it you are using Frm.Ending. Change this to:
Loop Until Ending
You've set your variable Ending in the form key press. This should help. If not, it's because your dispose a form whilst it's still shown. You don't need to do this.
|
Cheers! :) |
|
|
Vankwysha
Squire
Australia
43 Posts |
Posted - Jun 15 2005 : 04:33:27 AM
|
The reason that I have to use Frm.Ending is because sub Main is shared. Because I put sub main in the form class, and main is meant to execute before the form exists, it is effectively outside the form, so I have to refer to the Ending variable as Frm.Ending, as it is within the frmMain namespace. I've tried basically every combination of Frm.Dispose, Frm.Close, End and just about every other "ending" procedure that I know of to no end. |
|
|
ardman
Squire
15 Posts |
|
Vankwysha
Squire
Australia
43 Posts |
Posted - Jun 15 2005 : 5:19:00 PM
|
I've tried that, but when I use End, not only does it not quit but it doesn't actually do anything. I press escape and it just freezes. Something weird did happen though; I tried moving my sub main into a separate module. When I did, the program worked once absolutely fine and then stopped working. I'm wondering if this has something to do with the memory or the way directx stores its sprites.... |
|
|
Vankwysha
Squire
Australia
43 Posts |
|
Lachlan87
Moderator
USA
160 Posts |
|
Vankwysha
Squire
Australia
43 Posts |
Posted - Jun 17 2005 : 08:47:35 AM
|
I tried that, and it worked a couple of times, but now it's stacked. I'm wondering if there's something wrong with my D3D dll or something. I'll try downloading the SDK again. |
|
|
Threshold
Squire
USA
44 Posts |
Posted - Jun 17 2005 : 2:38:42 PM
|
Why don't you just use the standard "running" flag for your main class? Set it to true when everything initializes correctly and then loop until it's false. When exiting simply set it to false. Also, I'm not sure if it's the same with VB.NET, but in VB6, using "End" is not a smart idea as it doesn't terminate classes. |
Life is short. They say "don't waste it, have fun." They're right, don't waste it...but DO redefine "fun." |
|
|
Vankwysha
Squire
Australia
43 Posts |
|
Vankwysha
Squire
Australia
43 Posts |
Posted - Jun 21 2005 : 8:42:36 PM
|
I've moved and adjusted my use of the Dispose() methods of my various devices, and it appears to be fully functional. However, I don't wish to raise my hopes to soon. If it keeps working, thank you all for your help. |
|
|