Important alert: (current site time 7/23/2014 3:29:21 PM EDT)
 

winzip icon

Managed DirectX9 Graphics Example

Email
Submitted on: 1/6/2005 12:39:34 PM
By: Erik Jackman  
Level: Advanced
User Rating: By 5 Users
Compatibility: VB.NET
Views: 24778
author picture
 
     Engine Features: Enumeration of the display device, resolution modes available to the selected display device, refresh rates available to the selected resolution, color depth available to the selected resolution, pixel/vertex shader versions, texture filter modes for minify, magnify, and mip map. Configures display device based on saved settings or defaults. Dynamically creates lights. Load Direct3DX Meshes into memory. Dynamically draws each mesh from one algorithm; Scales, rotates, and positions the mesh. Dynamically positions and faces the camera. Can count FPS. Draws text. World Editor Features: Viewport is drawn through the engine on a separate thread. Dynamically create static meshes through the engine. Dynamically create lights through the engine. Dynamically draws each mesh through the engine. Update: Lights can be moved, rotated, color changed, and type changed. The HUD can also now display what device mode the engine is using. Fixed some bugs.

 
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
//**************************************
// for :Managed DirectX9 Graphics Example
//**************************************
This code may not be used towards commercial use.
winzip iconDownload code

Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.Virus note:All files are scanned once-a-day by Planet Source Code for viruses, but new viruses come out every day, so no prevention program can catch 100% of them. For your own safety, please:
  1. Re-scan downloaded files using your personal virus checker before using it.
  2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.

If you don't have a virus scanner, you can get one at many places on the net including:McAfee.com

 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.


Other 2 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Advanced category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

1/7/2005 11:11:40 AMErik Jackman

Please rate this if you found it useful.
(If this comment was disrespectful, please report it.)

 
1/7/2005 4:28:57 PMEnderBeta

Nice job on the use of a seperate dll to handle all the generic tasks. I especially like the use of DrawMesh and how it can dynamicly update the render loop.

I'm hoping you'll update this as you continue working on it. =)
(If this comment was disrespectful, please report it.)

 
1/12/2005 6:11:16 PMErik Jackman

updated it:

Lights in the toolset now have meshes drawn on screen to help you visualize the light.

Lights and Meshes can now be saved to a xml file.
(If this comment was disrespectful, please report it.)

 
1/15/2005 2:45:47 AMErik Jackman

The meshes can now have basic animation setup for the transforms.
(If this comment was disrespectful, please report it.)

 
1/21/2005 6:30:35 PM

The thread 'DrawViewportThread' (0xc70) has exited with code 0 (0x0).
'SentinelToolSet.exe': Loaded 'c:\windows\assembly\gac\mscorlib.resources\1.0.5000.0_it_b77a5c561934e089\mscorlib.reso urces.dll', No symbols loaded.
Application error.
-2005530516 (D3DERR_INVALIDCALL)
at Microsoft.DirectX.Direct3D.BaseMesh.DrawSubset(Int32 attributeID)
at Sentinel.Engine.Graphics.DrawMesh(Objects3D theObject, Vector3 Position, Vector3 Direction, Vector3 Scale) in C:\Documents and Settings\marcello\Desktop\Mercury\Sentinel\Engine.vb:line 1218 - Errore dell'applicazione.
Something bad happend drawing a mesh
Errore dell'applicazione.
-2005530516 (D3DERR_INVALIDCALL)
at Microsoft.DirectX.Direct3D.BaseMesh.DrawSubset(Int32 attributeID)
at Sentinel.Engine.Graphics.DrawMesh)


WHATS THE mATTER?????
(If this comment was disrespectful, please report it.)

 
1/21/2005 11:25:12 PMErik Jackman

Did this happen when you tried to make a RAH66? If so then it most likely the drawviewport thread tried to draw a mesh before it completed loading. I've been working on a update and so far I'm pretty sure that suspending the drawviewport thread while meshes are being loaded solves the problem. Give me a second and I'll post an update.
(If this comment was disrespectful, please report it.)

 
1/22/2005 12:42:47 AMErik Jackman

update: added a suspend and resume comand to control the viewport thread while loading a mesh to prevent the render pipeline from trying to draw a mesh still equal to nothing.
(If this comment was disrespectful, please report it.)

 
1/22/2005 7:16:25 AM

no it happens when i tried to resize the form. i only have a black viewport.your udate hava a series of compilation bug.....check it
(If this comment was disrespectful, please report it.)

 
1/22/2005 7:26:04 AM

sorry its allright ... compiled ... this is the message now

Application error.
-2005530516 (D3DERR_INVALIDCALL)
at Microsoft.DirectX.Direct3D.BaseMesh.DrawSubset(Int32 attributeID)
at Sentinel.Engine.Graphics.DrawMesh(Objects3D theObject, Vector3 Position, Vector3 Direction, Vector3 Scale) in C:\Documents and Settings\marcello\Desktop\Mercury\Sentinel\Engine.vb:line 1218

in any situation i have a black viewport ... damend


(If this comment was disrespectful, please report it.)

 
1/22/2005 7:27:06 AM

another strange thing .... i dont see the mousepointer that i see in your screensot!
(If this comment was disrespectful, please report it.)

 
1/22/2005 7:31:24 AM

in my opinion there is an error with the Handle of the viewport pictures ....
(If this comment was disrespectful, please report it.)

 
1/22/2005 7:38:00 AM

an error in the drawmesh .... routine
(If this comment was disrespectful, please report it.)

 
1/22/2005 11:30:39 AMErik Jackman

This is after all what ammounts to an alpha build. I can assure you though that there are no syntax errors in the code. What version of DirectX9 managed do you have? Can you please tell me what you where doing that got the second error message you posted?

The way it works right now, the camera doesn't start off properly. It's not a big deal, I'll mess with that later. In the mean time all you have to do to see the meshes is go to the edit tab and move the camera position on the x axis to -130. If you still don't see anything make sure you've created a directional light. I've got to look into why the spot and point light types aren't working properly.

Also the arrow mesh in the picture isn't the mouse cursor. Thats a directional light.

Can you please put all of your thoughts into one feedback next time. =)
(If this comment was disrespectful, please report it.)

 
1/22/2005 4:57:10 PM

C:\Documents and Settings\marcello\Desktop\Managed_Di1842701212005\SentinelToolSet\frmMeshSelect.vb(276): 'NumTextures' is not a member of 'Sentinel.Engine.Graphics'.

C:\Documents and Settings\marcello\Desktop\Managed_Di1842701212005\SentinelToolSet\SentinalMain.vb(3694): 'StaticMesh' is not a member of 'Sentinel.Engine.Graphics.MeshObject'.
sample of compilation errors
Managed DirectX9 Version: Managed_Di1842701212005.zip

(If this comment was disrespectful, please report it.)

 
1/22/2005 5:55:02 PMErik Jackman

Ok I figured out what going on.

To fix the errors your getting you need to load up the sentinel dll. I'll post a new build. However if you want to get it running right now follow these simple steps.

1)Open SentinelToolset project
2)right click the solution and click add existing project.
3)Point the dialog box to the Sentinel project and add it to the solution.
4) Do the same for the CollapsibleGroupBox project.
(If this comment was disrespectful, please report it.)

 
1/22/2005 6:16:33 PMErik Jackman

Alright, download the file again and go into the UrbanMetal folder and open the UrbanMetal Soltion file.
(If this comment was disrespectful, please report it.)

 
1/22/2005 8:07:37 PM

Hi Erik!
This is the error. Now .... directly after the splash screen ..

Application error.
-2005529767 (D3DXERR_INVALIDDATA)
at Microsoft.DirectX.Direct3D.Font..ctor(Device device, Font font)
at Sentinel.Engine.Graphics.InitGraphics(Boolean Fullscreen, IntPtr wHandle) in C:\Documents and Settings\marcello\Desktop\Managed_Di1843051222005\SentinelToolSet\Sentinel\Engine.vb:lin e 1728 - Errore dell'applicazione.



(If this comment was disrespectful, please report it.)

 
1/22/2005 8:29:42 PMErik Jackman

Some times it doesn't properly start. I
haven't narrowed down all the grimlins.
Does it do that every time you start it?

Also make sure you don't have a app open thats using the graphics card already.
(If this comment was disrespectful, please report it.)

 
1/23/2005 5:23:22 AM

In my opinione we use different version of DirectX Managed .... infact i already have a compilation error .. on the line that commit the Light object modifications.

.Commit() is not a member of DirectX.Light ... bla bla bla

another problem is the DrawMesh sub ... i'm trying to debug it ... your code is very interesting.

This is the error:
Errore dell'applicazione.
-2005530516 (D3DERR_INVALIDCALL)
at Microsoft.DirectX.Direct3D.Device.GetTransform(TransformType state, Int32* result)
at Microsoft.DirectX.Direct3D.Device.GetTransform(TransformType state)
at Microsoft.DirectX.Direct3D.Transforms.get_World()
at Sentinel.Engine.Graphics.DrawMesh(Objects3D theObject, Vector3 Position, Vector3 Direction, Vector3 Scale) in C:\Documents and Settings\marcello\Desktop\Managed_Di1843051222005\SentinelToolSet\Sentinel\Engine.vb:lin e 1289 - Errore dell'applicazione.

All the errors resolve a NullReference ....


(If this comment was disrespectful, please report it.)

 
1/23/2005 10:08:48 AMErik Jackman

I'm using version 1.0.900.0 of directx9 managed. What version are you using?
(If this comment was disrespectful, please report it.)

 
1/25/2005 2:53:44 PM

nothing nothing ..... i'm using same version but .... something dont work
(If this comment was disrespectful, please report it.)

 
3/5/2005 1:34:35 PMAleksey Gladfish

I use Visual Basic 2005 Beta (cuz I like it better) and this doesn't work right with 2005, can you make a compatible version? Thank You. God Bless!
(If this comment was disrespectful, please report it.)

 
10/3/2005 10:54:13 PMErik Jackman

Aleksey Gladfish, can you describe how it isn't working? I don't have Visual Studio 2005. I've been really busy as of late with my Crestron certification and work. I'll be trying to set some time aside for this project once again, but I can't promise it will work for Visual Studio 2005 without you going through and changing code to make account for any changes in the environment between 2003 and 2005 versions of VS .Net.
(If this comment was disrespectful, please report it.)

 
3/14/2006 6:59:19 AMsalam

salam
(If this comment was disrespectful, please report it.)

 
1/14/2007 11:36:58 PMLai Dong Van

Thank you very much
(If this comment was disrespectful, please report it.)

 
11/15/2011 4:49:35 PMWilly

ok, very good!
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.