protected override void DrawData(DrawInfo drawInfo, IDrawableState state)
 {
     vertexes.Bind();
     Gl.glVertexPointer(Vector2D.Count, GlHelper.GlScalar, 0, IntPtr.Zero);
     colors.Bind();
     Gl.glColorPointer(ScalarColor3.Count, GlHelper.GlScalar, 0, IntPtr.Zero);
     Gl.glDrawArrays(mode, 0, vertexes.Length);
 }
 internal void TestBuffer(DrawInfo drawInfo)
 {
     if (refresh != drawInfo.RefreshCount)
     {
         refresh = drawInfo.RefreshCount;
         BufferData(drawInfo.RefreshCount);
     }
 }
 protected override void DrawData(DrawInfo drawInfo, IDrawableState state)
 {
     for (int index = 0; index < buffer.Count; ++index)
     {
         buffer.Bind(index);
         Gl.glVertexPointer(Vector2D.Count, GlHelper.GlScalar, 0, IntPtr.Zero);
         Gl.glDrawArrays(mode, 0, buffer.GetLength(index));
     }
 }
 public void Draw(DrawInfo drawInfo, IDrawableState state)
 {
     if (isDisposed) { throw new ObjectDisposedException(this.ToString()); }
     if (refresh != drawInfo.RefreshCount)
     {
         refresh = drawInfo.RefreshCount;
         BufferData(drawInfo.RefreshCount);
     }
     EnableState();
     DrawData(drawInfo, state);
     DisableState();
 }
 public void Draw(DrawInfo drawInfo, IDrawableState state)
 {
     if (isDisposed) { throw new ObjectDisposedException(this.ToString()); }
     if (refresh != drawInfo.RefreshCount)
     {
         refresh = drawInfo.RefreshCount;
         list = Gl.glGenLists(1);
         if (bufferedDrawable != null)
         {
             bufferedDrawable.TestBuffer(drawInfo);
         }
         Gl.glNewList(list, Gl.GL_COMPILE);
         drawable.Draw(drawInfo, state);
         Gl.glEndList();
     }
     Gl.glCallList(list);
 }
 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();
 }
Beispiel #7
0
 public override void Draw(DrawInfo drawInfo)
 {
     if (collidedStep >= body.Lifetime.LastUpdate - 1)
     {
         base.Draw(drawInfo);
     }
 }
Beispiel #8
0
 void Draw(Scalar dt, Scalar trueDt)
 {
     rwLock.EnterWrite();
     try
     {
         viewports.RemoveExpired();
         lock (syncRoot)
         {
             viewports.AddPending();
         }
         viewports.CheckZOrder();
         drawCount++;
         DrawInfo drawInfo = new DrawInfo(dt, trueDt, drawCount, refreshCount);
         foreach (Viewport viewport in viewports.Items)
         {
             viewport.Draw(drawInfo);
         }
     }
     finally
     {
         rwLock.ExitWrite();
     }
 }
        protected override void DrawData(DrawInfo drawInfo, IDrawableState state)
        {
            texture.Bind();
            vertexes.Bind();
            Gl.glVertexPointer(Vector2D.Count, GlHelper.GlScalar, 0, IntPtr.Zero);

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

           // GlHelper.GlColor4(color.Red, color.Green, color.Blue, color.Alpha);

            Gl.glDrawArrays(Gl.GL_QUADS, 0, vertexes.Length);
        }
 protected abstract void DrawData(DrawInfo drawInfo, IDrawableState state);
Beispiel #11
0
 public DrawEventArgs(DrawInfo drawInfo)
 {
     this.drawInfo = drawInfo;
 }
        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);
        }
Beispiel #13
0
 private void DrawWithoutChildren(DrawInfo drawInfo)
 {
     PreDraw(drawInfo);
     drawable.Draw(drawInfo, drawableState);
     PostDraw(drawInfo);
 }
Beispiel #14
0
 public void Draw(DrawInfo drawInfo)
 {
     if (BeginDrawing != null) { BeginDrawing(this, new DrawEventArgs(drawInfo)); }
     rwLock.EnterWrite();
     try
     {
         graphics.RemoveExpired();
         lock (syncRoot)
         {
             graphics.AddPending();
         }
         graphics.CheckZOrder();
         List<Graphic> graphics1 = graphics.Items;
         for (int index = 0; index < graphics1.Count; ++index)
         {
             Graphic graphic = graphics1[index];
             if (graphic.IsVisible)
             {
                 graphic.Draw(drawInfo);
             }
         }
     }
     finally
     {
         rwLock.ExitWrite();
     }
     if (EndDrawing != null) { EndDrawing(this, new DrawEventArgs(drawInfo)); }
 }
        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);
        }
Beispiel #16
0
 public DrawEventArgs(DrawInfo drawInfo)
 {
     this.drawInfo = drawInfo;
 }
 protected override void DrawData(DrawInfo drawInfo, IDrawableState state)
 {
     vertexes.Bind();
     Gl.glVertexPointer(Vector2D.Count, GlHelper.GlScalar, 0, IntPtr.Zero);
     Gl.glDrawArrays(mode, 0, vertexes.Length);
 }