Exemple #1
0
        /// <summary>
        /// OpenGL init code (cold init).
        /// </summary>
        void InitOpenGL()
        {
            // Log OpenGL info just for curiosity.
            GlInfo.LogGLProperties();

            // General OpenGL.
            glControl1.VSync = true;
            GL.ClearColor(Color.DarkBlue);
            GL.Enable(EnableCap.DepthTest);
            GL.ShadeModel(ShadingModel.Flat);

            // VBO init.
            VBOid = new uint[2];
            GL.GenBuffers(2, VBOid);
            useVBO = (GL.GetError() == ErrorCode.NoError);

            // Shaders.
            if (useVBO)
            {
                canShaders = SetupShaders();
            }

            // Texture.
            texName = GenerateTexture();
        }
Exemple #2
0
        /// <summary>
        /// OpenGL init code (cold init).
        /// </summary>
        void InitOpenGL()
        {
            // log OpenGL info just for curiosity:
            GlInfo.LogGLProperties();

            // general OpenGL:
            glControl1.VSync = true;
            Color c = Color.FromArgb(40, 40, 40);

            GL.ClearColor(c);
            GL.Enable(EnableCap.DepthTest);
            GL.ShadeModel(ShadingModel.Flat);

            // VBO init:
            VBOid = new uint[2];
            GL.GenBuffers(2, VBOid);
            useVBO = (GL.GetError() == ErrorCode.NoError);

            // shaders:
            if (useVBO)
            {
                canShaders = SetupShaders();
            }

            // texture:
            texName = GenerateTexture();
        }
Exemple #3
0
        public void InitOpenGL(GLControl glc)
        {
            // log OpenGL info just for curiosity:
            GlInfo.LogGLProperties();

            // general OpenGL:
            glc.VSync = true;
            GL.ClearColor(Color.FromArgb(14, 20, 40));  // darker "navy blue"
            GL.Enable(EnableCap.DepthTest);
            GL.Enable(EnableCap.VertexProgramPointSize);
            GL.ShadeModel(ShadingModel.Flat);

            // VBO init:
            VBOid = new uint[2];       // one big buffer for vertex data, another buffer for tri/line indices
            GL.GenBuffers(2, VBOid);
            GlInfo.LogError("VBO init");
            VBOlen = new long[2];
        }
Exemple #4
0
        /// <summary>
        /// OpenGL init code.
        /// </summary>
        void InitOpenGL()
        {
            // Log OpenGL info just for curiosity.
            GlInfo.LogGLProperties();

            // General OpenGL.
            glControl1.VSync = true;
            GL.ClearColor(Color.FromArgb(14, 20, 40)); // darker "navy blue"
            GL.Enable(EnableCap.DepthTest);
            GL.Enable(EnableCap.VertexProgramPointSize);
            GL.ShadeModel(ShadingModel.Flat);

            // VBO init:
            VBOid = new uint[2];     // one big buffer for vertex data, another buffer for tri/line indices
            GL.GenBuffers(2, VBOid);
            GlInfo.LogError("VBO init");
            VBOlen = new int[2];     // zeroes..

            // Texture.
            GenerateTexture();
        }
Exemple #5
0
        /// <summary>
        /// OpenGL init code.
        /// </summary>
        void InitOpenGL()
        {
            // log OpenGL info just for curiosity:
            GlInfo.LogGLProperties();

            // OpenGL init code:
            glControl1.VSync = true;
            GL.ClearColor(Color.DarkBlue);
            GL.Enable(EnableCap.DepthTest);

            // VBO init:
            GL.GenBuffers(2, VBOid); // two buffers, one for vertex data, one for index data
            if (GL.GetError() != ErrorCode.NoError)
            {
                throw new Exception("Couldn't create VBOs");
            }

            GL.Light(LightName.Light0, LightParameter.Ambient, ambientColor);
            GL.Light(LightName.Light0, LightParameter.Diffuse, diffuseColor);
            GL.Light(LightName.Light0, LightParameter.Specular, specularColor);
        }
Exemple #6
0
        /// <summary>
        /// OpenGL init code (cold init).
        /// </summary>
        void InitOpenGL()
        {
            // log OpenGL info just for curiosity:
            GlInfo.LogGLProperties();

            // general OpenGL:
            glControl1.VSync = true;
            GL.ClearColor(Color.Black);
            GL.Disable(EnableCap.DepthTest);
            GL.ShadeModel(ShadingModel.Flat);

            // shaders:
            if (programs.Count > 0)
            {
                SetupShaders();
            }

            // texture:
            GL.Enable(EnableCap.Texture2D);
            GL.ActiveTexture(TextureUnit.Texture0);
            GL.TexEnv(TextureEnvTarget.TextureEnv, TextureEnvParameter.TextureEnvMode, (int)TextureEnvMode.Replace);
            ResizeTexture(10, 10);

            // colormap:
            int colors = 256;

            colormap = new byte[colors * 4];
            double x  = 0.04;
            double dx = 0.96 / colors;

            for (int i = 0; i < colors * 4; x += dx)
            {
                Color col = Draw.ColorRamp(x);
                colormap[i++] = col.R;
                colormap[i++] = col.G;
                colormap[i++] = col.B;
                colormap[i++] = 0;
            }
        }
Exemple #7
0
        //====================================================================
        // Rendering - OpenGL
        //====================================================================

        /// <summary>
        /// OpenGL init code (cold init).
        /// </summary>
        public void InitOpenGL(GLControl glc)
        {
            // Log OpenGL info just for curiosity.
            GlInfo.LogGLProperties();

            // General OpenGL.
            glc.VSync = true;
            GL.ClearColor(Color.FromArgb(14, 20, 40)); // darker "navy blue"
            GL.Enable(EnableCap.DepthTest);
            GL.Enable(EnableCap.VertexProgramPointSize);
            GL.ShadeModel(ShadingModel.Flat);

            // VBO init.
            VBOid = new uint[2];      // one big buffer for vertex data, another buffer for tri/line indices
            GL.GenBuffers(2, VBOid);
            if (GlInfo.LogError("VBO init"))
            {
                Application.Exit();
            }

            VBOlen = new long[2];     // current buffer lenghts in bytes

            // Shaders.
            InitShaderRepository();
            if (!SetupShaders())
            {
                Util.Log("Shader setup failed, giving up...");
                Application.Exit();
            }

            // Only shader VertexAttribPointers() or the very old glVertex() stuff.
            GL.DisableClientState(ArrayCap.VertexArray);
            GL.DisableClientState(ArrayCap.TextureCoordArray);
            GL.DisableClientState(ArrayCap.NormalArray);
            GL.DisableClientState(ArrayCap.ColorArray);

            // Texture.
            texName = GenerateTexture();
        }
Exemple #8
0
        /// <summary>
        /// OpenGL init code.
        /// </summary>
        public void InitOpenGL()
        {
            // log OpenGL info just for curiosity:
            GlInfo.LogGLProperties();

            // general OpenGL:
            glC.VSync = true;
            GL.ClearColor(Color.FromArgb(30, 40, 90));
            GL.Enable(EnableCap.DepthTest);
            GL.ShadeModel(ShadingModel.Flat);

            // VBO init:
            VBOid = new uint[2];       // one big buffer for vertex data, another buffer for tri/line indices
            GL.GenBuffers(2, VBOid);
            GlInfo.LogError("VBO init");

            // shaders:
            canShaders = SetupShaders();

            // texture:
            GenerateTexture();
        }