• Create Account

### #Actualvanattab

Posted 26 September 2012 - 06:06 AM

NOTE: For technical reasons I need to target DX9 (not 10/11), I am offering $25 total via PayPal to any poster(s) who provide help leading to a resolution of this issue. I know that's not much but I am very poor and hopefully that is at least enough incentive to read my ridiculously long post. I am having some trouble with figuring out how I should structure my program. I will first describe the general description of my program and then go into the things I have tried and the issues I have run into. I am not developing a game but rather a suite of computerized tests to test human vision. I am writing the program in VB.Net but converting between .Net languages is relativity trivial so if your going to post some code don't go out of your way to post it as VB if your better with C#. Even examples in other languages would be appreciated. I know the post is a little long but I want to be as clear as possible about the issues I am having. Thanks in advance! Design: The program lunches a “Main Menu” VB.Net form that has lots of options to select different types of test and configure different options for the tests. When the user clicks the RunTest button for a specific test a TestObject representing that test is created. The TestObject constructor creates a StimulusDisplayObject(SDO) which is derived from the SlimDX RenderForm class. The job of the SDO class is to manage the SlimDX device object and render the different stimuli to the screen. It contains a list of StimulusObjects(SO) which are essentially just a DX surface that was loaded from an .bmp image and some location information that to tell the SDO class where to draw the surface on the screen. After the SDO is created the TestObject.BeginTest() method is called that is just a loop that presents a number of trials to the observer. The loop creates some SO objects and adds them to the list of SO objects of the SDO class to be displayed. Problems: Because the stimuli I preset for the tests is fairly static and I usually only had to change the image that was displayed to the screen once every sec or two at the most, I did not have the scene rendering continually at as high of an FPS as possible. I simply had a SDO.RenderScene() that would get called from the TestObject whenever something need to be changed on the screen. This worked pretty well until I tried to handle DeviceLostExceptions and similar issues I arise from when the user ALT-TABs, CTRL-ALT-Delete, Covers the window (when in windowed mode), etc..) I have not found an effective way to handle these types of errors without having the scene continually rendering. So I decided to try rewriting the SDO class to use SlimDXs MessagePump.Run() functionality to render the scene constantly, however this causes exceptions because The MessagePump.Run() conflicts with the MessagePump of the “Main Menu” Form (At least I think that is what this error message means: “Additional information: Starting a second message loop on a single thread is not a valid operation.”). I decided to try creating the SDO object in a new thread but then I can't communicate between the the TestObject and the SDO Object to add/remove/change the SO objects. I am not 100% sure that creating a multithreaded application is the best approach because I have read that DX and Threading leads to programing nightmares but I don't see any other solutions. I think I need to learn to use some kind of thread synchronization but I am very very new to threading and I want to make sure I am not heading down a road that is doomed to fail before I invest a long period of time learning to synchronized threads. If creating a multithreaded application is the best choice is there any DX/SlimDX threading issues I should be aware of? Any examples of simple SlimDX threaded programs that synchronize data across threads? Thanks for taking the time to read this post and I will extremely grateful to any advice you can give. ### #1vanattab Posted 25 September 2012 - 11:40 AM NOTE: For technical reasons I need to target DX9 (not 10/11), I am offering$25 total via PayPal to any poster(s) who provide help leading to a resolution of this issue. I know that's not much but I am very poor and hopefully that is at least enough incentive to read my ridiculously long post.

I am having some trouble with figuring out how I should structure my program. I will first describe the general description of my program and then go into the things I have tried and the issues I have run into. I am not developing a game but rather a suite of computerized tests to test human vision. I am writing the program in VB.Net but converting between .Net languages is relativity trivial so if your going to post some code don't go out of your way to post it as VB if your better with C#. Even examples in other languages would be appreciated. I know the post is a little long but I want to be as clear as possible about the issues I am having. Thanks in advance!

Design: The program lunches a “Main Menu” VB.Net form that has lots of options to select different types of test and configure different options for the tests. When the user clicks the RunTest button for a specific test a TestObject representing that test is created. The TestObject constructor creates a StimulusDisplayObject(SDO) which is derived from the SlimDX RenderForm class. The job of the SDO class is to manage the SlimDX device object and render the different stimuli to the screen. It contains a list of StimulusObjects(SO) which are essentially just a DX surface that was loaded from an .bmp image and some location information that to tell the SDO class where to draw the surface on the screen. After the SDO is created the TestObject.BeginTest() method is called that is just a loop that presents a number of trials to the observer. The loop creates some SO objects and adds them to the list of SO objects of the SDO class to be displayed.

Problems: Because the stimuli I preset for the tests is fairly static and I usually only had to change the image that was displayed to the screen once every sec or two at the most, I did not have the scene rendering continually at as high of an FPS as possible. I simply had a SDO.RenderScene() that would get called from the TestObject whenever something need to be changed on the screen. This worked pretty well until I tried to handle DeviceLostExceptions and similar issues I arise from when the user ALT-TABs, CTRL-ALT-Delete, Covers the window (when in windowed mode), etc..) I have not found an effective way to handle these types of errors without having the scene continually rendering.