Advertisement

There's no such thing as a stupid question, but they're the easiest to answer.
Login
Search

Advertisement

Software Development Software Development
Search Search
Search for:
Tech Support Guy > > >

C# direct x basic program


(!)

CyberFog's Avatar
CyberFog CyberFog is offline
Member with 64 posts.
THREAD STARTER
 
Join Date: Aug 2007
13-Jul-2012, 02:51 PM #1
C# direct x basic program
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
File Type: rar programd3d.rar (1.4 KB, 13 views)
ckphilli's Avatar
ckphilli   (Chris) ckphilli is offline
Member with 4,284 posts.
 
Join Date: Apr 2006
Location: Down South
Experience: Intermediate
13-Jul-2012, 10:13 PM #2
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.
CyberFog's Avatar
CyberFog CyberFog is offline
Member with 64 posts.
THREAD STARTER
 
Join Date: Aug 2007
14-Jul-2012, 02:29 AM #3
Quote:
Originally Posted by ckphilli View Post
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.
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]
ckphilli's Avatar
ckphilli   (Chris) ckphilli is offline
Member with 4,284 posts.
 
Join Date: Apr 2006
Location: Down South
Experience: Intermediate
14-Jul-2012, 03:39 PM #4
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.
dvk01's Avatar
dvk01   (Derek) dvk01 is offline dvk01 is authorized to help remove malware.
Moderator & Malware Removal Specialist with 45,738 posts.
 
Join Date: Dec 2002
Location: Loughton, Essex, UK
14-Jul-2012, 04:14 PM #5
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
ckphilli's Avatar
ckphilli   (Chris) ckphilli is offline
Member with 4,284 posts.
 
Join Date: Apr 2006
Location: Down South
Experience: Intermediate
14-Jul-2012, 04:20 PM #6
CyberFog, here's a directX specific thread for you: http://www.gamedev.net/topic/408072-...lization-in-c/
As Seen On

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine
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.


(clock)
THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


WELCOME
You Are Using: Server ID
Trusted Website Back to the Top ↑