Ejemplo n.º 1
0
        public void GLWindowGetAuxiliaryHintId()
        {
            tlog.Debug(tag, $"GLWindowGetAuxiliaryHintId START");
            string    name      = "myGLWindow";
            Rectangle rectangle = new Rectangle(20, 20, 100, 100);
            GLWindow  a1        = new GLWindow(name, rectangle, true);

            uint pos = a1.AddAuxiliaryHint("myHint", "myValue");

            a1.GetAuxiliaryHintId("myHint");

            a1.Destroy();
            tlog.Debug(tag, $"GLWindowGetAuxiliaryHintId END (OK)");
        }
Ejemplo n.º 2
0
        private static GeoModel ProcessScene(Scene scene, string filename, AssemblyMode am)
        {
            GeoModel returnModel = new GeoModel();

            returnModel.Filename = filename;
            returnModel.Name     = StripPathFromFile(filename);
            if (am == AssemblyMode.Internal)
            {
                returnModel.PathAbsolute = "";
            }
            else
            {
                if (am == AssemblyMode.User)
                {
                    returnModel.PathAbsolute = Assembly.GetEntryAssembly().GetName().Name + "." + filename;
                }
                else
                {
                    string p  = Assembly.GetExecutingAssembly().Location;
                    string pA = new DirectoryInfo(StripFileNameFromPath(p)).FullName;
                    if (!Path.IsPathRooted(filename))
                    {
                        returnModel.PathAbsolute = Path.Combine(pA, filename);
                    }
                    else
                    {
                        returnModel.PathAbsolute = filename;
                    }

                    bool success = File.Exists(returnModel.PathAbsolute);
                }
            }


            returnModel.AssemblyMode = am;
            returnModel.CalculatePath();
            returnModel.Meshes = new Dictionary <string, GeoMesh>();
            returnModel.TransformGlobalInverse = Matrix4.Invert(HelperMatrix.ConvertAssimpToOpenTKMatrix(scene.RootNode.Transform));
            returnModel.Textures = new Dictionary <string, GeoTexture>();
            returnModel.IsValid  = false;

            GenerateNodeHierarchy(scene.RootNode, ref returnModel);
            ProcessBones(scene, ref returnModel);
            ProcessMeshes(scene, ref returnModel);
            ProcessAnimations(scene, ref returnModel);

            returnModel.IsValid = true;
            GLWindow.StartGarbageCollection();
            return(returnModel);
        }
Ejemplo n.º 3
0
        public void GLWindowIsOpaqueState()
        {
            tlog.Debug(tag, $"GLWindowIsOpaqueState START");
            string    name      = "myGLWindow";
            Rectangle rectangle = new Rectangle(20, 20, 100, 100);
            GLWindow  a1        = new GLWindow(name, rectangle, true);

            var result = a1.IsOpaqueState();

            tlog.Debug(tag, "IsOpaqueState : " + result);

            a1.Destroy();
            tlog.Debug(tag, $"GLWindowIsOpaqueState END (OK)");
        }
Ejemplo n.º 4
0
        public void GLWindowSetEglConfig()
        {
            tlog.Debug(tag, $"GLWindowSetEglConfig START");
            string    name      = "myGLWindow";
            Rectangle rectangle = new Rectangle(20, 20, 100, 100);
            GLWindow  a1        = new GLWindow(name, rectangle, true);

            GLWindow.GLESVersion b1 = new GLWindow.GLESVersion();
            a1.SetEglConfig(true, true, 10, b1);

            a1.Destroy();
            tlog.Debug(tag, $"GLWindowSetEglConfig END (OK)");
            Assert.Pass("GLWindowSetEglConfig");
        }
Ejemplo n.º 5
0
        public void GLWindowRemoveAuxiliaryHint()
        {
            tlog.Debug(tag, $"GLWindowRemoveAuxiliaryHint START");
            string    name      = "myGLWindow";
            Rectangle rectangle = new Rectangle(20, 20, 100, 100);
            GLWindow  a1        = new GLWindow(name, rectangle, true);

            uint pos = a1.AddAuxiliaryHint("myHint", "myValue");

            a1.RemoveAuxiliaryHint(pos);

            tlog.Debug(tag, $"GLWindowRemoveAuxiliaryHint END (OK)");
            Assert.Pass("GLWindowRemoveAuxiliaryHint");
        }
Ejemplo n.º 6
0
        public void GLWindowWindowPositionSize()
        {
            tlog.Debug(tag, $"GLWindowWindowPositionSize START");
            string    name      = "myGLWindow";
            Rectangle rectangle = new Rectangle(20, 20, 100, 100);
            GLWindow  a1        = new GLWindow(name, rectangle, true);

            Rectangle b1 = a1.WindowPositionSize;

            a1.WindowPositionSize = b1;

            tlog.Debug(tag, $"GLWindowWindowPositionSize END (OK)");
            Assert.Pass("GLWindowWindowPositionSize");
        }
        public void GLWindowVisibilityChangedEventConstructor()
        {
            tlog.Debug(tag, $"GLWindowVisibilityChangedEventConstructor START");
            string    name      = "myGLWindow";
            Rectangle rectangle = new Rectangle(20, 20, 100, 100);
            GLWindow  a1        = new GLWindow(name, rectangle, true);

            GLWindowVisibilityChangedEvent b1 = new GLWindowVisibilityChangedEvent(a1);

            b1.Dispose();
            a1.Destroy();
            tlog.Debug(tag, $"GLWindowVisibilityChangedEventConstructor END (OK)");
            Assert.Pass("GLWindowVisibilityChangedEventConstructor");
        }
Ejemplo n.º 8
0
        public void GLWindowGetSupportedAuxiliaryHint()
        {
            tlog.Debug(tag, $"GLWindowGetSupportedAuxiliaryHint START");
            string    name      = "myGLWindow";
            Rectangle rectangle = new Rectangle(20, 20, 100, 100);
            GLWindow  a1        = new GLWindow(name, rectangle, true);

            var result = a1.GetSupportedAuxiliaryHint(1);

            tlog.Debug(tag, "GetSupportedAuxiliaryHint : " + result);

            a1.Destroy();
            tlog.Debug(tag, $"GLWindowGetSupportedAuxiliaryHint END (OK)");
        }
Ejemplo n.º 9
0
        public void GLWindowGetCurrentOrientation()
        {
            tlog.Debug(tag, $"GLWindowGetCurrentOrientation START");
            string    name      = "myGLWindow";
            Rectangle rectangle = new Rectangle(20, 20, 100, 100);
            GLWindow  a1        = new GLWindow(name, rectangle, true);

            var result = a1.GetCurrentOrientation();

            tlog.Debug(tag, "CurrentOrientation : " + result);

            a1.Destroy();
            tlog.Debug(tag, $"GLWindowGetCurrentOrientation END (OK)");
        }
Ejemplo n.º 10
0
        public PreferencesWindow(Gwen.Controls.ControlBase parent, GLWindow pgame) : base(parent, "Preferences")
        {
            game   = pgame;
            Width  = 400;
            Height = 400;
            MakeModal(true);
            DisableResizing();
            ///controls
            TabControl tcontainer = new TabControl(this);

            CreateBasicTab(tcontainer);
            //CreateAdvancedTab(tcontainer); //todo
            CreateRecordingTab(tcontainer);
            CreateAboutTab(tcontainer);
        }
        public void GLWindowVisibilityChangedEventGetConnectionCount()
        {
            tlog.Debug(tag, $"GLWindowVisibilityChangedEventGetConnectionCount START");
            string    name      = "myGLWindow";
            Rectangle rectangle = new Rectangle(20, 20, 100, 100);
            GLWindow  a1        = new GLWindow(name, rectangle, true);

            GLWindowVisibilityChangedEvent b1 = new GLWindowVisibilityChangedEvent(a1.SwigCPtr.Handle, false);

            b1.GetConnectionCount();

            a1.Destroy();
            tlog.Debug(tag, $"GLWindowVisibilityChangedEventGetConnectionCount END (OK)");
            Assert.Pass("GLWindowVisibilityChangedEventGetConnectionCount");
        }
Ejemplo n.º 12
0
        public void GLWindowRenderingMode()
        {
            tlog.Debug(tag, $"GLWindowRenderingMode START");

            var testingTarget = new GLWindow();

            Assert.IsNotNull(testingTarget, "Can't create success object GLWindow");
            Assert.IsInstanceOf <GLWindow>(testingTarget, "Should be an instance of GLWindow type.");

            testingTarget.RenderingMode = GLRenderingMode.Continuous;
            tlog.Debug(tag, "RenderingMode : " + testingTarget.RenderingMode);

            testingTarget.Destroy();
            tlog.Debug(tag, $"GLWindowRenderingMode END (OK)");
        }
Ejemplo n.º 13
0
        public void GLWindowConstructorWithGLWindow()
        {
            tlog.Debug(tag, $"GLWindowConstructorWithGLWindow START");

            using (GLWindow glwindow = new GLWindow())
            {
                var testingTarget = new GLWindow(glwindow.SwigCPtr.Handle, false);
                Assert.IsNotNull(testingTarget, "should be not null");
                Assert.IsInstanceOf <GLWindow>(testingTarget, "should be an instance of testing target class!");

                testingTarget.Destroy();
            }

            tlog.Debug(tag, $"GLWindowConstructorWithGLWindow END (OK)");
        }
Ejemplo n.º 14
0
        public void GLWindowResized()
        {
            tlog.Debug(tag, $"GLWindowResized START");
            string    name      = "myGLWindow";
            Rectangle rectangle = new Rectangle(20, 20, 100, 100);
            GLWindow  a1        = new GLWindow(name, rectangle, true);

            a1.Resized += A1_Resized;
            a1.Resized -= A1_Resized;

            GLWindow.ResizedEventArgs e1 = new GLWindow.ResizedEventArgs();
            A1_Resized(null, e1);
            a1.Destroy();
            tlog.Debug(tag, $"GLWindowResized END (OK)");
            Assert.Pass("GLWindowResized");
        }
Ejemplo n.º 15
0
        public void GLWindowConstructor()
        {
            tlog.Debug(tag, $"GLWindowConstructor START");
            string    name      = "myGLWindow";
            Rectangle rectangle = new Rectangle(20, 20, 100, 100);
            GLWindow  a1        = new GLWindow(name, rectangle, true);

            GLWindow a2 = new GLWindow();
            GLWindow a3 = new GLWindow(GLWindow.getCPtr(a1).Handle, true);

            a1.Destroy();
            a2.Destroy();
            a3.Destroy();
            tlog.Debug(tag, $"GLWindowConstructor END (OK)");
            Assert.Pass("GLWindowConstructor");
        }
Ejemplo n.º 16
0
        public void GLWindowTouchEvent()
        {
            tlog.Debug(tag, $"GLWindowTouchEvent START");
            string    name      = "myGLWindow";
            Rectangle rectangle = new Rectangle(20, 20, 100, 100);
            GLWindow  a1        = new GLWindow(name, rectangle, true);

            a1.TouchEvent += A1_TouchEvent;
            a1.TouchEvent -= A1_TouchEvent;

            GLWindow.TouchEventArgs e1 = new GLWindow.TouchEventArgs();
            A1_TouchEvent(null, e1);
            a1.Destroy();
            tlog.Debug(tag, $"GLWindowTouchEvent END (OK)");
            Assert.Pass("GLWindowTouchEvent");
        }
Ejemplo n.º 17
0
        public void GLWindowWindowPositionSize()
        {
            tlog.Debug(tag, $"GLWindowWindowPositionSize START");
            string    name      = "myGLWindow";
            Rectangle rectangle = new Rectangle(20, 20, 100, 100);
            GLWindow  a1        = new GLWindow(name, rectangle, true);

            a1.WindowPositionSize = new Rectangle(30, 40, 50, 60);
            Assert.AreEqual(30, a1.WindowPositionSize.X, "Should be equal!");
            Assert.AreEqual(40, a1.WindowPositionSize.Y, "Should be equal!");
            Assert.AreEqual(50, a1.WindowPositionSize.Width, "Should be equal!");
            Assert.AreEqual(60, a1.WindowPositionSize.Height, "Should be equal!");

            a1.Destroy();
            tlog.Debug(tag, $"GLWindowWindowPositionSize END (OK)");
        }
Ejemplo n.º 18
0
        public void GLWindowWindowSize()
        {
            tlog.Debug(tag, $"GLWindowWindowSize START");

            var testingTarget = new GLWindow();

            Assert.IsNotNull(testingTarget, "Can't create success object GLWindow");
            Assert.IsInstanceOf <GLWindow>(testingTarget, "Should be an instance of GLWindow type.");

            testingTarget.WindowSize = new Size2D(50, 30);
            Assert.AreEqual(50, testingTarget.WindowSize.Width, "Should be equal!");
            Assert.AreEqual(30, testingTarget.WindowSize.Height, "Should be equal!");

            testingTarget.Destroy();
            tlog.Debug(tag, $"GLWindowWindowSize END (OK)");
        }
Ejemplo n.º 19
0
        public SaveWindow(Gwen.Controls.ControlBase parent, GLWindow game) : base(parent, "Save Track")
        {
            game.Track.Stop();
            MakeModal(true);

            var bottom = new PropertyBase(this)
            {
                Name = "bottom", Margin = new Margin(0, 10, 0, 5), Height = 30
            };
            var cb = new ComboBox(this);

            cb.ItemSelected += (o, e) => {
                var snd = ((ComboBox)o);
                var txt = snd.SelectedItem.Text;
                this.UserData = txt;
            };
            var tb = new TextBox(bottom)
            {
                Name = "tb"
            };

            tb.Dock     = Pos.Left;
            bottom.Dock = Pos.Bottom;
            cb.Dock     = Pos.Bottom;
            cb.Margin   = new Margin(0, 0, 0, 0);
            this.Width  = 200;
            this.Height = 100;
            var dir = Program.CurrentDirectory + "Tracks";

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            var folders = Directory.GetDirectories(Program.CurrentDirectory + "Tracks");

            cb.AddItem("<create new track>"); //< used as it cant be used as a file character
            cb.SelectByText("<create new track>");
            foreach (var folder in folders)
            {
                var trackname = Path.GetFileName(folder);
                cb.AddItem(trackname);
            }
            cb.SelectByText(game.Track.Name);
            game.Cursor = MouseCursor.Default;
        }
Ejemplo n.º 20
0
        public void GLWindowSetAvailableOrientations()
        {
            tlog.Debug(tag, $"GLWindowSetAvailableOrientations START");
            string    name      = "myGLWindow";
            Rectangle rectangle = new Rectangle(20, 20, 100, 100);
            GLWindow  a1        = new GLWindow(name, rectangle, true);

            GLWindow.GLWindowOrientation        o1 = new GLWindow.GLWindowOrientation();
            List <GLWindow.GLWindowOrientation> l1 = new List <GLWindow.GLWindowOrientation>
            {
                o1
            };

            a1.SetAvailableOrientations(l1);

            a1.Destroy();
            tlog.Debug(tag, $"GLWindowSetAvailableOrientations END (OK)");
        }
Ejemplo n.º 21
0
        internal static Vector2 GetNormalizedMouseCoords(float mousex, float mousey, GLWindow window)
        {
            float x;
            float y;

            if (window.WindowState != WindowState.Fullscreen)
            {
                x = mousex - window.X - 8; // TODO: Find out why '8' ;-)
                y = mousey - window.Y - SystemInformation.CaptionHeight - 8;
            }
            else
            {
                x = mousex;
                y = mousey;
            }

            return(new Vector2(x, y));
        }
        public void GLWindowVisibilityChangedEventConstructor()
        {
            tlog.Debug(tag, $"GLWindowVisibilityChangedEventConstructor START");

            string    name  = "myGLWindow";
            Rectangle rec   = new Rectangle(20, 20, 100, 100);
            GLWindow  glwin = new GLWindow(name, rec, true);

            var testingTarget = new GLWindowVisibilityChangedEvent(glwin.SwigCPtr.Handle, false);

            Assert.IsNotNull(testingTarget, "Can't create success object GLWindowVisibilityChangedEvent");
            Assert.IsInstanceOf <GLWindowVisibilityChangedEvent>(testingTarget, "Should be an instance of GLWindowVisibilityChangedEvent type.");

            rec.Dispose();
            glwin.Destroy();
            testingTarget.Dispose();
            tlog.Debug(tag, $"GLWindowVisibilityChangedEventConstructor END (OK)");
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Gibt das GameObject zurück, das unter dem Mauszeiger liegt (Instanzen müssen mit IsPickable = true gesetzt haben)
        /// </summary>
        /// <param name="ms">Mausinformationen</param>
        /// <param name="offsetX">optionale Verschiebung des Cursors auf der X-Achse in Pixeln (Standard: 0)</param>
        /// <param name="offsetY">optionale Verschiebung des Cursors auf der X-Achse in Pixeln (Standard: 0)</param>
        /// <returns>Gewähltes GameObject</returns>
        public static GameObject PickGameObject(MouseState ms, int offsetX = 0, int offsetY = 0)
        {
            GLWindow w = GLWindow.CurrentWindow;

            if (w == null || w.CurrentWorld == null || !w.Focused)
            {
                return(null);
            }
            Vector2 mouseCoords = HelperGeneral.GetNormalizedMouseCoords(ms.X + offsetX, ms.Y + offsetY);
            Vector3 ray         = KWEngine.CurrentWindow.Get3DMouseCoords(mouseCoords.X, mouseCoords.Y);
            Vector3 pos;

            if (KWEngine.Projection == ProjectionType.Perspective)
            {
                pos = w.CurrentWorld.GetCameraPosition() + ray;
            }
            else
            {
                pos = HelperGeneral.GetRayOriginForOrthographicProjection(mouseCoords) + ray;
            }

            GameObject pickedObject   = null;
            float      pickedDistance = float.MaxValue;

            foreach (GameObject go in w.CurrentWorld.GetGameObjects())
            {
                if (go.IsPickable && go.IsInsideScreenSpace)
                {
                    if (GameObject.IntersectRaySphere(pos, ray, go.GetCenterPointForAllHitboxes(), go.GetMaxDiameter() / 2))
                    {
                        float distance = (go.GetCenterPointForAllHitboxes() - pos).LengthSquared;
                        if (distance < pickedDistance)
                        {
                            pickedDistance = distance;
                            pickedObject   = go;
                        }
                    }
                }
            }

            return(pickedObject);
        }
Ejemplo n.º 24
0
        public void GLWindowSetAvailableOrientationsNullValue()
        {
            tlog.Debug(tag, $"GLWindowSetAvailableOrientationsNullValue START");

            string    name          = "myGLWindow";
            Rectangle rectangle     = new Rectangle(20, 20, 100, 100);
            var       testingTarget = new GLWindow(name, rectangle, true);

            try
            {
                List <GLWindow.GLWindowOrientation> list = null;
                testingTarget.SetAvailableOrientations(list);
            }
            catch (ArgumentNullException)
            {
                testingTarget.Destroy();
                tlog.Debug(tag, $"GLWindowSetAvailableOrientationsNullValue END (OK)");
                Assert.Pass("Caught ArgumentNullException :  Passed!");
            }
        }
Ejemplo n.º 25
0
        public static byte[] GrabScreenshot(GLWindow game, int frontbuffer)
        {
            if (GraphicsContext.CurrentContext == null)
            {
                throw new GraphicsContextMissingException();
            }
            var backbuffer = game.MSAABuffer.Framebuffer;

            byte[] screenshot = new byte[game.RenderSize.Width * game.RenderSize.Height * 3];// 3 bytes per pixel
            SafeFrameBuffer.BindFramebuffer(FramebufferTarget.ReadFramebuffer, backbuffer);
            SafeFrameBuffer.BindFramebuffer(FramebufferTarget.DrawFramebuffer, frontbuffer);
            SafeFrameBuffer.BlitFramebuffer(0, 0, game.RenderSize.Width, game.RenderSize.Height,
                                            0, 0, game.RenderSize.Width, game.RenderSize.Height,
                                            ClearBufferMask.ColorBufferBit, BlitFramebufferFilter.Nearest);
            SafeFrameBuffer.BindFramebuffer(FramebufferTarget.ReadFramebuffer, frontbuffer);

            GL.ReadPixels(0, 0, game.RenderSize.Width, game.RenderSize.Height,
                          OpenTK.Graphics.OpenGL.PixelFormat.Bgr, PixelType.UnsignedByte, screenshot);
            SafeFrameBuffer.BindFramebuffer(FramebufferTarget.Framebuffer, backbuffer);
            return(screenshot);
        }
Ejemplo n.º 26
0
        public void GLWindowWindowSizeNullValue()
        {
            tlog.Debug(tag, $"GLWindowWindowSizeNullValue START");

            var testingTarget = new GLWindow();

            Assert.IsNotNull(testingTarget, "Can't create success object GLWindow");
            Assert.IsInstanceOf <GLWindow>(testingTarget, "Should be an instance of GLWindow type.");

            try
            {
                Size2D size2d = null;
                testingTarget.WindowSize = size2d;
            }
            catch (ArgumentNullException)
            {
                testingTarget.Destroy();
                tlog.Debug(tag, $"GLWindowWindowSizeNullValue END (OK)");
                Assert.Pass("Caught ArgumentNullException : Passed!");
            }
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Prüft, ob der Mauszeiger auf dem HUD-Objekt ist
        /// </summary>
        /// <param name="ms">Mausinfo</param>
        /// <returns>true, wenn die Maus auf dem HUD-Objekt ist</returns>
        public bool IsMouseCursorOnMe(MouseState ms)
        {
            GLWindow w = KWEngine.CurrentWindow;

            if (w._windowRect.Contains(ms.X, ms.Y))
            {
                Vector2 coords = HelperGL.GetNormalizedMouseCoords(ms.X, ms.Y, w);
                float   left, right, top, bottom;

                if (_type == HUDObjectType.Image)
                {
                    left  = _absolute.X - _scale.X * 0.5f;
                    right = _absolute.X + _scale.X * 0.5f;

                    top    = _absolute.Y - _scale.Y * 0.5f;
                    bottom = _absolute.Y + _scale.Y * 0.5f;
                }
                else
                {
                    left  = _absolute.X - _scale.X * 0.5f;
                    right = _absolute.X + ((_count - 1) * _spread) + _scale.X * 0.5f;

                    top    = _absolute.Y - _scale.Y * 0.5f;
                    bottom = _absolute.Y + _scale.Y * 0.5f;
                }

                if (coords.X >= left && coords.X <= right && coords.Y >= top && coords.Y <= bottom)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 28
0
        static void Main(params string[]  args)
        {
            GLWindow window = new GLWindow();
            Scene    scene  = CoreEngine.MainScene;

            if (args.Length != 0)
            {
                SceneNode modelNode = ResourcesManager.LoadAsset <ModelPrefab>(args[0]).CreateNode();
                modelNode.Name = "model";
                scene.AddNode2Root(modelNode);
            }
            var       camera     = new Camera();
            SceneNode cameraNode = new SceneNode();

            cameraNode.Name = "Camera";
            cameraNode.AddComponent(camera);
            cameraNode.AddComponent <CameraControllOrbitScript>();
            //cameraNode.AddComponent<FrameTimeScript>();
            //cameraNode.GetTransform.Position = new Vector3(0, 1f, 3);

            scene.AddNode2Root(cameraNode);
            cameraNode.AddComponent <DynamicFormScript>();

            var task = new Task(() =>
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                var form         = new Form1();
                form.scene       = scene;
                form.FormClosed += (s, e) => window.Close();
                form.cam         = camera;
                Application.Run(form);
            });

            task.Start();

            window.Title = "ModelViewer";
            window.Run();
        }
Ejemplo n.º 29
0
        public void GLWindowSetEglConfig()
        {
            tlog.Debug(tag, $"GLWindowSetEglConfig START");

            var testingTarget = new GLWindow();

            Assert.IsNotNull(testingTarget, "Can't create success object GLWindow");
            Assert.IsInstanceOf <GLWindow>(testingTarget, "Should be an instance of GLWindow type.");

            try
            {
                testingTarget.SetEglConfig(true, true, 10, GLESVersion.Version20);
            }
            catch (Exception e)
            {
                tlog.Debug(tag, e.Message.ToString());
                Assert.Fail("Caught Exception: Failed!");
            }

            testingTarget.Destroy();
            tlog.Debug(tag, $"GLWindowSetEglConfig END (OK)");
        }
Ejemplo n.º 30
0
        public void RunDemo()
        {
            const uint      screenWidth  = 250;
            const uint      screenHeight = 250;
            GLWindow        window       = new GLWindow((int)screenWidth, (int)screenHeight, 4, 4, AppName);
            PixelGameEngine pge          = new PixelGameEngine(AppName);

            pge.Construct(screenWidth, screenHeight, window);
            pge.OnFrameUpdate += (sender, frameUpdateArgs) =>
            {
                Random rnd = new Random();

                for (uint x = 0; x < pge.ScreenWidth; x++)
                {
                    for (uint y = 0; y < pge.ScreenHeight; y++)
                    {
                        pge.Draw(x, y, new Pixel((byte)rnd.Next(255), (byte)rnd.Next(255), (byte)rnd.Next(255)));
                    }
                }

                pge.DrawString(0, 0, "Sup?", Pixel.WHITE);
            };
            pge.Start();
        }
Ejemplo n.º 31
0
        public ColorTableManager(GLWindow glcontrol)
        {
            this.glcontrol = glcontrol;
            this.Bounds = new Rectangle(Point.Empty, glcontrol.Size);
            SetCursor(CursorType.Default);

            ShowColormapPickerAction = ActionManager.CreateAction("Show colormap picker", "show picker", delegate(object[] parameters) {
                pickerVisible = true;
                return null;
            });
            HideColormapPickerAction = ActionManager.CreateAction("Hide colormap picker", "hide picker", delegate(object[] parameters) {
                pickerVisible = false;
                return null;
            });

            // Create shaders as singleton
            /*if(colortableshader == null)
                colortableshader = new GLShader(new string[] {COLOR_TABLE_SHADER.VS}, new string[] {COLOR_TABLE_SHADER.FS});*/
            if(lineshader == null)
                lineshader = new GLShader(new string[] {LINE_SHADER.VS}, new string[] {LINE_SHADER.FS});
            if(cmpreviewshader == null)
                cmpreviewshader = new GLShader(new string[] {COLORMAP_PREVIEW_SHADER.VS}, new string[] {COLORMAP_PREVIEW_SHADER.FS});

            // Create input section
            input = new InputSection(this, new GLTextFont2(new Font("Lucida Sans Unicode", 12.0f)));
            input.Bounds = new Rectangle(130, 60, glcontrol.Width - 260, 200);//new Rectangle(100, glcontrol.Height - 60, glcontrol.Width - 400, 40);
            input.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom;
            this.Controls.Add(input);

            // Create colormap picker
            picker = new ColorMapPicker(new GLTextFont2(new Font("Lucida Sans Unicode", 12.0f/*, FontStyle.Bold*/)));
            picker.bounds = new Rectangle(0, 0, glcontrol.Width, input.Bounds.Top);
            picker.ColormapDragStart += ColorMapPicker_ColormapDragStart;

            // Create/load colormaps
            AddColormap(ColorTableFromSolidColor(Color4.Red, Vector3.Zero, "Red"));
            AddColormap(ColorTableFromSolidColor(Color4.Orange, Vector3.Zero, "Orange"));
            AddColormap(ColorTableFromSolidColor(Color4.Yellow, Vector3.Zero, "Yellow"));
            AddColormap(ColorTableFromSolidColor(Color4.Green, Vector3.Zero, "Green"));
            AddColormap(ColorTableFromSolidColor(new Color4(0.215686f, 0.278431f, 0.082353f, 1.0f), Vector3.Zero, "Green2"));
            AddColormap(ColorTableFromSolidColor(Color4.Blue, Vector3.Zero, "Blue"));
            AddColormap(ColorTableFromSolidColor(new Color4(0.082353f, 0.133333f, 0.278431f, 1.0f), Vector3.Zero, "Blue2"));
            AddColormap(ColorTableFromSolidColor(Color4.White, Vector3.Zero, "White"));
            AddColormap(ColorTableFromSolidColor(Color4.Gray, Vector3.Zero, "Gray"));
            AddColormap(ColorTableFromSolidColor(Color4.Black, Vector3.Zero, "Black"));
            AddColormap(ColorTableFromSolidColor(new Color4(1.0f, 1.0f, 1.0f, 0.25f), Vector3.Zero, "25% White", "Transparent"));
            AddColormap(ColorTableFromSolidColor(new Color4(1.0f, 1.0f, 1.0f, 0.5f), Vector3.Zero, "50% White", "Transparent"));
            AddColormap(ColorTableFromSolidColor(new Color4(0.0f, 0.0f, 0.0f, 0.25f), Vector3.Zero, "25% Black", "Transparent"));
            AddColormap(ColorTableFromSolidColor(new Color4(0.0f, 0.0f, 0.0f, 0.5f), Vector3.Zero, "50% Black", "Transparent"));
            AddColormap(ColorTableFromSolidColor(new Color4(1.0f, 0.0f, 0.0f, 0.25f), Vector3.Zero, "25% Red", "Transparent"));
            AddColormap(ColorTableFromSolidColor(new Color4(1.0f, 0.0f, 0.0f, 0.5f), Vector3.Zero, "50% Red", "Transparent"));
            /*ColorMapCreator.Vector3 C0 = new ColorMapCreator.Vector3(58.650f, 76.245f, 192.270f);
            ColorMapCreator.Vector3 C1 = new ColorMapCreator.Vector3(180.030f, 4.080f, 38.250f);
            AddColormap(ColorTableFromRange(C0, C1, new Vector3(65.0f / 255.0f, 68.0f / 255.0f, 91.0f / 255.0f), "Moreland cool/warm", "Divergent"));*/
            AddColormaps(ColorTableFromXml(Global.EXE_DIR + "ColorMaps.xml"));
            //AddColormap(NamedColorTable.None);

            // Overwrite default //EDIT: DELETE
            //colormaps.Remove("_default"); //EDIT: DELETE
            //colormaps.Add("_default", colormaps["KineticEnergy"]); //EDIT: DELETE

            ActionManager.Do(HideColormapPickerAction);
            Reset();
            input.UpdateColormap();

            // Create buttons
            buttons = new GLButton[5];
            buttons[0] = new GLButton(Global.EXE_DIR + "splitterButton.png", new Rectangle(4, 100, 0, 0), AnchorStyles.Bottom | AnchorStyles.Left, "CreateSplitter", "Create colormap splitter");
            buttons[0].Click = SplitterButton_Click;
            buttons[1] = new GLButton(Global.EXE_DIR + "interjectorButton.png", new Rectangle(4, 100 - buttons[0].Bounds.Height, 0, 0), AnchorStyles.Bottom | AnchorStyles.Left, "CreateInterjector", "Create colormap interjector");
            buttons[1].Click = InterjectorButton_Click;
            buttons[2] = new GLButton(Global.EXE_DIR + "colorMapButton.png", new Rectangle(4, 100, 0, 0), AnchorStyles.Bottom | AnchorStyles.Right, "ShowColormapPicker", "Show colormap picker");
            buttons[2].Click = ColorMapButton_Click;
            buttons[3] = new GLButton(Global.EXE_DIR + "saveColorMapButton.png", new Rectangle(4, 100 - buttons[2].Bounds.Height, 0, 0), AnchorStyles.Bottom | AnchorStyles.Right, "SaveColormap", "Save colormap to disk");
            buttons[3].Click = SplitterButton_Click;
            buttons[3].Visible = false;
            buttons[4] = new GLButton(Global.EXE_DIR + "trashButton.png", new Rectangle(4, 100, 0, 0), AnchorStyles.Bottom | AnchorStyles.Left, "RemoveSplitter", "Remove colormap splitter");
            buttons[4].MouseUp = TrashButton_MouseUp;
            buttons[4].Visible = false;

            // Create cursors
            cursors = new GLCursor[2];
            cursors[0] = new GLCursor(Global.EXE_DIR + "splitterCursor.png", new Point(2, 54));
            cursors[1] = new GLCursor(Global.EXE_DIR + "interjectorCursor.png", new Point(8, 51));

            /*HISTORY_PATH = System.Reflection.Assembly.GetEntryAssembly().Location;
            HISTORY_PATH = HISTORY_PATH.Substring(0, Math.Max(HISTORY_PATH.LastIndexOf('/'), HISTORY_PATH.LastIndexOf('\\')) + 1);
            HISTORY_PATH += ".colormap";

            if(System.IO.File.Exists(HISTORY_PATH))
            {
                System.IO.StreamReader sr = new System.IO.StreamReader(HISTORY_PATH);
                while(sr.Peek() != -1)
                    history.Add(sr.ReadLine());
                sr.Close();
                history_idx = history.Count;
            }*/
        }
Ejemplo n.º 32
0
		public void Init(GLWindow glcontrol, GLTextureStream.ReadImageMetaDataDelegate ReadImageMetaData)
		{
			this.glcontrol = glcontrol;
			glcontrol.GotFocus += (object sender, EventArgs e) => { glcontrol_focused = true; };
			glcontrol.LostFocus += (object sender, EventArgs e) => { glcontrol_focused = false; };
			glcontrol_focused = true;

			// Define actions
			SetViewControlAction = ActionManager.CreateAction("Set View Control", this, "SetViewControl");
			EnableDepthRenderingAction = ActionManager.CreateAction("Enable Depth Rendering", "enable depth", this, "EnableDepthRendering");
			DisableDepthRenderingAction = ActionManager.CreateAction("Disable Depth Rendering", "disable depth", this, "DisableDepthRendering");
			MoveAction = ActionManager.CreateAction("Move images", this, "Move");
			/*ActionManager.CreateAction("Select all", "all", this, "SelectAll");
			ActionManager.CreateAction("Select and focus all", "focus all", delegate(object[] parameters) {
				this.SelectAll();
				this.FocusSelection();
			});*/

			// Load shaders
			sdrAabb = new GLShader(new string[] {AABB_SHADER.VS}, new string[] {AABB_SHADER.FS});

			// Create mesh for non-depth rendering
#if USE_GS_QUAD
			mesh2D = new GLMesh(new Vector3[] {new Vector3(0.0f, 0.0f, 0.0f)}, null, null, null, null, null, PrimitiveType.Points); // Use this when rendering geometry shader quads
#else
			mesh2D = Common.meshQuad2;
#endif

			texstream = new GLTextureStream(256*1024*1024, ReadImageMetaData); // Optimize for 1GB of VRAM
			//texstream = new GLTextureStream(64*1024*1024, ReadImageMetaData); // Optimize for 256MB of VRAM
			//texstream = new GLTextureStream(8*1024*1024, ReadImageMetaData); // Optimize for 32MB of VRAM
			//texstream = new GLTextureStream(1024*1024, ReadImageMetaData); // Optimize for 4MB of VRAM
			//texstream = new GLTextureStream(128*1024, ReadImageMetaData); // Optimize for 512KB of VRAM

			#if USE_ARG_IDX
			argIndex.Bounds = new Rectangle(250, 10, Width - 250, 16);
			//argIndex.Bounds = new Rectangle(150, 10, Width - 150, 16);
			argIndex.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
			argIndex.Init();
			argIndex.SelectionChanged += SelectionChanged;//() => { SelectionChanged(); };
			//argIndex.ArgumentLabelMouseDown += ArgumentIndex_ArgumentLabelMouseDown;
			this.Controls.Add(argIndex);
			#endif

			#if USE_PARAM_IDX
			//paramIndex.Bounds = new Rectangle(200, 0, Width - 200, 16);
			//paramIndex.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
			paramIndex.Bounds = new Rectangle(16, 0, 300, 16);
			paramIndex.Anchor = AnchorStyles.Top | AnchorStyles.Right;
			paramIndex.Init();
			paramIndex.ParameterChanged += (Cinema.CinemaStore.Parameter parameter, int paramidx) => {
				foreach(TransformedImage image in images)
					image.OnParameterChanged(parameter, paramidx);
			};
			this.Controls.Add(paramIndex);
			#endif

			#if USE_CUSTOM_CONTROLS
			ccContainer.Bounds = new Rectangle(250, 10, Width - 300, 16);
			ccContainer.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
			ccContainer.Init();
			/*ccContainer.CustomControlValueChanged += (int controlIdx, float value) => {
				//EDIT
			};*/
			this.Controls.Add(ccContainer);
			#endif

			colorTableMgr = new ColorTableManager(glcontrol);
			colorTableMgr.Visible = false;
			this.Controls.Add(colorTableMgr);

			coordsys = new CoordinateSystem();
			grid = new LineGrid();

			ContextMenu = new ImageContextMenu();

			fragmentcounter = GL.GenQuery();

//ccContainer.CreateSlider("testSlider", new float[] { 0.0f, 0.5f, 1.0f });
		}