Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Need help in C#.NET 2005 beta 2

Need help in C#.NET 2005 beta 2

Scheduled Pinned Locked Moved C#
helpcsharpgraphicsgame-devhardware
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tom_dx
    wrote on last edited by
    #1

    using System; using System.Drawing; using System.Windows.Forms; using Microsoft.DirectX; using Microsoft.DirectX.Direct3D; namespace XSkate { public partial class MainForm : Form { Device device = null; // Our rendering device public MainForm() { InitializeComponent(); } public bool InitializeGraphics() { try { PresentParameters presentParams = new PresentParameters(); presentParams.Windowed = true; presentParams.SwapEffect = SwapEffect.Discard; device = new Device(0, DeviceType.Hardware, this, CreateFlags.HardwareVertexProcessing, presentParams); return true; } catch (DirectXException) { DisplayError("Could not initialize Direct3D, now exiting.", true); return false; } } private void Render() { if (device == null) { return; } device.Clear(ClearFlags.Target, System.Drawing.Color.Blue, 1.0f, 0); device.BeginScene(); // Rendering of scene objects can happen here device.EndScene(); device.Present(); } protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { this.Render(); } protected override void OnKeyPress(System.Windows.Forms.KeyPressEventArgs e) { if ((int)(byte)e.KeyChar == (int)System.Windows.Forms.Keys.Escape) { this.Close(); } } static void Main() { using (MainForm frm = new MainForm()) { if (!frm.InitializeGraphics()) { return; } frm.Show(); while (frm.Created) { frm.Render(); Application.DoEvents(); } } } private void DisplayError(string Message, bool Fatal) { if (Fatal) { MessageBox.Show(Message, "Fatal Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } else { MessageBox.Show(Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } } } } It works but I don't know why the console window pops up along with the form, I don't want it to but what am I doing wrong? I am using Visual C#.NET 2005 beta 2, plz help, this is all the code I have in the project, except for the form code which is probably unnecessary for this problem, again plz help. :(:confused::confused: IM PROUD TO BE A GMAIL;

    S 1 Reply Last reply
    0
    • T tom_dx

      using System; using System.Drawing; using System.Windows.Forms; using Microsoft.DirectX; using Microsoft.DirectX.Direct3D; namespace XSkate { public partial class MainForm : Form { Device device = null; // Our rendering device public MainForm() { InitializeComponent(); } public bool InitializeGraphics() { try { PresentParameters presentParams = new PresentParameters(); presentParams.Windowed = true; presentParams.SwapEffect = SwapEffect.Discard; device = new Device(0, DeviceType.Hardware, this, CreateFlags.HardwareVertexProcessing, presentParams); return true; } catch (DirectXException) { DisplayError("Could not initialize Direct3D, now exiting.", true); return false; } } private void Render() { if (device == null) { return; } device.Clear(ClearFlags.Target, System.Drawing.Color.Blue, 1.0f, 0); device.BeginScene(); // Rendering of scene objects can happen here device.EndScene(); device.Present(); } protected override void OnPaint(System.Windows.Forms.PaintEventArgs e) { this.Render(); } protected override void OnKeyPress(System.Windows.Forms.KeyPressEventArgs e) { if ((int)(byte)e.KeyChar == (int)System.Windows.Forms.Keys.Escape) { this.Close(); } } static void Main() { using (MainForm frm = new MainForm()) { if (!frm.InitializeGraphics()) { return; } frm.Show(); while (frm.Created) { frm.Render(); Application.DoEvents(); } } } private void DisplayError(string Message, bool Fatal) { if (Fatal) { MessageBox.Show(Message, "Fatal Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } else { MessageBox.Show(Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } } } } It works but I don't know why the console window pops up along with the form, I don't want it to but what am I doing wrong? I am using Visual C#.NET 2005 beta 2, plz help, this is all the code I have in the project, except for the form code which is probably unnecessary for this problem, again plz help. :(:confused::confused: IM PROUD TO BE A GMAIL;

      S Offline
      S Offline
      S Senthil Kumar
      wrote on last edited by
      #2

      Is your project's Output Type specified as Console application? Regards Senthil _____________________________ My Blog | My Articles | WinMacro

      C T 2 Replies Last reply
      0
      • S S Senthil Kumar

        Is your project's Output Type specified as Console application? Regards Senthil _____________________________ My Blog | My Articles | WinMacro

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #3

        I thought of that, but he has a mainform, surely the wizard added that ? Christian Graus - Microsoft MVP - C++

        T 1 Reply Last reply
        0
        • C Christian Graus

          I thought of that, but he has a mainform, surely the wizard added that ? Christian Graus - Microsoft MVP - C++

          T Offline
          T Offline
          tom_dx
          wrote on last edited by
          #4

          i renamed the whole class to mainform.. using refactor of course IM PROUD TO BE A GMAIL;

          1 Reply Last reply
          0
          • S S Senthil Kumar

            Is your project's Output Type specified as Console application? Regards Senthil _____________________________ My Blog | My Articles | WinMacro

            T Offline
            T Offline
            tom_dx
            wrote on last edited by
            #5

            That was it, sry I'm new to .net and C#, in c++ you didn't have to do this :P, that was it thank you. IM PROUD TO BE A GMAIL;

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups