Esempio n. 1
0
        private void createTexture(int size)
        {
            VideoDriver drv = device.VideoDriver;

            Texture o = texture;

            texture = drv.AddTexture(new Dimension2Di(size), "tex");

            TexturePainter p = texture.Painter;

            p.Lock(TextureLockMode.WriteOnly);
            for (int i = 0; i < p.MipMapLevelHeight; i++)
            {
                p.SetLine(0, i, p.MipMapLevelWidth - 1, i, new Color(200, 200, 200));
            }
            p.Unlock(true);

            guiImage.Image = texture;
            sceneNodePainter.SetMaterialTexture(0, texture);

            if (o != null)
            {
                drv.RemoveTexture(o);
            }
        }
Esempio n. 2
0
        bool OnEvent(Event e)
        {
            if (e.Type == EventType.Mouse)
            {
                int  x = e.Mouse.X;
                int  y = e.Mouse.Y;
                bool l = e.Mouse.IsLeftPressed();

                if (l && guiImage.AbsolutePosition.IsPointInside(new Vector2Di(x, y)))
                {
                    Vector2Di p = new Vector2Di(x, y) - guiImage.AbsolutePosition.UpperLeftCorner;

                    if (e.Mouse.Type == MouseEventType.Move)
                    {
                        TexturePainter t = texture.Painter;

                        if (p.X < texture.Size.Width &&
                            p.Y < texture.Size.Height &&
                            t.Lock(TextureLockMode.WriteOnly))
                        {
                            t.SetLine(oldMouseX, oldMouseY, p.X, p.Y, new Color(255, 0, 0));
                            t.Unlock(true);
                        }
                    }

                    oldMouseX = p.X;
                    oldMouseY = p.Y;

                    return(true);
                }
            }

            if (e.Type == EventType.GUI)
            {
                if (e.GUI.Type == GUIEventType.ElementClosed &&
                    e.GUI.Caller is GUIWindow)
                {
                    device.Close();
                    return(true);
                }

                if (e.GUI.Type == GUIEventType.ButtonClicked)
                {
                    if (e.GUI.Caller == guiSize128)
                    {
                        initGUI(128);
                        createTexture(128);
                        return(true);
                    }

                    if (e.GUI.Caller == guiSize256)
                    {
                        initGUI(256);
                        createTexture(256);
                        return(true);
                    }

                    if (e.GUI.Caller == guiSize512)
                    {
                        initGUI(512);
                        createTexture(512);
                        return(true);
                    }
                }
            }

            return(false);
        }