C# and OpenGL

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Smurfas
    New Member
    • Jul 2008
    • 30

    C# and OpenGL

    Hi, I programin whit C# and OpenGL, but I have one problam. I don't find wha't is wrong. Windows is white, don't do enything.

    What's wrong?

    And maybe some no good OpenGL+C# book for beginner?
    Code:
    using System;
    using System.Collections.Generic;
    using System.Text;
    using Tao.OpenGl;
    
    namespace image
    {
        class Begin
        {
            static void Main(string[] args)
            {
                Glut.glutInit();
                Glut.glutInitDisplayMode(Glut.GLUT_SINGLE | Glut.GLUT_RGB);
    
                Glut.glutInitWindowSize(400, 400);
                Glut.glutInitWindowPosition(400, 300);
                Glut.glutCreateWindow("Image");
    
                Init();
    
                Glut.glutDisplayFunc(new Glut.DisplayCallback(Show));
                                    
                Glut.glutMainLoop();
    
            }
    
            static void Init()
            {            
               Gl.glClearColor(1.0f, 1.0f, 1.0f, 1.0f); 
            }
    
            static void Show()
            {
                Gl.glClear(Gl.GL_COLOR_BUFFER_BIT); //Clear buffer
    
                float[] mas_quad = { -0.5f, -0.5f, -0.5f, 0.5f, 0.5f, 0.5f, 0.5f, -0.5f };
                float[] color_mas = { 0.5f, 0.1f, 0.5f, 0.5f, 0.1f, 0.6f, 0.0f, 0.8f, 0.0f, 0.0f, 0.5f, 4.0f };
                Gl.glVertexPointer(2, Gl.GL_FLOAT, 0, mas_quad);
                Gl.glColorPointer(3, Gl.GL_FLOAT, 0, color_mas);
                Gl.glBegin(Gl.GL_POLYGON);
                for (int i = 0; i < 4; i++)
                    Gl.glArrayElement(i);
                Gl.glEnd();
                Gl.glFlush();
            }
          }
    }
Working...