// Methods. public bool Initialize(DSystemConfiguration configuration, IntPtr windowHandle) { // Set the size to sample down to. screenWidth = configuration.Width; screenHeight = configuration.Height; try { // Create the input object. Input = new DInput(); // Initialize the input object. if (!Input.Initialize(configuration, windowHandle)) { return(false); } #region Initialize System // Create the Direct3D object. D3D = new DDX11(); // Initialize the Direct3D object. if (!D3D.Initialize(configuration, windowHandle)) { return(false); } #endregion #region Initialize Camera // Create the camera object Camera = new DCamera(); // Set the initial position of the camera. Camera.SetPosition(0.0f, 0.0f, -10.0f); Camera.Render(); #endregion // Create the model object. Model = new DModel(); // Initialize the model object. if (!Model.Initialize(D3D.Device, "sphere.txt", "blue.bmp")) { return(false); } // Create the texture shader object. TextureShader = new DTextureShader(); // Initialize the texture shader object. if (!TextureShader.Initialize(D3D.Device, windowHandle)) { return(false); } // Create the light shader object. LightShader = new DLightShader(); // Initialize the light shader object. if (!LightShader.Initialize(D3D.Device, windowHandle)) { return(false); } // Create the light object. Light = new DLight(); // Initialize the light object. Light.Direction = new Vector3(0.0f, 0.0f, 1.0f); // Create the text object. Text = new DTextClass(); // Initialize the text object. if (!Text.Initialize(D3D.Device, D3D.DeviceContext, windowHandle, configuration.Width, configuration.Height, Camera.ViewMatrix)) { return(false); } // Create the bitmap object as the mouse pointer. BitMap = new DBitmap(); // Initialize the bitmap object. if (!BitMap.Initialize(D3D.Device, configuration.Width, configuration.Height, "mouse.bmp", 32, 32)) { return(false); } // Initialize that the user has not clicked on the screen to try an intersection test yet. beginMouseChexk = false; return(true); } catch (Exception ex) { MessageBox.Show("Could not initialize Direct3D\nError is '" + ex.Message + "'"); return(false); } }
public static byte[] ToImageData(DBitmap bmp) { #if CAIRO return ((WFCairoBitmap)bmp).GetPngData(); #else return ToImageData((Bitmap)bmp.NativeBmp); #endif }
public static DGraphics MakeGraphics(DBitmap bmp) { #if CAIRO return new WFCairoGraphics(bmp); #else return new GDIGraphics(bmp); #endif }
// Methods. public bool Initialize(DSystemConfiguration configuration, IntPtr windowHandle) { try { #region Initialize System // Create the Direct3D object. D3D = new DDX11(); // Initialize the Direct3D object. if (!D3D.Initialize(configuration, windowHandle)) { return(false); } #endregion #region Initialize Camera // Create the camera object Camera = new DCamera(); // Set the position of the camera; Camera.SetPosition(0, 0, -10); #endregion #region Initialize Models // Create the model class. Model = new DModel(); // Initialize the model object. if (!Model.Initialize(D3D.Device, "Cube.txt", new[] { "seafloor.bmp" })) { MessageBox.Show("Could not initialize the model object", "Error", MessageBoxButtons.OK); return(false); } // Create the bitmap object. Bitmap = new DBitmap(); // Initialize the model object. if (!Bitmap.Initialize(D3D.Device, configuration.Width, configuration.Height, configuration.Width, configuration.Height)) { MessageBox.Show("Could not initialize the bitmap object", "Error", MessageBoxButtons.OK); return(false); } #endregion #region Initialize Shader // Create the shader object. TextureShader = new DTextureShader(); // Initialize the shader object. if (!TextureShader.Initialize(D3D.Device, windowHandle)) { MessageBox.Show("Could not initialize the shader", "Error", MessageBoxButtons.OK); return(false); } // Create the shader object. FadeShader = new DFadeShader(); // Initialize the shader object. if (!FadeShader.Initialize(D3D.Device, windowHandle)) { MessageBox.Show("Could not initialize the fade shader", "Error", MessageBoxButtons.OK); return(false); } #endregion #region Initialize Data // Create the render to texture object. RenderTexture = new DRenderTexture(); // Initialize the render to texture object. if (!RenderTexture.Initialize(D3D.Device, configuration)) { return(false); } #endregion #region Initialize Variables // Set the fade in time to 3000 milliseconds FadeInTime = 5000; // Initialize the accumulated time to zero milliseconds. AccumulatedTime = 0; // Initialize the fade percentage to zero at first so the scene is black. FadePercentage = 0; // Set the fading in effect to not done. FadeDone = false; #endregion return(true); } catch (Exception ex) { MessageBox.Show("Could not initialize Direct3D\nError is '" + ex.Message + "'"); return(false); } }
// Methods. public bool Initialize(DSystemConfiguration configuration, IntPtr windowHandle) { // Set the size to sample down to. int downSampleWidth = configuration.Width / 2; int downSampleHeight = configuration.Height / 2; try { #region Initialize System // Create the Direct3D object. D3D = new DDX11(); // Initialize the Direct3D object. if (!D3D.Initialize(configuration, windowHandle)) { return(false); } #endregion #region Initialize Camera // Create the camera object Camera = new DCamera(); // Set the initial position of the camera. Camera.SetPosition(0.0f, 0.0f, -10.0f); #endregion // Create the texture shader object. TextureShader = new DTextureShader(); // Create the texture shader object. if (!TextureShader.Initialize(D3D.Device, windowHandle)) { return(false); } // Create the bitmap object. BitMap = new DBitmap(); // Initialize the bitmap object. if (!BitMap.Initialize(D3D.Device, configuration.Width, configuration.Height, "test.bmp", "glowmap.bmp", 256, 32)) { return(false); } // Create the render to texture object. RenderTexture = new DRenderTexture(); // Initialize the render to texture object. if (!RenderTexture.Initialize(D3D.Device, configuration.Width, configuration.Height, DSystemConfiguration.ScreenNear, DSystemConfiguration.ScreenDepth)) { return(false); } // Create the down sample render to texture object. DownSampleTexture = new DRenderTexture(); // Initialize the down sample render to texture object. if (!DownSampleTexture.Initialize(D3D.Device, configuration.Width / 2, configuration.Height / 2, DSystemConfiguration.ScreenNear, DSystemConfiguration.ScreenDepth)) { return(false); } // Create the small ortho window object. SmallWindow = new DOrthoWindow(); // Initialize the small ortho window object. if (!SmallWindow.Initialize(D3D.Device, configuration.Width / 2, configuration.Height / 2)) { return(false); } // Create the horizontal blur render to texture object. HorizontalBlurTexture = new DRenderTexture(); // Initialize the horizontal blur render to texture object. if (!HorizontalBlurTexture.Initialize(D3D.Device, configuration.Width / 2, configuration.Height / 2, DSystemConfiguration.ScreenNear, DSystemConfiguration.ScreenDepth)) { return(false); } // Create the horizontal blur shader object. HorizontalBlurShader = new DHorizontalBlurShader(); // Initialize the horizontal blur shader object. if (!HorizontalBlurShader.Initialize(D3D.Device, windowHandle)) { return(false); } // Create the vertical blur render to texture object. VerticalBlurTexture = new DRenderTexture(); // Initialize the vertical blur render to texture object. if (!VerticalBlurTexture.Initialize(D3D.Device, configuration.Width / 2, configuration.Height / 2, DSystemConfiguration.ScreenNear, DSystemConfiguration.ScreenDepth)) { return(false); } // Create the vertical blur shader object. VerticalBlurShader = new DVerticalBlurShader(); // Initialize the vertical blur shader object. if (!VerticalBlurShader.Initialize(D3D.Device, windowHandle)) { return(false); } // Create the up sample render to texture object. UpSampleTexure = new DRenderTexture(); // Initialize the up sample render to texture object. if (!UpSampleTexure.Initialize(D3D.Device, configuration.Width, configuration.Height, DSystemConfiguration.ScreenNear, DSystemConfiguration.ScreenDepth)) { return(false); } // Create the full screen ortho window object. FullScreenWindow = new DOrthoWindow(); // Initialize the full screen ortho window object. if (!FullScreenWindow.Initialize(D3D.Device, configuration.Width, configuration.Height)) { return(false); } // Create the glow map shader object. GlowMapShader = new DGlowMapShader(); // Initialize the glow map shader object. if (!GlowMapShader.Initialize(D3D.Device, windowHandle)) { return(false); } // Create the glow shader object. GlowShader = new DGlowShader(); // Initialize the glow shader object. if (!GlowShader.Initialize(D3D.Device, windowHandle)) { return(false); } return(true); } catch (Exception ex) { MessageBox.Show("Could not initialize Direct3D\nError is '" + ex.Message + "'"); return(false); } }
public override void DrawBitmap(DBitmap bitmap, DRect rect, double alpha) { if (bitmap != null) { Bitmap bmp = (Bitmap)bitmap.NativeBmp; if (bmp.Width == rect.Width && bmp.Height == rect.Height && alpha == 1) g.DrawImageUnscaled(bmp, (int)rect.X, (int)rect.Y); else g.DrawImage(bmp, MakePara(rect), new RectangleF(0, 0, bmp.Width, bmp.Height), GraphicsUnit.Pixel, MakeImageAttributesWithAlpha(alpha)); } }
public override void DrawBitmap(DBitmap bitmap, DRect rect) { g.DrawImage((Bitmap)bitmap.NativeBmp, MakeRect(rect)); }
public override void DrawBitmap(DBitmap bitmap, DPoint pt, double alpha) { DrawBitmap(bitmap, new DRect(pt.X, pt.Y, bitmap.Width, bitmap.Height), alpha); }
public override void DrawBitmap(DBitmap bitmap, DPoint pt) { g.DrawImage((Bitmap)bitmap.NativeBmp, new PointF((float)pt.X, (float)pt.Y)); }
public GDIGraphics(DBitmap bmp) : this(Graphics.FromImage((Bitmap)bmp.NativeBmp)) { }