예제 #1
0
 public void Buffer(int refresh)
 {
     this.refresh = refresh;
     Gl.glGenBuffersARB(1, out bufferName);
     Gl.glBindBufferARB(Gl.GL_ARRAY_BUFFER_ARB, bufferName);
     GlHelper.GlBufferDataARB(
         Gl.GL_ARRAY_BUFFER_ARB,
         array,
         array.Length * elementSize,
         Gl.GL_STATIC_DRAW_ARB);
 }
예제 #2
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         vertexes.Dispose();
         coordinates.Dispose();
         sprite.Dispose();
         bumpmap.Dispose();
     }
     GlHelper.GlDeleteTextures(LastRefresh, new int[] { normalization_cube_map });
 }
예제 #3
0
 public void Buffer(int refresh)
 {
     Gl.glGenBuffersARB(array.Length, bufferNames);
     for (int index = 0; index < array.Length; ++index)
     {
         Gl.glBindBufferARB(Gl.GL_ARRAY_BUFFER_ARB, bufferNames[index]);
         GlHelper.GlBufferDataARB(
             Gl.GL_ARRAY_BUFFER_ARB,
             array[index],
             array[index].Length * elementSize,
             Gl.GL_STATIC_DRAW_ARB);
     }
 }
예제 #4
0
 private void GraphicsProcess(Scalar dt, Scalar trueDt)
 {
     while (Events.Poll())
     {
     }
     if (isResized)
     {
         Init();
         Resize();
         isResized = false;
     }
     GlHelper.DoDelete(refreshCount);
     Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT);
     Draw(dt, trueDt);
     Video.GLSwapBuffers();
 }
예제 #5
0
 public virtual void Draw(DrawInfo drawInfo)
 {
     UpdateTime(drawInfo);
     if (graphicParent == null)
     {
         GlHelper.GlLoadMatrix(matrixArray);
     }
     else
     {
         GlHelper.GlMultMatrix(matrixArray);
     }
     if (hasChildren)
     {
         DrawWithChildren(drawInfo);
     }
     else
     {
         DrawWithoutChildren(drawInfo);
     }
 }
예제 #6
0
 public void Draw(DrawInfo drawInfo)
 {
     if (BeginDrawing != null)
     {
         BeginDrawing(this, new DrawEventArgs(drawInfo));
     }
     Gl.glViewport(rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height);
     Gl.glMatrixMode(Gl.GL_PROJECTION);
     if (!calculated)
     {
         calculated = true;
         Calc();
     }
     GlHelper.GlLoadMatrix(matrixArray);
     Gl.glMatrixMode(Gl.GL_MODELVIEW);
     scene.Draw(drawInfo);
     if (EndDrawing != null)
     {
         EndDrawing(this, new DrawEventArgs(drawInfo));
     }
 }
예제 #7
0
        public void Draw(DrawInfo drawInfo, IDrawableState state)
        {
            RaysSegmentsState st = state as RaysSegmentsState;

            for (int index = 0; index < st.lenghts.Length; ++index)
            {
                RaySegment segment   = shape.Segments[index];
                Ray        ray       = segment.RayInstance;
                Scalar     length    = (st.lenghts[index] == -1) ? (segment.Length) : (st.lenghts[index]);
                int        destIndex = index * 2 + 1;
                array[destIndex].X = ray.Origin.X + ray.Direction.X * length;
                array[destIndex].Y = ray.Origin.Y + ray.Direction.Y * length;
            }
            Gl.glLineWidth(2);
            Gl.glColor3f(1, 1, 1);
            Gl.glBegin(Gl.GL_LINES);
            for (int index = 0; index < array.Length; ++index)
            {
                GlHelper.GlVertex(array[index]);
            }
            Gl.glEnd();
        }
예제 #8
0
 private void Dispose(bool disposing)
 {
     GlHelper.GlDeleteTextures(refresh, new int[] { textureID });
 }
예제 #9
0
 private void Dispose(bool disposing)
 {
     GlHelper.GlDeleteBuffersARB(refresh, new int[] { bufferName });
 }
예제 #10
0
 private void Dispose(bool disposing)
 {
     GlHelper.GlDeleteBuffersARB(refresh, bufferNames);
 }
예제 #11
0
        protected override void DrawData(DrawInfo drawInfo, IDrawableState state)
        {
            // Set The First Texture Unit To Normalize Our Vector From The Surface To The Light.
            // Set The Texture Environment Of The First Texture Unit To Replace It With The
            // Sampled Value Of The Normalization Cube Map.

            Gl.glEnableClientState(Gl.GL_VERTEX_ARRAY);
            vertexes.Bind();
            //Gl.glBindBufferARB(Gl.GL_ARRAY_BUFFER_ARB, vertexName);
            Gl.glVertexPointer(Vector2D.Count, GlHelper.GlScalar, 0, IntPtr.Zero);

            Gl.glActiveTextureARB(Gl.GL_TEXTURE0_ARB);
            Gl.glClientActiveTexture(Gl.GL_TEXTURE0_ARB);
            Gl.glEnable(Gl.GL_TEXTURE_CUBE_MAP);
            Gl.glBindTexture(Gl.GL_TEXTURE_CUBE_MAP, normalization_cube_map);
            Gl.glTexEnvi(Gl.GL_TEXTURE_ENV, Gl.GL_TEXTURE_ENV_MODE, Gl.GL_COMBINE);
            Gl.glTexEnvi(Gl.GL_TEXTURE_ENV, Gl.GL_COMBINE_RGB, Gl.GL_REPLACE);
            Gl.glTexEnvi(Gl.GL_TEXTURE_ENV, Gl.GL_SOURCE0_RGB, Gl.GL_TEXTURE);

            Gl.glEnableClientState(Gl.GL_TEXTURE_COORD_ARRAY);
            vertexes.Bind();
            //Gl.glBindBufferARB(Gl.GL_ARRAY_BUFFER_ARB, vertexName);
            Gl.glTexCoordPointer(Vector2D.Count, GlHelper.GlScalar, 0, IntPtr.Zero);

            //now we change the textures origin to that of the light's position
            GlHelper.GlGetModelViewMatrix(GlMatrix);
            Matrix4x4 matrix;

            Matrix4x4.CopyTranspose(GlMatrix, out matrix);
            Matrix4x4.Invert(ref matrix, out matrix);
            Vector3D lightPos;

            Vector3D.Transform(ref matrix, ref light.Position, out lightPos);
            Gl.glMatrixMode(Gl.GL_TEXTURE);
            Gl.glLoadIdentity();
            GlHelper.GlScale(-1, -1, -1);


            GlHelper.GlTranslate(
                (xInverted) ? (lightPos.X) : (-lightPos.X),
                (yInverted) ? (lightPos.Y) : (-lightPos.Y),
                -lightPos.Z);

            // Set The Second Unit To The Bump Map.
            // Set The Texture Environment Of The Second Texture Unit To Perform A Dot3
            // Operation With The Value Of The Previous Texture Unit (The Normalized
            // Vector Form The Surface To The Light) And The Sampled Texture Value (The
            // Normalized Normal Vector Of Our Bump Map).
            Gl.glActiveTextureARB(Gl.GL_TEXTURE1_ARB);
            Gl.glClientActiveTexture(Gl.GL_TEXTURE1_ARB);
            Gl.glEnable(Gl.GL_TEXTURE_2D);
            bumpmap.Bind();

            Gl.glTexEnvi(Gl.GL_TEXTURE_ENV, Gl.GL_TEXTURE_ENV_MODE, Gl.GL_COMBINE);
            Gl.glTexEnvi(Gl.GL_TEXTURE_ENV, Gl.GL_COMBINE_RGB, Gl.GL_DOT3_RGB);
            Gl.glTexEnvi(Gl.GL_TEXTURE_ENV, Gl.GL_SOURCE0_RGB, Gl.GL_PREVIOUS);
            Gl.glTexEnvi(Gl.GL_TEXTURE_ENV, Gl.GL_SOURCE1_RGB, Gl.GL_TEXTURE);

            Gl.glEnableClientState(Gl.GL_TEXTURE_COORD_ARRAY);
            coordinates.Bind();
            Gl.glTexCoordPointer(Vector2D.Count, GlHelper.GlScalar, 0, IntPtr.Zero);



            // Set The Third Texture Unit To Our Texture.
            // Set The Texture Environment Of The Third Texture Unit To Modulate
            // (Multiply) The Result Of Our Dot3 Operation With The Texture Value.
            Gl.glActiveTextureARB(Gl.GL_TEXTURE2_ARB);
            Gl.glClientActiveTexture(Gl.GL_TEXTURE2_ARB);
            Gl.glEnable(Gl.GL_TEXTURE_2D);
            sprite.Bind();

            Gl.glTexEnvi(Gl.GL_TEXTURE_ENV, Gl.GL_TEXTURE_ENV_MODE, Gl.GL_MODULATE);

            Gl.glEnableClientState(Gl.GL_TEXTURE_COORD_ARRAY);
            coordinates.Bind();
            Gl.glTexCoordPointer(Vector2D.Count, GlHelper.GlScalar, 0, IntPtr.Zero);

            //THEN YOU DRAW IT! MUAHHAAHA IT WORKS! it finally works!
            Gl.glDrawArrays(Gl.GL_QUADS, 0, 4);



            Gl.glDisable(Gl.GL_TEXTURE_2D);
            Gl.glDisableClientState(Gl.GL_TEXTURE_COORD_ARRAY);


            Gl.glActiveTextureARB(Gl.GL_TEXTURE1_ARB);
            Gl.glClientActiveTexture(Gl.GL_TEXTURE1_ARB);
            Gl.glDisable(Gl.GL_TEXTURE_2D);
            Gl.glDisableClientState(Gl.GL_TEXTURE_COORD_ARRAY);

            Gl.glActiveTextureARB(Gl.GL_TEXTURE0_ARB);
            Gl.glClientActiveTexture(Gl.GL_TEXTURE0_ARB);
            Gl.glDisable(Gl.GL_TEXTURE_CUBE_MAP);
            Gl.glDisableClientState(Gl.GL_TEXTURE_COORD_ARRAY);
            Gl.glDisableClientState(Gl.GL_VERTEX_ARRAY);

            Gl.glLoadIdentity();
            Gl.glMatrixMode(Gl.GL_MODELVIEW);
        }
예제 #12
0
 private void Dispose(bool disposing)
 {
     GlHelper.GlDeleteLists(refresh, list, 1);
 }
예제 #13
0
 public void Apply()
 {
     GlHelper.GlColor3(Red, Green, Blue);
 }
예제 #14
0
 public void Apply()
 {
     GlHelper.GlColor4(Red, Green, Blue, Alpha);
 }