Example #1
0
        static void Main(string[] args)
        {
            // create an OpenGL window
            Glut.glutInit();
            Glut.glutInitDisplayMode(Glut.GLUT_DOUBLE
                                     | Glut.GLUT_DEPTH);
            Glut.glutInitWindowSize(width, height);
            Glut.glutCreateWindow("OpenGL Tutorial");

            // provide the Glut callbacks that are necessary for running this tutorial
            Glut.glutIdleFunc(OnRenderFrame);
            Glut.glutDisplayFunc(OnDisplay);
            Gl.Enable(EnableCap.DepthTest);

            program = new ShaderProgram(VertexShader, FragmentShader);

            // set the view and projection matrix, which are static throughout this tutorial
            program.Use();
            program["projection_matrix"].SetValue(Matrix4.CreatePerspectiveFieldOfView(0.45f, (float)width / height, 0.1f, 1000f));
            program["view_matrix"].SetValue(Matrix4.LookAt(new Vector3(0, 0, 10), Vector3.Zero, new Vector3(0, 1, 0)));

            // create a triangle
            squareVertexes = new VBO <Vector3>(new Vector3[] { new Vector3(-1, -1, 0),
                                                               new Vector3(-1, 1, 0),
                                                               new Vector3(1, 1, 0),
                                                               new Vector3(1, -1, 0) });
            squareElements = new VBO <int>(new int[] { 0, 1, 2, 3 }, BufferTarget.ElementArrayBuffer);

            squares = Reader.readFromFile("input.txt");

            watch = System.Diagnostics.Stopwatch.StartNew();

            Glut.glutMainLoop();
        }
        static void Main(string[] args)
        {
            // create an OpenGL window
            Glut.glutInit();
            Glut.glutInitDisplayMode(Glut.GLUT_DOUBLE | Glut.GLUT_DEPTH);
            Glut.glutInitWindowSize(width, height);
            Glut.glutCreateWindow("OpenGL Tutorial");

            // provide the Glut callbacks that are necessary for running this tutorial
            Glut.glutIdleFunc(OnRenderFrame);
            Glut.glutDisplayFunc(OnDisplay);
            Glut.glutCloseFunc(OnClose);
            Glut.glutKeyboardFunc(OnKeyboard);

            time_ = 0;
            Matrix4 modelMatrix = CreateModelMatrix(time_);

            context_     = new NeutrinoGl.Context("..\\..\\effects\\textures\\");
            effectModel_ = new NeutrinoGl.EffectModel(context_, new Neutrino.Effect_params_test());
            effect_      = new NeutrinoGl.Effect(effectModel_, Neutrino._math.vec3_(modelMatrix[3].x, modelMatrix[3].y, modelMatrix[3].z), null);
            effect_.neutrinoEffect().setEmitterPropertyValue(null, "Color", Neutrino._math.vec3_(1, 1, 0));

            // load a crate texture
            watch = System.Diagnostics.Stopwatch.StartNew();

            Glut.glutMainLoop();
        }
Example #3
0
        // --- Entry Point ---
        #region Run()
        public static void Run()
        {
            // initialize GLUT
            Glut.glutInit();
            // double buffer, use rgb color, enable depth buffers
            Glut.glutInitDisplayMode(Glut.GLUT_DOUBLE | Glut.GLUT_RGB | Glut.GLUT_DEPTH);
            // initialize the window size
            Glut.glutInitWindowSize(windowWidth, windowHeight);
            // set the window postion
            Glut.glutInitWindowPosition(100, 100);
            // create the window
            Glut.glutCreateWindow("Starfield");

            // set the display function - called when redrawing
            Glut.glutDisplayFunc(new Glut.DisplayCallback(Display));
            // set the idle function - called when idle
            Glut.glutIdleFunc(new Glut.IdleCallback(Idle));
            // set the keyboard function - called on keyboard events
            Glut.glutKeyboardFunc(new Glut.KeyboardCallback(Keyboard));
            // set the mouse function - called on mouse stuff
            Glut.glutMouseFunc(new Glut.MouseCallback(Mouse));
            // set the reshape function - called when client area changes
            Glut.glutReshapeFunc(new Glut.ReshapeCallback(Reshape));

            // do our own initialization
            Init();

            // let GLUT handle the current thread from here
            Glut.glutMainLoop();
        }
Example #4
0
 public static void Start()
 {
     Glut.glutDisplayFunc(Display);
     Glut.glutReshapeFunc(Reshape);
     Glut.glutKeyboardFunc(Keyb);
     Glut.glutMainLoop();
 }
        static void Main(string[] args)
        {
            // create an OpenGL window
            Glut.glutInit();
            Glut.glutInitDisplayMode(Glut.GLUT_DOUBLE | Glut.GLUT_DEPTH);
            Glut.glutInitWindowSize(width, height);
            Glut.glutCreateWindow("OpenGL Tutorial");

            // provide the Glut callbacks that are necessary for running this tutorial
            Glut.glutIdleFunc(OnRenderFrame);
            Glut.glutDisplayFunc(OnDisplay);
            Glut.glutCloseFunc(OnClose);

            // compile the shader program
            program = new ShaderProgram(VertexShader, FragmentShader);

            // set the view and projection matrix, which are static throughout this tutorial
            program.Use();
            program["projection_matrix"].SetValue(Matrix4.CreatePerspectiveFieldOfView(0.45f, (float)width / height, 0.1f, 1000f));
            program["view_matrix"].SetValue(Matrix4.LookAt(new Vector3(0, 0, 10), Vector3.Zero, new Vector3(0, 1, 0)));

            // create a triangle
            triangle         = new VBO <Vector3>(new Vector3[] { new Vector3(0, 1, 0), new Vector3(-1, -1, 0), new Vector3(1, -1, 0) });
            triangleElements = new VBO <uint>(new uint[] { 0, 1, 2 }, BufferTarget.ElementArrayBuffer);

            // create a square
            square         = new VBO <Vector3>(new Vector3[] { new Vector3(-1, 1, 0), new Vector3(1, 1, 0), new Vector3(1, -1, 0), new Vector3(-1, -1, 0) });
            squareElements = new VBO <uint>(new uint[] { 0, 1, 2, 3 }, BufferTarget.ElementArrayBuffer);

            Glut.glutMainLoop();
        }
Example #6
0
        static void Main(string[] args)
        {
            scene = new Scene.Scene(800, 600);

            menuList.Add(new InfoMenu(300, scene.HEIGHT - 20, 0, bottomHeight + 20));
            menuList.Add(new BottomMenu(scene.WIDTH, bottomHeight, 0, 0));

            Glut.glutInit();

            Glut.glutInitDisplayMode(Glut.GLUT_DOUBLE | Glut.GLUT_RGBA | Glut.GLUT_DEPTH);
            Glut.glutInitWindowSize(scene.WIDTH + menuList[0].WIDTH, scene.HEIGHT + menuList[1].HEIGHT);

            Glut.glutInitWindowPosition(100, 10);
            int id = Glut.glutCreateWindow("Scene Editor");

            Init();
            Glut.glutDisplayFunc(new Glut.DisplayCallback(Draw));
            Glut.glutKeyboardFunc(new Glut.KeyboardCallback(KeyboardHandle));
            Glut.glutMouseFunc(new Glut.MouseCallback(MouseHandle));
            Glut.glutMouseWheelFunc(new Glut.MouseWheelCallback(MouseWheelHandle));
            //Glut.glutReshapeFunc(new Glut.ReshapeCallback(Resize));
            Glut.glutTimerFunc(1000 / 60, Update, 0);

            Glut.glutMainLoop();
        }
Example #7
0
        public static void Run()
        {
            Glut.glutInit();
            Glut.glutInitDisplayMode(Glut.GLUT_DEPTH | Glut.GLUT_DOUBLE | Glut.GLUT_RGB);
            Glut.glutInitWindowPosition(50, 50);
            Glut.glutCreateWindow("Voronoi");

            Glut.glutDisplayFunc(new Glut.DisplayCallback(Display));
            Glut.glutKeyboardFunc(new Glut.KeyboardCallback(Keyboard));
            Glut.glutMouseFunc(new Glut.MouseCallback(Mouse));
            Glut.glutReshapeFunc(new Glut.ReshapeCallback(Reshape));

            Glut.glutCreateMenu(new Glut.CreateMenuCallback(Menu));
            Glut.glutAddMenuEntry("Voronoi", 0);
            Glut.glutAddMenuEntry("", 0);
            Glut.glutAddMenuEntry("[r] Reset", (int)'r');
            Glut.glutAddMenuEntry("[p] Toggle points", (int)'p');
            Glut.glutAddMenuEntry("", 0);
            Glut.glutAddMenuEntry("Quit", 27);
            Glut.glutAttachMenu(Glut.GLUT_RIGHT_BUTTON);

            Init();

            Glut.glutMainLoop();
        }
Example #8
0
        static void Main(string[] args)
        {
            int w = 400;
            int h = 400;

            Glut.glutInit();
            Gl.glEnable(Gl.GL_DEPTH_TEST);
            Glut.glutInitDisplayMode(Glut.GLUT_DEPTH | Glut.GLUT_SINGLE | Glut.GLUT_RGB);
            Glut.glutInitWindowSize(w, h);
            Glut.glutInitWindowPosition(400, 300);
            Glut.glutCreateWindow("Pradzia");
            Init();
            Glut.glutDisplayFunc(new Glut.DisplayCallback(Vaizdavimas));
            Glut.glutSpecialFunc(new Glut.SpecialCallback(Klaviatura));
            Glut.glutCreateMenu(new Glut.CreateMenuCallback(Menu));
            Glut.glutReshapeFunc(new Glut.ReshapeCallback(Perpiesti));
            Glut.glutAddMenuEntry("Difuse", 1);
            Glut.glutAddMenuEntry("Specular", 2);
            Glut.glutAddMenuEntry("Ambient", 3);
            Glut.glutAddMenuEntry("Du sviesos saltiniai", 4);
            Glut.glutAddMenuEntry("+45 laipsniai X", 5);
            Glut.glutAddMenuEntry("-45 laipsniai X", 6);
            Glut.glutAddMenuEntry("Pabaiga", 9);
            Glut.glutAttachMenu(Glut.GLUT_RIGHT_BUTTON);
            Glut.glutMainLoop();
        }
Example #9
0
        public static void Main(string[] args)
        {
            int i, j;

            Glut.glutInit();
            Glut.glutInitDisplayMode(Glut.GLUT_DOUBLE | Glut.GLUT_RGBA);
            Glut.glutInitWindowSize(320, 320);
            Glut.glutInitWindowPosition(50, 50);
            Glut.glutCreateWindow("Null");

            Glut.glutDisplayFunc(new Glut.DisplayCallback(Display));
            Glut.glutKeyboardFunc(new Glut.KeyboardCallback(Keyboard));
            Glut.glutMotionFunc(new Glut.MotionCallback(Motion));
            Glut.glutMouseFunc(new Glut.MouseCallback(Mouse));
            Glut.glutReshapeFunc(new Glut.ReshapeCallback(Reshape));

            // Create a pretty color ramp
            for (j = 0; j < 256; j++)
            {
                for (i = 0; i < 256; i++)
                {
                    image[(256 * j + i) * 3 + 0] = (byte)(255 - i * j / 255);
                    image[(256 * j + i) * 3 + 1] = (byte)i;
                    image[(256 * j + i) * 3 + 2] = (byte)j;
                }
            }

            Glut.glutMainLoop();
        }
Example #10
0
        static void Main(string[] args)
        {
            int w = 400;
            int h = 400;

            Glut.glutInit();
            Glut.glutInitDisplayMode(Glut.GLUT_SINGLE | Glut.GLUT_RGB);
            Glut.glutInitWindowSize(w, h);
            Glut.glutInitWindowPosition(400, 300);
            Glut.glutCreateWindow("Pradzia");
            Init();
            Glut.glutDisplayFunc(new Glut.DisplayCallback(Piesk));
            Glut.glutCreateMenu(new Glut.CreateMenuCallback(Menu));
            Glut.glutAddMenuEntry("(1)Ketvirtis is virsaus", 1);
            Glut.glutAddMenuEntry("(2)Figura is virsaus", 2);
            Glut.glutAddMenuEntry("(3)Figura is sono", 3);
            Glut.glutAddMenuEntry("(4)Fugura paversta", 4);
            Glut.glutAddMenuEntry("(5)Sumazint, pasukt ir pastumt", 5);
            Glut.glutAddMenuEntry("(6)glu.Perspective", 6);
            Glut.glutAddMenuEntry("(7)glFrustum", 7);
            Glut.glutAddMenuEntry("Astuntas punktas", 8);
            Glut.glutAddMenuEntry("Pabaiga", 9);
            Glut.glutAttachMenu(Glut.GLUT_RIGHT_BUTTON);
            Glut.glutMainLoop();
        }
Example #11
0
        static void Main(string[] args)
        {
            try
            {
                init();
                Glut.glutDisplayFunc(Draw);
                Glut.glutReshapeFunc(reshape);
                Glut.glutKeyboardFunc(new Glut.KeyboardCallback(pressKey));
                Glut.glutSpecialFunc(new Glut.SpecialCallback(specialKey));

                Glut.glutIgnoreKeyRepeat(1);
                Glut.glutKeyboardUpFunc(new Glut.KeyboardUpCallback(releaseKey));

                Glut.glutTimerFunc(33, on_timer, 0);
                Glut.glutMainLoop();
            }
            catch (FileReadException e)
            {
                Console.WriteLine(e.exception);
            }
            catch
            {
                Console.WriteLine("Some unknow expection...=(");
            }
        }
Example #12
0
        //private static int loop;
        #endregion Private Fields

        // --- Entry Point ---
        #region Main()
        /// <summary>

        ///

        /// </summary>
        public static void Main()
        {
            Glut.glutInit();
            Glut.glutInitDisplayMode(Glut.GLUT_DEPTH | Glut.GLUT_DOUBLE | Glut.GLUT_RGB);
            Glut.glutInitWindowSize(400, 400);
            Alut.alutInit();
            window = Glut.glutCreateWindow("OpenAL & OpenGL | www.dev-gallery.com");
            Init();
            Console.WriteLine("Controls:");
            Console.WriteLine("1: Activate Red Sound");
            Console.WriteLine("2: Activate Green Sound");
            Console.WriteLine("3: Activate Blue Sound");
            Console.WriteLine("4: Deactivate Red Sound");
            Console.WriteLine("5: Deactivate Green Sound");
            Console.WriteLine("6: Deactivate Blue Sound");
            Console.WriteLine("W: Move Forward");
            Console.WriteLine("A: Move Left");
            Console.WriteLine("S: Move Backward");
            Console.WriteLine("D: Move Right");
            Console.WriteLine("ESC: Exit");
            Glut.glutDisplayFunc(new Glut.DisplayCallback(Display));
            Glut.glutKeyboardFunc(new Glut.KeyboardCallback(Keyboard));
            Glut.glutReshapeFunc(new Glut.ReshapeCallback(Reshape));
            Glut.glutMainLoop();
        }
Example #13
0
        /*
         * creating the window for the 3d opengl graphics engine
         *
         * */
        public static void displayWindow()
        {
            Glut.glutInit();

            /*
             * Glut.GLUT_DOUBLE: Double buffer removes any tearing/flickering of the screen-
             *                  -Drawing on the back buffer (video memory)
             * Glut.GLUT_DEPTH: Location and color of the screen. Closest gets drawn.
             * */
            Glut.glutInitDisplayMode(Glut.GLUT_DOUBLE | Glut.GLUT_DEPTH);

            Glut.glutInitWindowSize(width, height);             // width and height of the engine's window
            Glut.glutCreateWindow("3D OpenGL Graphics Engine"); // title of the engine


            Glut.glutIdleFunc(OnRenderFrame);
            Glut.glutDisplayFunc(OnDisplay);
            Glut.glutCloseFunc(closeProgram);
            Gl.Enable(EnableCap.DepthTest);



            SquareDrawing();


            Glut.glutMainLoop();
        }
Example #14
0
        private void button1_Click(object sender, EventArgs e)
        {
            Glut.glutInitDisplayMode(Glut.GLUT_DOUBLE | Glut.GLUT_RGB);

            Glut.glutInitWindowSize(500, 500);
            Glut.glutCreateWindow("Чайник");

            Gl.glShadeModel(Gl.GL_SMOOTH);//Установите модель затенения
            Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT);
            Gl.glEnable(Gl.GL_LIGHTING);
            Gl.glEnable(Gl.GL_LIGHT0);
            float[] light_pos = new float[3] {
                1, 0.5F, 1
            };
            Gl.glLightfv(Gl.GL_LIGHT0, Gl.GL_POSITION, light_pos);
            Gl.glClearDepth(1.0f);         //Установите значение буфера глубины (ranges[0,1])
            Gl.glEnable(Gl.GL_DEPTH_TEST); //Включить тест глубины
            Gl.glDepthFunc(Gl.GL_LEQUAL);  //Если два объекта с одинаковыми координатами показывают первый нарисованный
            Gl.glClearColor(255, 255, 255, 1);
            Gl.glHint(Gl.GL_PERSPECTIVE_CORRECTION_HINT, Gl.GL_NICEST);

            Glut.glutReshapeFunc(reshape); //Изменение размеров окна
            Glut.glutDisplayFunc(render);  //Функция перерисовки окна
            // Установить обратный вызов ключа окна
            Glut.glutKeyboardFunc(new Glut.KeyboardCallback(keyboard));
            // Установите для окна специальный обратный вызов
            Glut.glutSpecialFunc(new Glut.SpecialCallback(specialKey));
            // Установить окна для обратного вызова движения мыши
            Glut.glutMouseWheelFunc(new Glut.MouseWheelCallback(processMouseWheel));
            Glut.glutMainLoop();
        }
Example #15
0
        /*private void keyboard(byte key, int x, int y)
         * {
         *      int mod = Glut.glutGetModifiers();
         *              if(mod==Glut.GLUT_ACTIVE_CTRL) ctrl=true;
         *              else ctrl=false;
         * }*/

        /**
         * luo glut ikkuna, aseta callbackit ja luo tyhjä texture
         */
        void create(int width, int height)
        {
            Glut.glutInit();
            Glut.glutInitDisplayMode(Glut.GLUT_DOUBLE | Glut.GLUT_RGB);
            Glut.glutInitWindowSize(width, height);
            Glut.glutInitWindowPosition(100, 100);
            Glut.glutCreateWindow("CSPaint");

            Glut.glutDisplayFunc(new Glut.DisplayCallback(display));
            Glut.glutMouseFunc(new Glut.MouseCallback(mouseButton));
            Glut.glutMotionFunc(new Glut.MotionCallback(mouseMotion));
            Glut.glutCloseFunc(new Glut.CloseCallback(closeWindow));
            Glut.glutReshapeFunc(new Glut.ReshapeCallback(reshape));
            //Glut.glutKeyboardFunc(new Glut.KeyboardCallback(keyboard));

            Gl.glDisable(Gl.GL_LIGHTING);
            Gl.glClearColor(1, 1, 1, 1);
            Gl.glClear(Gl.GL_COLOR_BUFFER_BIT);
            Gl.glDisable(Gl.GL_CULL_FACE);

            Gl.glDisable(Gl.GL_DEPTH_TEST);
            Gl.glMatrixMode(Gl.GL_PROJECTION);
            Gl.glLoadIdentity();
            Gl.glOrtho(0, width, height, 0, -1, 1);
            Gl.glMatrixMode(Gl.GL_MODELVIEW);
            Gl.glLoadIdentity();

            // luo yksi taso
            newLayer();
        }
Example #16
0
        static void Init()
        {
            Glut.glutInit();
            Glut.glutInitDisplayMode(Glut.GLUT_DEPTH | Glut.GLUT_DOUBLE | Glut.GLUT_RGB);
            Glut.glutInitWindowSize(1024, 700);
            //Glut.glutInitWindowPosition(150, 0);
            Glut.glutInitWindowPosition(150, 0);
            Glut.glutCreateWindow("Computação Gráfica");

            ContentManager.SetModelList("modelos\\");
            ContentManager.LoadModels();
            Load3dsModels();

            Gl.glMatrixMode(Gl.GL_PROJECTION);
            Gl.glLoadIdentity();

            SetupLight();

            Glu.gluPerspective(35.0f, 1.0, 0.001, 100.0);
            Gl.glMatrixMode(Gl.GL_MODELVIEW);
            Glu.gluLookAt(0.0, 1.0, 8.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);

            Gl.glClearColor(0.498039f, 1, 0.831373f, 0.0f);
            Glut.glutTimerFunc(1, airplane.Timer, 1);

            Gl.glEnable(Gl.GL_DEPTH_TEST);
            Glut.glutDisplayFunc(Render);

            RegisterFuncs();

            Glut.glutMainLoop();
        }
Example #17
0
        public static void Main2

            (string[] argv)
        {
            Glut.glutInit();
            //Glut.glutInitDisplayMode(Glut.GLUT_DOUBLE | Glut.GLUT_RGB | Glut.GLUT_ALPHA | Glut.GLUT_DEPTH);
            Glut.glutInitDisplayMode(Glut.GLUT_DOUBLE | Glut.GLUT_RGB | Glut.GLUT_DEPTH);
            Glut.glutInitWindowSize(winW, winH);
            Glut.glutCreateWindow("GLViewer");

            Init();

            //if (argv.Length <= 0) return;

            model = new ThreeDSFile("c:\\bmw.3ds" /*argv[0]*/).ThreeDSModel;

            PrintInstructions();

            Glut.glutDisplayFunc(new Glut.DisplayCallback(Display));
            Glut.glutIdleFunc(new Glut.IdleCallback(Idle));
            Glut.glutKeyboardFunc(new Glut.KeyboardCallback(Keyboard));
            Glut.glutKeyboardUpFunc(new Glut.KeyboardUpCallback(KeyboardUp));
            Glut.glutReshapeFunc(new Glut.ReshapeCallback(Reshape));
            Glut.glutMotionFunc(new Glut.MotionCallback(Motion));
            Glut.glutMainLoop();
        }
Example #18
0
        private static void Init()
        {
            Glut.glutInit();
            Glut.glutInitDisplayMode(Glut.GLUT_DOUBLE | Glut.GLUT_DEPTH);
            Glut.glutInitWindowSize(Width, Height);

            ScreenWidth  = Glut.glutGet(Glut.GLUT_SCREEN_WIDTH);
            ScreenHeight = Glut.glutGet(Glut.GLUT_SCREEN_HEIGHT);

            Glut.glutInitWindowPosition((ScreenWidth - Width) / 2, (ScreenHeight - Height) / 2);
            Glut.glutCreateWindow("Plexico 2D Game - Copyright Alex Tan 2016");
            //Glut.glutGameModeString(Width+"x"+Height+":32@60");

            Glut.glutSetOption(Glut.GLUT_ACTION_ON_WINDOW_CLOSE, Glut.GLUT_ACTION_CONTINUE_EXECUTION);
            Gl.Viewport(0, 0, Width, Height);
            Glut.glutReshapeFunc(OnReshape);
            Glut.glutDisplayFunc(delegate() { });
            Glut.glutIdleFunc(MainGameLoop);

            //Console.SetWindowSize(Console.LargestWindowWidth / 4, Console.LargestWindowHeight / 4);
            //Console.SetWindowPosition(0, 0);
            Mode = ProgramMode.None;

            AssetsManager.Init();
            Input.Init();
            Gui.Init();
            SwitchToTitleScreen();
        }
Example #19
0
        static void Main(string[] args)
        {
            Glut.glutInit();
            Glut.glutInitDisplayMode(Glut.GLUT_DOUBLE | Glut.GLUT_DEPTH);
            Glut.glutInitWindowSize(width, height);
            Glut.glutCreateWindow("OpenGL Tutorial");

            Glut.glutIdleFunc(OnRenderFrame);
            Glut.glutDisplayFunc(OnDisplay);

            Glut.glutKeyboardFunc(OnKeyboardDown);
            Glut.glutKeyboardUpFunc(OnKeyboardUp);

            Glut.glutCloseFunc(OnClose);
            Glut.glutReshapeFunc(OnReshape);

            // enable blending and set to accumulate the star colors
            Gl.Disable(EnableCap.DepthTest);
            Gl.Enable(EnableCap.Blend);
            Gl.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.One);

            // create our shader program
            program = new ShaderProgram(VertexShader, FragmentShader);

            // set up the projection and view matrix
            program.Use();
            program["projection_matrix"].SetValue(Matrix4.CreatePerspectiveFieldOfView(0.45f, (float)width / height, 0.1f, 1000f));
            program["view_matrix"].SetValue(Matrix4.LookAt(new Vector3(0, 0, 20), Vector3.Zero, new Vector3(0, 1, 0)));

            // load the star texture
            starTexture = new Texture("star.bmp");

            // each star is simply a quad
            star      = new VBO <Vector3>(new Vector3[] { new Vector3(-1, -1, 0), new Vector3(1, -1, 0), new Vector3(1, 1, 0), new Vector3(-1, 1, 0) });
            starUV    = new VBO <Vector2>(new Vector2[] { new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1) });
            starQuads = new VBO <int>(new int[] { 0, 1, 2, 0, 2, 3 }, BufferTarget.ElementArrayBuffer);

            // create 50 stars for this tutorial
            int numStars = 50;

            for (int i = 0; i < numStars; i++)
            {
                stars.Add(new Star(0, (float)i / numStars * 4f, new Vector3((float)generator.NextDouble(), (float)generator.NextDouble(), (float)generator.NextDouble())));
            }

            font        = new BMFont("font24.fnt", "font24.png");
            fontProgram = new ShaderProgram(BMFont.FontVertexSource, BMFont.FontFragmentSource);

            fontProgram.Use();
            fontProgram["ortho_matrix"].SetValue(Matrix4.CreateOrthographic(width, height, 0, 1000));
            fontProgram["color"].SetValue(new Vector3(1, 1, 1));

            information = font.CreateString(fontProgram, "OpenGL  C#  Tutorial  10");

            watch = System.Diagnostics.Stopwatch.StartNew();

            Glut.glutMainLoop();
        }
Example #20
0
        static void Main(string[] args)
        {
            Glut.glutInit();
            Glut.glutInitDisplayMode(Glut.GLUT_DOUBLE | Glut.GLUT_DEPTH);
            Glut.glutInitWindowSize(width, height);
            Glut.glutCreateWindow("OpenGL Tutorial");

            Glut.glutIdleFunc(OnRenderFrame);
            Glut.glutDisplayFunc(OnDisplay);

            Glut.glutKeyboardFunc(OnKeyboardDown);
            Glut.glutKeyboardUpFunc(OnKeyboardUp);

            Glut.glutCloseFunc(OnClose);
            Glut.glutReshapeFunc(OnReshape);

            Gl.Enable(EnableCap.DepthTest);

            program = new ShaderProgram(VertexShader, FragmentShader);

            program.Use();
            program["projection_matrix"].SetValue(Matrix4.CreatePerspectiveFieldOfView(0.45f, (float)width / height, 0.1f, 1000f));
            program["view_matrix"].SetValue(Matrix4.LookAt(new Vector3(0, 0, 10), Vector3.Zero, new Vector3(0, 1, 0)));

            program["light_direction"].SetValue(new Vector3(0, 0, 1));
            program["enable_lighting"].SetValue(lighting);

            crateTexture = new Texture("crate.jpg");

            cube = new VBO<Vector3>(new Vector3[] {
                new Vector3(1, 1, -1), new Vector3(-1, 1, -1), new Vector3(-1, 1, 1), new Vector3(1, 1, 1),         // top
                new Vector3(1, -1, 1), new Vector3(-1, -1, 1), new Vector3(-1, -1, -1), new Vector3(1, -1, -1),     // bottom
                new Vector3(1, 1, 1), new Vector3(-1, 1, 1), new Vector3(-1, -1, 1), new Vector3(1, -1, 1),         // front face
                new Vector3(1, -1, -1), new Vector3(-1, -1, -1), new Vector3(-1, 1, -1), new Vector3(1, 1, -1),     // back face
                new Vector3(-1, 1, 1), new Vector3(-1, 1, -1), new Vector3(-1, -1, -1), new Vector3(-1, -1, 1),     // left
                new Vector3(1, 1, -1), new Vector3(1, 1, 1), new Vector3(1, -1, 1), new Vector3(1, -1, -1) });      // right
            cubeNormals = new VBO<Vector3>(new Vector3[] {
                new Vector3(0, 1, 0), new Vector3(0, 1, 0), new Vector3(0, 1, 0), new Vector3(0, 1, 0), 
                new Vector3(0, -1, 0), new Vector3(0, -1, 0), new Vector3(0, -1, 0), new Vector3(0, -1, 0), 
                new Vector3(0, 0, 1), new Vector3(0, 0, 1), new Vector3(0, 0, 1), new Vector3(0, 0, 1), 
                new Vector3(0, 0, -1), new Vector3(0, 0, -1), new Vector3(0, 0, -1), new Vector3(0, 0, -1), 
                new Vector3(-1, 0, 0), new Vector3(-1, 0, 0), new Vector3(-1, 0, 0), new Vector3(-1, 0, 0), 
                new Vector3(1, 0, 0), new Vector3(1, 0, 0), new Vector3(1, 0, 0), new Vector3(1, 0, 0) });
            cubeUV = new VBO<Vector2>(new Vector2[] {
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1) });

            cubeQuads = new VBO<int>(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 }, BufferTarget.ElementArrayBuffer);


            watch = System.Diagnostics.Stopwatch.StartNew();

            Glut.glutMainLoop();
        }
Example #21
0
 static void Main()
 {
     Glut.glutInit();
     Glut.glutInitWindowSize(800, 800);
     Glut.glutCreateWindow("OpenGL Static Shape");
     Glut.glutInitWindowPosition(50, 50);
     Glut.glutDisplayFunc(display);
     Glut.glutMainLoop();
 }
Example #22
0
        static void Main(string[] args)
        {
            Glut.glutInit();
            Glut.glutInitWindowSize(500, 500);
            Glut.glutCreateWindow("Tao Example");

            init_graphics();
            Glut.glutDisplayFunc(on_display);
            Glut.glutMainLoop();
        }
Example #23
0
 static void Main()
 {
     Glut.glutInit();
     Glut.glutInitWindowSize(500, 500);
     Glut.glutCreateWindow("Tao Example");
     init_graphics();
     Glut.glutDisplayFunc(on_display);
     Glut.glutReshapeFunc(on_reshape);
     Glut.glutMainLoop();
 }
Example #24
0
//функция, задающая анимацию
//void Timer()
//{
//    Glut.glutPostRedisplay();
//    Glut.glutTimerFunc(10, Timer, 0);
//}

//вызов функций рисования поля
        public void Opengl()
        {
            //glutTimerFunc(10, Timer, 1);
            init();
            Gl.glRasterPos2i(300, 300);
            Glut.glutMouseFunc(new Glut.MouseCallback(MousePressed));
            Glut.glutDisplayFunc(display);
            Glut.glutMainLoop();
            //return 0; /* ISO C requires main to return int. */
        }
Example #25
0
        public MainClass(string[] args)
        {
            GlControl    ViewPort = new GlControl(Width, Height);
            GlObjectList world    = new GlObjectList();

            world.Add(new LightSource());
#if !testingObjects
            world.Add(new TranslatedObject(new Point3D(0, -10, 0), new SkyBox()));
            GlObjectList casa = new GlObjectList();
            casa.Add(new Casa2());

            casa.Add(new Librero(new Point3D(210, 0, -318), 0));
            casa.Add(new Librero(new Point3D(210, Librero.Height + .3, -316), -3));
            casa.Add(new Lamp(new Point3D(60, 270, 190), 70));
            casa.Add(new Refrigerador(new Point3D(-145, 0, 120), 180));
            Plantilla obj = new Mesita(new Point3D(80, 0, 40), 90);
            casa.Add(obj);
            casa.Add(new TV(new Point3D(80, obj.Height + .2, 60), 0));
            casa.Add(new Cama(new Point3D(370, 0, -250), 0, 100, 70));
            casa.Add(new Cama(new Point3D(370, 0, -480), 0, 100, 60));
            casa.Add(new Cama(new Point3D(-210, 0, -420), 0, 90, 40));
            casa.Add(new Estante(new Point3D(-210, 170, -108)));
            obj = new Mesa(new Point3D(380, 0, 200));
            casa.Add(obj);
            casa.Add(new Silla(new Point3D(440, 0, 160)));
            casa.Add(new Silla(new Point3D(440, 0, 240)));
            casa.Add(new Silla(new Point3D(330, 0, 160), 180));
            casa.Add(new Silla(new Point3D(330, 0, 240), 180));
            casa.Add(new Silla(new Point3D(385, 0, 110), 90));
            casa.Add(new Silla(new Point3D(385, 0, 290), -90));
            casa.Add(new Plato(new Point3D(380, obj.Height + .2, 200)));
            casa.Add(new Vaso(new Point3D(380, obj.Height + .2, 230)));
            casa.Add(new MesitaDeNoche(new Point3D(455, 0, -140), -90));
            casa.Add(new MesitaDeNoche(new Point3D(455, 0, -380), -90));
            casa.Add(new MesitaDeNoche(new Point3D(455, 0, -580), -90));
            casa.Add(new MesitaDeNoche(new Point3D(-280, 0, -340), 90));
            obj = new EstanteHorizontal(new Point3D(330, 0, -70), 180);
            casa.Add(obj);

            casa.Add(new Butaca(new Point3D(-30, 0, 200), 90, 2));
            casa.Add(new Butaca(new Point3D(200, 0, 270), 250, 1));
            casa.Add(new Butaca(new Point3D(200, 0, 110), -70, 1));

            casa.Add(new MesetaConFregadero(new Point3D(-307, 0, -64), 0));

            casa.Add(new Clock(new Point3D(485, 200, 325), 270));
            GlObject c = new TranslatedObject(new Point3D(0, 0, -70), casa);
            world.Add(c);
#endif

            observer = new Avatar(ViewPort, world);
            Glut.glutDisplayFunc(new Glut.DisplayCallback(observer.Look));
            Glut.glutIdleFunc(new Glut.IdleCallback(observer.Look));
            Glut.glutMainLoop();
        }
Example #26
0
        static void Main()
        {
            Glut.glutInit();
            Glut.glutInitDisplayMode(Glut.GLUT_DOUBLE | Glut.GLUT_DEPTH);
            Glut.glutInitWindowSize(width, height);
            Glut.glutCreateWindow("OpenGL Toutorial");

            Glut.glutIdleFunc(OnRenderFrame);
            Glut.glutDisplayFunc(OnDisplay);
            Glut.glutCloseFunc(OnClose);

            Gl.Enable(EnableCap.DepthTest);

            ShaderProgram = new ShaderProgram(VertexShader, FragmentShader);

            ShaderProgram.Use();
            ShaderProgram["projection_matrix"].SetValue(Matrix4.CreatePerspectiveFieldOfView(0.45f, (float)width / height, 0.1f, 1000f));
            ShaderProgram["view_matrix"].SetValue(Matrix4.LookAt(new Vector3(0, 0, 10), Vector3.Zero, Vector3.Up));

            CrateTexture = new Texture("Grass1.jpg");

            cube = new VBO <Vector3>(new Vector3[] {
                new Vector3(1, 1, -1), new Vector3(-1, 1, -1), new Vector3(-1, 1, 1), new Vector3(1, 1, 1),
                new Vector3(1, -1, 1), new Vector3(-1, -1, 1), new Vector3(-1, -1, -1), new Vector3(1, -1, -1),
                new Vector3(1, 1, 1), new Vector3(-1, 1, 1), new Vector3(-1, -1, 1), new Vector3(1, -1, 1),
                new Vector3(1, -1, -1), new Vector3(-1, -1, -1), new Vector3(-1, 1, -1), new Vector3(1, 1, -1),
                new Vector3(-1, 1, 1), new Vector3(-1, 1, -1), new Vector3(-1, -1, -1), new Vector3(-1, -1, 1),
                new Vector3(1, 1, -1), new Vector3(1, 1, 1), new Vector3(1, -1, 1), new Vector3(1, -1, -1)
            });
            int x1 = 500; int y1 = -5; int z1 = 10;
            int x2 = -500; int y2 = -50; int z2 = -1000;

            cube = new VBO <Vector3>(new Vector3[] {
                new Vector3(x1, y1, z2), new Vector3(x2, y1, z2), new Vector3(x2, y1, z1), new Vector3(x1, y1, z1), //top
                new Vector3(x1, y2, z1), new Vector3(x2, y2, z1), new Vector3(x2, y2, z2), new Vector3(x1, y2, z2), //bottom
                new Vector3(x1, y1, z1), new Vector3(x2, y1, z1), new Vector3(x2, y2, z1), new Vector3(x1, y2, z1), //front face
                new Vector3(x1, y2, z2), new Vector3(x2, y2, z2), new Vector3(x2, y1, z2), new Vector3(x1, y1, z2), //back face
                new Vector3(x2, y1, z1), new Vector3(x2, y1, z2), new Vector3(x2, y2, z2), new Vector3(x2, y2, z1), //left face
                new Vector3(x1, y1, z2), new Vector3(x1, y1, z1), new Vector3(x1, y2, z1), new Vector3(x1, y2, z2)
            });                                                                                                     //right face
            cubeUV = new VBO <Vector2>(new Vector2[] {
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1)
            });
            cubeQuads = new VBO <int>(new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 }, BufferTarget.ElementArrayBuffer);

            watch = System.Diagnostics.Stopwatch.StartNew();

            Glut.glutMainLoop();
        }
        static void Main(string[] args)
        {
            // create an OpenGL window
            Glut.glutInit();
            Glut.glutInitDisplayMode(Glut.GLUT_DOUBLE | Glut.GLUT_DEPTH);
            Glut.glutInitWindowSize(width, height);
            Glut.glutCreateWindow("OpenGL Tutorial");

            // provide the Glut callbacks that are necessary for running this tutorial
            Glut.glutIdleFunc(OnRenderFrame);
            Glut.glutDisplayFunc(OnDisplay);
            Glut.glutCloseFunc(OnClose);

            // enable depth testing to ensure correct z-ordering of our fragments
            Gl.Enable(OpenGL.EnableCap.DepthTest);

            // compile the shader program
            program = new ShaderProgram(VertexShader, FragmentShader);

            // set the view and projection matrix, which are static throughout this tutorial
            program.Use();
            program["projection_matrix"].SetValue(Matrix4.CreatePerspectiveFieldOfView(0.45f, (float)width / height, 0.1f, 1000f));
            program["view_matrix"].SetValue(Matrix4.LookAt(new Vector3(0, 0, 10), Vector3.Zero, new Vector3(0, 1, 0)));

            // load a crate texture
            crateTexture = new Texture("res/textures/willem_side.png");

            // create a crate with vertices and UV coordinates

            cube[0] = new VBO <Vector3>(new Vector3[] {
                new Vector3(1, 1, -1), new Vector3(-1, 1, -1), new Vector3(-1, 1, 1), new Vector3(1, 1, 1),
                new Vector3(1, -1, 1), new Vector3(-1, -1, 1), new Vector3(-1, -1, -1), new Vector3(1, -1, -1),
                new Vector3(1, 1, 1), new Vector3(-1, 1, 1), new Vector3(-1, -1, 1), new Vector3(1, -1, 1),
                new Vector3(1, -1, -1), new Vector3(-1, -1, -1), new Vector3(-1, 1, -1), new Vector3(1, 1, -1),
                new Vector3(-1, 1, 1), new Vector3(-1, 1, -1), new Vector3(-1, -1, -1), new Vector3(-1, -1, 1),
                new Vector3(1, 1, -1), new Vector3(1, 1, 1), new Vector3(1, -1, 1), new Vector3(1, -1, -1)
            });
            cubeUV[0] = new VBO <Vector2>(new Vector2[] {
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1),
                new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1)
            });

            //crateTexture = new Texture("res/textures/crate.jpg");

            cubeQuads = new VBO <uint>(new uint[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 }, BufferTarget.ElementArrayBuffer);

            watch = System.Diagnostics.Stopwatch.StartNew();

            Glut.glutMainLoop();
        }
Example #28
0
 public static void Run()
 {
     Glut.glutInit();
     Glut.glutInitDisplayMode(Glut.GLUT_SINGLE | Glut.GLUT_RGB);
     Glut.glutInitWindowSize(250, 250);
     Glut.glutInitWindowPosition(100, 100);
     Glut.glutCreateWindow("Hello");
     Init();
     Glut.glutDisplayFunc(new Glut.DisplayCallback(Display));
     Glut.glutMainLoop();
 }
Example #29
0
 // --- Entry Point ---
 #region Run()
 /// <summary>
 ///     <para>
 ///         Main Loop.  Open window with initial window size, title bar, RGBA display
 ///         mode, and handle input events.
 ///     </para>
 /// </summary>
 public static void Run()
 {
     Glut.glutInit();
     Glut.glutInitDisplayMode(Glut.GLUT_SINGLE | Glut.GLUT_RGB | Glut.GLUT_DEPTH);
     Glut.glutCreateWindow("Anti");
     Init();
     Glut.glutDisplayFunc(new Glut.DisplayCallback(Display));
     Glut.glutKeyboardFunc(new Glut.KeyboardCallback(Keyboard));
     Glut.glutReshapeFunc(new Glut.ReshapeCallback(Reshape));
     Glut.glutMainLoop();
 }
Example #30
0
 public static void Main(string[] args)
 {
     Glut.glutInit();
     Glut.glutInitDisplayMode(Glut.GLUT_SINGLE | Glut.GLUT_INDEX | Glut.GLUT_DEPTH);
     Glut.glutCreateWindow("FogIndexOld");
     Init();
     Glut.glutDisplayFunc(new Glut.DisplayCallback(Display));
     Glut.glutKeyboardFunc(new Glut.KeyboardCallback(Keyboard));
     Glut.glutReshapeFunc(new Glut.ReshapeCallback(Reshape));
     Glut.glutMainLoop();
 }