Click here to Skip to main content
15,908,173 members
Home / Discussions / Graphics
   

Graphics

 
GeneralRe: HELPP please. Pin
chasoknight24-Jul-08 15:00
chasoknight24-Jul-08 15:00 
GeneralRe: HELPP please. Pin
Tim Craig24-Jul-08 15:31
Tim Craig24-Jul-08 15:31 
AnswerRe: HELPP please. Pin
Mark Salsbery25-Jul-08 6:59
Mark Salsbery25-Jul-08 6:59 
AnswerRe: HELPP please. Pin
Paul Conrad26-Jul-08 18:06
professionalPaul Conrad26-Jul-08 18:06 
QuestionRay Tracing question Pin
Member 433828023-Jul-08 11:14
Member 433828023-Jul-08 11:14 
QuestionWorking with 2D in DirectX using C# (Newest version as of 07/22/2008) ??? Pin
Thrash50522-Jul-08 16:00
Thrash50522-Jul-08 16:00 
AnswerRe: Working with 2D in DirectX using C# (Newest version as of 07/22/2008) ??? Pin
Thrash50523-Jul-08 20:26
Thrash50523-Jul-08 20:26 
GeneralRe: Working with 2D in DirectX using C# (Newest version as of 07/22/2008) ??? Pin
Thrash50525-Sep-08 11:56
Thrash50525-Sep-08 11:56 
I've finally figured out why my code wasn't working... I had to set the view transform and turn off lighting. Then I had to put in the BeginScene(), EndScene(), and Present() calls when rendering.

Here's the new version of the GameForm.cs file:
// *************************************************************************************************
// ***** Project: 2D DirectX9 Test
// ***** Author: Thrash505
// ***** Created: 07/24/2008
// *************************************************************************************************

// *************************************************************************************************
// ***** Using Directives
// *************************************************************************************************
#region Using Directives
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using Microsoft.DirectX;
using Microsoft.DirectX.Direct3D;
#endregion

namespace _2D_DirectX9_Test {
    // *********************************************************************************************
    // ***** GameForm Class
    // *********************************************************************************************
    #region GameForm Class
    public partial class GameForm : Form {
        // *****************************************************************************************
        // GameForm - Attributes
        // *****************************************************************************************
        #region GameForm - Attributes
        private Device _graphicsDevice;
        private Sprite _spriteManager;
        private GraphicsSprite gs;
        #endregion

        // *****************************************************************************************
        // GameForm - Properties
        // *****************************************************************************************
        #region GameForm - Properties
        private Device GraphicsDevice {
            get { return _graphicsDevice; }
            set { _graphicsDevice = value; }
        }
        private int ScreenWidth {
            get { return 1024; }
        }
        private int ScreenHeight {
            get { return 768; }
        }
        public Sprite SpriteManager {
            get { return _spriteManager; }
            set { _spriteManager = value; }
        }
        #endregion

        // *****************************************************************************************
        // GameForm - Constructors
        // *****************************************************************************************
        #region GameForm - Constructors
        public GameForm( ) {
            InitializeComponent( );
            InitializeGraphics( );
        }
        #endregion

        // *****************************************************************************************
        // GameForm - Methods
        // *****************************************************************************************
        #region GameForm - Methods
        private void InitializeGraphics( ) {
            PresentParameters presentParameters = new PresentParameters( );
            Format currentFormat = Manager.Adapters[ 0 ].CurrentDisplayMode.Format;

            presentParameters.SwapEffect = SwapEffect.Discard;

            if( Manager.CheckDeviceType( 0, DeviceType.Hardware, currentFormat, currentFormat,
                false ) ) {
                presentParameters.Windowed = true;
                presentParameters.BackBufferFormat = currentFormat;
                presentParameters.BackBufferCount = 1;
                presentParameters.BackBufferWidth = ScreenWidth;
                presentParameters.BackBufferHeight = ScreenHeight;
            } else {
                presentParameters.Windowed = true;
            }
            GraphicsDevice = new Device( 0, DeviceType.Hardware, this,
                CreateFlags.SoftwareVertexProcessing, presentParameters );

            GraphicsDevice.Transform.View = Matrix.OrthoOffCenterLH( 0, ScreenWidth, ScreenHeight, 0, 0, 10 );

            GraphicsDevice.RenderState.Lighting = false;

            SpriteManager = new Sprite( GraphicsDevice );
            gs = new GraphicsSprite( new Vector3( 0f, 0f, 1f ),
                TextureLoader.FromFile( GraphicsDevice, @"C:\test.bmp" ) );
        }

        public void RenderGraphics( ) {
            GraphicsDevice.Clear( ClearFlags.Target, Color.FromArgb( 0, 0, 225 ), 0, 0 );
            GraphicsDevice.BeginScene( );
            _spriteManager.Begin( SpriteFlags.AlphaBlend );
            gs.Draw( SpriteManager );
            _spriteManager.End( );
            GraphicsDevice.EndScene( );
            GraphicsDevice.Present( );
        }

        // *****************************************************************************************
        // GameForm - Event Handlers
        // *****************************************************************************************
        private void GameForm_KeyUp( object sender, KeyEventArgs e ) {
            if( e.KeyCode == Keys.Escape )
                this.Close( );
        }
        #endregion
    }
    #endregion
}


Hopefully that will help somebody else.
QuestionBitmap from a Graphics object ? Pin
david davies21-Jul-08 2:06
david davies21-Jul-08 2:06 
AnswerRe: Bitmap from a Graphics object ? Pin
Luc Pattyn21-Jul-08 3:00
sitebuilderLuc Pattyn21-Jul-08 3:00 
QuestionDirectX installation. Pin
Ranger4919-Jul-08 17:22
Ranger4919-Jul-08 17:22 
AnswerRe: DirectX installation. Pin
Ranger4919-Jul-08 22:56
Ranger4919-Jul-08 22:56 
GeneralGraphics Help Plz -Urgent! [modified] Pin
Brady Kelly17-Jul-08 22:58
Brady Kelly17-Jul-08 22:58 
GeneralRe: Graphics Help Plz -Urgent! Pin
Graham Bradshaw17-Jul-08 23:02
Graham Bradshaw17-Jul-08 23:02 
GeneralRe: Graphics Help Plz -Urgent! Pin
Brady Kelly17-Jul-08 23:17
Brady Kelly17-Jul-08 23:17 
GeneralRe: Graphics Help Plz -Urgent! Pin
Simon P Stevens17-Jul-08 23:26
Simon P Stevens17-Jul-08 23:26 
GeneralRe: Graphics Help Plz -Urgent! Pin
peterchen17-Jul-08 23:40
peterchen17-Jul-08 23:40 
GeneralRe: Graphics Help Plz -Urgent! Pin
TommyTomToms18-Jul-08 0:07
TommyTomToms18-Jul-08 0:07 
QuestionMap Projection Pin
aadilali17-Jul-08 19:18
aadilali17-Jul-08 19:18 
AnswerRe: Map Projection Pin
El Corazon18-Jul-08 9:17
El Corazon18-Jul-08 9:17 
GeneralRe: Map Projection Pin
aadilali19-Jul-08 0:58
aadilali19-Jul-08 0:58 
GeneralRe: Map Projection Pin
El Corazon19-Jul-08 5:53
El Corazon19-Jul-08 5:53 
Questiondrawing a 3d circle in Directx Pin
Md. Ali Naser Khan16-Jul-08 21:21
Md. Ali Naser Khan16-Jul-08 21:21 
AnswerRe: drawing a 3d circle in Directx Pin
Shog917-Jul-08 12:44
sitebuilderShog917-Jul-08 12:44 
GeneralRe: drawing a 3d circle in Directx Pin
Md. Ali Naser Khan17-Jul-08 15:19
Md. Ali Naser Khan17-Jul-08 15:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.