示例#1
0
        public static void Main(string[] args)
        {
            device = new IrrlichtDevice(DriverType.OpenGL, new Dimension2D(640, 480), 32, false, true, false, false);
            if (device == null)
            {
                System.Console.WriteLine("Device could not be created. Exiting.");
                return;
            }

            device.WindowCaption = "Hello World - 2D Graphics Demo";

            videoDriver = device.VideoDriver;
            sceneManager = device.SceneManager;
            guiEnvironment = device.GUIEnvironment;

            images = videoDriver.GetTexture("../../irrlicht/media/2ddemo.png");
            videoDriver.MakeColorKeyTexture(images, new Position2D(0, 0));

            font = guiEnvironment.BuiltInFont;
            font2 = guiEnvironment.GetFont("../../irrlicht/media/fonthaettenschweiler.bmp");

            device.OnEvent += new OnEventDelegate(device_OnEvent);

            while (device.Run())
            {
                RenderLoop();
            }

            device.Drop();
        }
示例#2
0
 public void SafeCopyInto(Texture tex)
 {
     Color[,] col = Retrieve();
     ModifyPixel del = delegate(int x, int y, out Color result)
     {
         result = col[x, y];
         return true;
     };
     tex.Modify(del);
 }
示例#3
0
 public void RemoveTexture(Texture text)
 {
     VideoDriver_RemoveTexture(_raw, text.Raw);
 }
示例#4
0
 public void Draw2DImage(Texture image, Position2D destPos, bool useAlphaChannel)
 {
     Draw2DImage(image, destPos, Color.White, useAlphaChannel);
 }
示例#5
0
 public void Draw2DImage(Texture image, Position2D destPos, Color color, bool useAlphaChannel)
 {
     Draw2DImage(image, destPos, new Rect(new Position2D(0, 0), image.OriginalSize), color, useAlphaChannel);
 }
示例#6
0
 public void Draw2DImage(Texture image, Position2D destPos)
 {
     VideoDriver_Draw2DImageA(_raw, image.Raw, destPos.ToUnmanaged());
 }
示例#7
0
 /// <summary>
 /// Adds a simple skybox. A skybox is a basic cube rendered before everything and used to simulate an external environment with only textures.
 /// </summary>
 /// <returns>The skybox scene node (it should NOT be used since the skybox may not be moved nor rotated)</returns>
 /// <param name="parent">Its parent (should be set to null)</param>
 /// <param name="textureList">List of 6 Textures that constitute the skybox, order : top, bottom, left, right, front, back</param>
 /// <param name="id">ID of the node, -1 for automatic assign.</param>
 public SceneNode AddSkyBoxSceneNode(SceneNode parent, Texture[] textureList, int id)
 {
     IntPtr top = textureList[0].Raw;
     IntPtr bottom = textureList[1].Raw;
     IntPtr right = textureList[2].Raw;
     IntPtr left = textureList[3].Raw;
     IntPtr front = textureList[4].Raw;
     IntPtr back = textureList[5].Raw;
     return (SceneNode)
         NativeElement.GetObject(SceneManager_AddSkyBoxSceneNode(_raw, top, bottom, left, right, front, back, GetPtr(parent), id),
                                 typeof(SceneNode));
 }
示例#8
0
 public void SetPressedImage(Texture image, Rect pos)
 {
     GUIButton_SetPressedImage(_raw, image.Raw, pos.ToUnmanaged());
 }
示例#9
0
 /// <summary>
 /// Creates an 1bit alpha channel of the texture based on a pixel position color
 /// </summary>
 /// <param name="texture">Input texture that will be modified</param>
 /// <param name="colorKeyPixelPos">Position of the pixel with the color key</param>
 public void MakeColorKeyTexture(Texture texture, Position2D colorKeyPixelPos)
 {
     VideoDriver_MakeColorKeyTexture(_raw, texture.Raw, colorKeyPixelPos.ToUnmanaged());
 }
示例#10
0
 /// <summary>
 /// Creates a normal map from heightmap texture
 /// </summary>
 /// <param name="texture">Input texture that will be modified</param>
 /// <param name="amplitude">Constant value which by the height information is multiplied</param>
 public void MakeNormalMapTexture(Texture texture, float amplitude)
 {
     VideoDriver_MakeNormalMapTexture(_raw, texture.Raw, amplitude);
 }
示例#11
0
 /// <summary>
 /// Creates an 1bit alpha channel of the texture based on a color
 /// </summary>
 /// <param name="texture">Input texture that will be modified</param>
 /// <param name="color">Color</param>
 public void MakeColorKeyTexture(Texture texture, Color color)
 {
     VideoDriver_MakeColorKeyTextureA(_raw, texture.Raw, color.ToUnmanaged());
 }
示例#12
0
 /// <summary>
 /// Creates an animator that will switch every [timePerFrame] miliseconds the textures of the node.
 /// </summary>
 /// <param name="textures">List of textures</param>
 /// <param name="timePerFrame">Time (miliseconds) between each switch</param>
 /// <param name="loop">Does the animation loop ?</param>
 /// <returns>An animator to be added with SceneNode.AddAnimator</returns>
 public Animator CreateTextureAnimator(Texture[] textures, int timePerFrame, bool loop)
 {
     IntPtr[] array = new IntPtr[textures.Length];
     for (int i = 0; i < textures.Length; i++)
         array[i] = textures[i].Raw;
     return (Animator)
         NativeElement.GetObject(SceneManager_CreateTextureAnimator(_raw, array, array.Length, timePerFrame, loop),
                                 typeof(Animator));
 }
示例#13
0
 /// <summary>
 /// Adds a skydome scene node to the scene graph.
 /// A skydome is a large (half-) sphere with a panoramic texture on the inside and is drawn around the camera position.
 /// </summary>
 /// <param name="texture">Texture for the dome. </param>
 /// <param name="horiRes">Number of vertices of a horizontal layer of the sphere. </param>
 /// <param name="vertRes">Number of vertices of a vertical layer of the sphere. </param>
 /// <param name="texturePercentage">How much of the height of the texture is used. Should be between 0 and 1. </param>
 /// <param name="spherePercentage">How much of the sphere is drawn. Value should be between 0 and 2, where 1 is an exact half-sphere and 2 is a full sphere. </param>
 /// <param name="radius"></param>
 /// <param name="parent">Parent scene node of the dome. A dome usually has no parent, so this should be null. Note: If a parent is set, the dome will not change how it is drawn.</param>
 /// <returns>The scene node</returns>
 public SceneNode AddSkyDomeSceneNode(Texture texture, uint horiRes, uint vertRes, double texturePercentage, double spherePercentage, double radius, SceneNode parent)
 {
     return (SceneNode)
         NativeElement.GetObject(SceneManager_AddSkyDomeSceneNode(_raw, texture.Raw, horiRes, vertRes, texturePercentage, spherePercentage, radius, GetPtr(parent)),
                                 typeof(SceneNode));
 }
示例#14
0
 public void RenameTexture(Texture text, string name)
 {
     VideoDriver_RenameTexture(_raw, text.Raw, name);
 }
示例#15
0
 public void Draw2DImage(Texture image, Position2D destPos, Rect sourceRect, Color color, bool useAlpha)
 {
     VideoDriver_Draw2DImageB(_raw, image.Raw, destPos.ToUnmanaged(), sourceRect.ToUnmanaged(), color.ToUnmanaged(), useAlpha);
 }
示例#16
0
 public void SetRenderTarget(Texture target, bool clearBackBuffer, bool clearZBuffer, Color color)
 {
     VideoDriver_SetRenderTarget(_raw, GetPtr(target), clearBackBuffer, clearZBuffer, color.ToUnmanaged());
 }
示例#17
0
 public void Draw2DImage(Texture image, Rect destRect, Rect sourceRect, Color[] color, bool useAlpha)
 {
     VideoDriver_Draw2DImageD(_raw, image.Raw, destRect.ToUnmanaged(), sourceRect.ToUnmanaged(), color[0].ToUnmanaged(), color[1].ToUnmanaged(), color[2].ToUnmanaged(), color[3].ToUnmanaged(), useAlpha);
 }
示例#18
0
 public GUIImage AddImage(Texture image, Position2D position, bool useAlphaChannel, GUIElement parent, int id, string text)
 {
     return (GUIImage)NativeElement.GetObject(GuiEnv_AddImageA(_raw, image.Raw, position.ToUnmanaged(), useAlphaChannel, GetPtr(parent), id, text),
                                               typeof(GUIImage));
 }
示例#19
0
 public void Draw2DImage(Texture image, Rect destRect, Rect sourceRect, Rect clipRect, Color color, bool useAlpha)
 {
     VideoDriver_Draw2DImageC(_raw, image.Raw, destRect.ToUnmanaged(), sourceRect.ToUnmanaged(), clipRect.ToUnmanaged(), color.ToUnmanaged(), color.ToUnmanaged(), color.ToUnmanaged(), color.ToUnmanaged(), useAlpha);
 }
示例#20
0
 public void SetPressedImage(Texture image)
 {
     GUIButton_SetPressedImageA(_raw, image.Raw);
 }
示例#21
0
 public void SetMaterialTexture(int layer, Texture text)
 {
     SceneNode_SetMaterialTexture(_raw, layer, (text == null ? IntPtr.Zero : text.Raw));
 }