1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

C# direct x basic program

Discussion in 'Software Development' started by CyberFog, Jul 13, 2012.

Thread Status:
Not open for further replies.
Advertisement
  1. CyberFog

    CyberFog Thread Starter

    Joined:
    Aug 13, 2007
    Messages:
    64
    Hi,

    I' am having problem compiling this program.
    I'm using sdk 2010 and c#. I'm using Visual Studio 2008.
    The program is in the attachement.

    It's reporting errors in the InitalizeGraphics function.

    Wrong device parameters.

    Thank you for your help.
     

    Attached Files:

  2. ckphilli

    ckphilli

    Joined:
    Apr 29, 2006
    Messages:
    4,384
    Hi CyberFog. Don't take any offense, please, but I'm not in the habit of downloading files from an unknown source. Can you do me a favor and paste the offending code and what you think is relevant to that code in a post? Just wrap it in code tags (the hash button) in the menu bar please. We'll see if we can help you out.
     
  3. CyberFog

    CyberFog Thread Starter

    Joined:
    Aug 13, 2007
    Messages:
    64
    Hi ckphili,

    No offense taken :).


    Code:
    using Microsoft.DirectX;
    using Microsoft.DirectX.Direct3D;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Windows.Forms;
    
    
    namespace programd3d
    {
    
        class Program
        {
    
            private Device device = null;
    
             
    
    
            public void InitializeGraphics()
            {
    
                PresentParameters presentParams = new PresentParameters();
    
                presentParams.Windowed = true;
                presentParams.SwapEffect = SwapEffect.Discard;
    
                device = new Device(0, DeviceType.Hardware, this,                      <------------ this is line 28  responsible for errors
                CreateFlags.SoftwareVertexProcessing, presentParams);             <------------ this is line 29 resonsible for errors 
               
    
            }
    
    
            static void Main()
            {
    
                using (Form1 frm = new Form1())
                {
    
                    frm.Show();
                    frm.InitializeGraphics();
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    Application.Run(frm);
    
                }
    
            }
    
        }
    }
    



    And these are the three error codes.


    Error 1 The best overloaded method match for 'Microsoft.DirectX.Direct3D.Device.Device(int, Microsoft.DirectX.Direct3D.DeviceType, System.IntPtr, Microsoft.DirectX.Direct3D.CreateFlags, params Microsoft.DirectX.Direct3D.PresentParameters[])' has some invalid arguments C:\Users\Barichke\Documents\Visual Studio 2008\Projects\programd3d\programd3d\Program.cs 28


    Error 3 Argument '5': cannot convert from 'Microsoft.DirectX.Direct3D.PresentParameters' to 'Microsoft.DirectX.Direct3D.PresentParameters[]' C:\Users\Barichke\Documents\Visual Studio 2008\Projects\programd3d\programd3d\Program.cs 29


    Error 2 Argument '3': cannot convert from 'programd3d.Program' to 'System.IntPtr' C:\Users\Barichke\Documents\Visual Studio 2008\Projects\programd3d\programd3d\Program.cs 28
    [/COLOR]
     
  4. ckphilli

    ckphilli

    Joined:
    Apr 29, 2006
    Messages:
    4,384
    Hey I'll be honest Cyber, I have no idea here as I haven't dealt with this. Glad you posted the code so if someone does, they can help.

    But general debugging: check out the parameters. Change them, see if you can get a heartbeat.

    Also, if you downloaded this code (I have no idea if you wrote it or found it) dig around for some other examples.

    Make sure you have all the components installed on your machine to make this work as well.

    Sorry I can't give you anything solid, but good luck.:)
     
  5. dvk01

    dvk01 Derek Moderator Malware Specialist

    Joined:
    Dec 14, 2002
    Messages:
    47,800
    several posts that were off topic or arguing have been deleted

    if you don't know the answer don't post
    inflammatory posts or statements willl be deleted and teh posters penalised
     
  6. ckphilli

    ckphilli

    Joined:
    Apr 29, 2006
    Messages:
    4,384
  7. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1060841