glViewport() private méthode

private glViewport ( int x, int y, int width, int height ) : void
x int
y int
width int
height int
Résultat void
        protected virtual void initRenderingGL()
        {
            if (m_DeviceContext == 0 || m_RenderingContext == 0)
            {
                return;
            }
            if (m_DisplayPanel.Width == 0 || m_DisplayPanel.Height == 0)
            {
                return;
            }

            GL.glShadeModel(GL.GL_SMOOTH);
            GL.glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
            GL.glClearDepth(1.0f);


            GL.glClearColor(0.5f, 0.5f, 0.5f, 0.0f);
            GL.glEnable(GL.GL_DEPTH_TEST);
            GL.glDepthFunc(GL.GL_LEQUAL);
            GL.glHint(GL.GL_PERSPECTIVE_CORRECTION_Hint, GL.GL_NICEST);

            GL.glViewport(0, 0, m_DisplayPanel.Width, m_DisplayPanel.Height);
            GL.glMatrixMode(GL.GL_PROJECTION);
            GL.glLoadIdentity();

            //nice 3D
            GLU.gluPerspective(70.0, 1.0, 0.4, 500.0);

            GL.glMatrixMode(GL.GL_MODELVIEW);
            GL.glLoadIdentity();
            TextureUtills.GenerateTextures();
            //save the current MODELVIEW Matrix (now it is Identity)
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, AccumulatedRotationsTraslations);
        }
Exemple #2
0
 public void OnResize()
 {
     m_Width  = m_Control.Width;
     m_Height = m_Control.Height;
     GL.glViewport(0, 0, m_Width, m_Height);
     Draw();
 }
Exemple #3
0
        protected virtual void initRenderingGL()
        {
            if (m_uint_DC == 0 || m_uint_RC == 0)
            {
                return;
            }
            if (this.Width == 0 || this.Height == 0)
            {
                return;
            }
            GL.glClearColor(0.5f, 0.5f, 0.5f, 0.0f);
            GL.glEnable(GL.GL_DEPTH_TEST);
            GL.glDepthFunc(GL.GL_LEQUAL);

            GL.glViewport(0, 0, this.Width, this.Height);
            GL.glMatrixMode(GL.GL_PROJECTION);
            GL.glLoadIdentity();

            //nice 3D
            GLU.gluPerspective(45.0, 1.0, 0.4, 100.0);


            GL.glMatrixMode(GL.GL_MODELVIEW);
            GL.glLoadIdentity();

            //save the current MODELVIEW Matrix (now it is Identity)
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, AccumulatedRotationsTraslations);
        }
Exemple #4
0
 public void OnResize()
 {
     Width  = p.Width;
     Height = p.Height;
     GL.glViewport(0, 0, Width, Height);
     Draw();
 }
Exemple #5
0
        protected virtual void initRenderingGL()
        {
            if (m_uint_DC == 0 || m_uint_RC == 0)
            {
                return;
            }
            if (this.m_Width == 0 || this.m_Height == 0)
            {
                return;
            }
            GL.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
            GL.glEnable(GL.GL_DEPTH_TEST);
            GL.glDepthFunc(GL.GL_LEQUAL);

            GL.glViewport(0, 0, this.m_Width, this.m_Height);
            GL.glClearColor(0, 0, 0, 0);
            GL.glMatrixMode(GL.GL_PROJECTION);
            GL.glLoadIdentity();

            //1
            GLU.gluPerspective(45.0, ((double)m_Width) / m_Height, 1.0, 1000.0);
            //GLU.gluOrtho2D(0, Width, 0, Height);
            //the same
            //GLU.gluOrtho(0, iWidth, 0, iHeight, -1, 1);

            GL.glMatrixMode(GL.GL_MODELVIEW);
            GL.glLoadIdentity();

            InitTexture(Resources.dreidel);
        }
Exemple #6
0
        protected virtual void initRenderingGL()
        {
            if (m_uint_DC == 0 || m_uint_RC == 0)
            {
                return;
            }
            if (this.Width == 0 || this.Height == 0)
            {
                return;
            }
            GL.glClearColor(0.5f, 0.9f, 1.0f, 1.0f);
            GL.glEnable(GL.GL_DEPTH_TEST);
            GL.glDepthFunc(GL.GL_LEQUAL);


            //GL.glHint(GL.GL_PERSPECTIVE_CORRECTION_Hint, GL.GL_NICEST);

            GL.glViewport(0, 0, this.Width, this.Height);
            GL.glMatrixMode(GL.GL_PROJECTION);
            GL.glLoadIdentity();


            GL.glShadeModel(GL.GL_SMOOTH);

            GLU.gluPerspective(60, (float)Width / (float)Height, 0.45f, 1000.0f);

            GenerateTextures(1);//////////////////////////////////////

            GL.glMatrixMode(GL.GL_MODELVIEW);
            GL.glLoadIdentity();
        }
Exemple #7
0
        protected virtual void initRenderingGL()
        {
            if (m_uint_DC == 0 || m_uint_RC == 0)
            {
                return;
            }
            if (this.Width == 0 || this.Height == 0)
            {
                return;
            }
            GL.glEnable(GL.GL_DEPTH_TEST);
            GL.glDepthFunc(GL.GL_LEQUAL);

            GL.glViewport(0, 0, Width, Height);
            GL.glClearColor(0, 0, 0, 0);
            GL.glMatrixMode(GL.GL_PROJECTION);
            GL.glLoadIdentity();
            double d = (Width) / Height;

            GLU.gluPerspective(100.0, (Width) / Height, 1.0, 1000.0);
            GL.glMatrixMode(GL.GL_MODELVIEW);
            GL.glLoadIdentity();

            InitTexture();
        }
Exemple #8
0
        protected virtual void initRenderingGL()
        {
            if (m_uint_DC == 0 || m_uint_RC == 0)
            {
                return;
            }

            GL.glShadeModel(GL.GL_SMOOTH);
            GL.glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
            GL.glClearDepth(1.0f);

            GL.glEnable(GL.GL_LIGHT0);
            GL.glEnable(GL.GL_COLOR_MATERIAL);
            GL.glColorMaterial(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT_AND_DIFFUSE);

            GL.glEnable(GL.GL_DEPTH_TEST);
            GL.glDepthFunc(GL.GL_LEQUAL);
            GL.glHint(GL.GL_PERSPECTIVE_CORRECTION_Hint, GL.GL_NICEST);

            GL.glViewport(0, 0, Width, Height);
            GL.glClearColor(0, 0, 0, 0);
            GL.glMatrixMode(GL.GL_PROJECTION);
            GL.glLoadIdentity();
            GLU.gluPerspective(45.0, 1.0, 1.0, 1000.0);
            GL.glMatrixMode(GL.GL_MODELVIEW);
            GL.glLoadIdentity();
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, AccumulatedTraslations);

            InitTexture("SurgeryRoom.bmp");
        }
Exemple #9
0
        public void initRenderingGL()
        {
            if (m_uint_DC == 0 || m_uint_RC == 0)
            {
                return;
            }
            if (this.Width == 0 || this.Height == 0)
            {
                return;
            }

            GL.glShadeModel(GL.GL_SMOOTH);
            GL.glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
            GL.glClearDepth(1.0f);

            GL.glEnable(GL.GL_LIGHT0);
            GL.glEnable(GL.GL_COLOR_MATERIAL);
            GL.glColorMaterial(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT_AND_DIFFUSE); // GL.GL_AMBIENT_AND_DIFFUSE / GL.GL_SHININESS


            //GL.glEnable(GL.GL_DEPTH_TEST);
            GL.glDepthFunc(GL.GL_LEQUAL);

            GL.glViewport(0, 0, this.Width, this.Height);
            GL.glMatrixMode(GL.GL_PROJECTION);
            GL.glLoadIdentity();

            GLU.gluPerspective(45, ((double)Width) / Height, 1.0, 1000.0);
            GL.glMatrixMode(GL.GL_MODELVIEW);
            //save the current MODELVIEW Matrix (now it is Identity)
            //GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, AccumulatedRotationsTraslations);

            InitTexture("IMG\\1.bmp");
        }
Exemple #10
0
        public void OnResize()
        {
            Width  = p.Width;
            Height = p.Height;

            //!!!!!!!
            GL.glViewport(0, 0, Width, Height);
            //!!!!!!!

            initRenderingGL();
            Draw();
        }
Exemple #11
0
        protected virtual void initRenderingGL()
        {
            if (m_uint_DC == 0 || m_uint_RC == 0)
            {
                return;
            }
            if (this.Width == 0 || this.Height == 0)
            {
                return;
            }
            GL.glShadeModel(GL.GL_SMOOTH);
            GL.glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
            GL.glClearDepth(1.0f);


            GL.glEnable(GL.GL_LIGHT0);
            GL.glEnable(GL.GL_COLOR_MATERIAL);
            GL.glColorMaterial(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT_AND_DIFFUSE);

            GL.glEnable(GL.GL_DEPTH_TEST);
            GL.glDepthFunc(GL.GL_LEQUAL);
            GL.glHint(GL.GL_PERSPECTIVE_CORRECTION_Hint, GL.GL_NICEST);

            GL.glViewport(0, 0, this.Width, this.Height);
            GL.glMatrixMode(GL.GL_PROJECTION);
            GL.glLoadIdentity();

            //nice 3D
            GLU.gluPerspective(45.0, 1.0, 0.4, 100.0);

            //! TEXTURE 1a
            GL.glEnable(GL.GL_COLOR_MATERIAL);
            float[] emis = { 0.3f, 0.3f, 0.3f, 1 };
            GL.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_EMISSION, emis);
            //! TEXTURE 1a



            GL.glShadeModel(GL.GL_SMOOTH);
            GLU.gluPerspective(viewAngle, (float)Width / (float)Height, 0.45f, 30.0f);

            GL.glMatrixMode(GL.GL_MODELVIEW);
            GL.glLoadIdentity();

            //! TEXTURE 1a
            GenerateTextures();
            //! TEXTURE 1b
            //save the current MODELVIEW Matrix (now it is Identity)
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, AccumulatedRotationsTraslations);
        }
Exemple #12
0
        /// <summary>
        /// Event handler called when the control is resized.
        /// </summary>
        protected virtual void ResizeGL(object sender, EventArgs e)
        {
            if (m_uint_DC == 0 || m_uint_RC == 0)
            {
                return;
            }
            if (this.Width == 0 || this.Height == 0)
            {
                return;
            }
            WGL.wglMakeCurrent(m_uint_DC, m_uint_RC);
            GL.glViewport(0, 0, this.Width, this.Height);

            GL.glMatrixMode(GL.GL_PROJECTION);
            GL.glLoadIdentity();
            GLU.gluPerspective(60.0, ((double)(this.Width) / (double)(this.Height)), 1.0, 1000.0);
            GL.glMatrixMode(GL.GL_MODELVIEW);
            GL.glLoadIdentity();
        }
Exemple #13
0
        public void initRenderingGL()
        {
            if (m_uint_DC == 0 || m_uint_RC == 0)
            {
                return;
            }
            if (this.Width == 0 || this.Height == 0)
            {
                return;
            }
            GL.glClearColor(1.0f, 1.0f, 1.0f, 0.0f);
            GL.glEnable(GL.GL_DEPTH_TEST);
            GL.glDepthFunc(GL.GL_LEQUAL);

            GL.glViewport(0, 0, this.Width, this.Height);

            GL.glMatrixMode(GL.GL_PROJECTION);
            GL.glLoadIdentity();

            //Z-BUFFER SHOW begin
            if (!bPerspective)
            {
                GL.glOrtho(-4, 4, -4, 4, -4, 4);
            }
            else
            {
                // - no Grey nuances: differences of our objects Z
                //        are relatively 0 to 100.0f ... 0.45f
                GLU.gluPerspective(45.0f, Width / Height, 0.45f, 500.0f);
            }
            GL.glMatrixMode(GL.GL_MODELVIEW);

            GL.glLoadIdentity();

            //save the current MODELVIEW Matrix (now it is Identity)
            GL.glGetDoublev(GL.GL_MODELVIEW_MATRIX, AccumulatedRotationsTraslations);

            Zbuf = new float[Width * Height];


            GenerateTextures();
        }
Exemple #14
0
        protected virtual void initRenderingGL()
        {
            if (m_uint_DC == 0 || m_uint_RC == 0)
            {
                return;
            }
            if (this.Width == 0 || this.Height == 0)
            {
                return;
            }
            GL.glShadeModel(GL.GL_SMOOTH);
            GL.glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
            GL.glClearDepth(1.0f);

            if (GlobalProperties.LightBeamOn)
            {
                GL.glEnable(GL.GL_LIGHT0);
            }
            GL.glEnable(GL.GL_COLOR_MATERIAL);
            GL.glColorMaterial(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT_AND_DIFFUSE);

            GL.glEnable(GL.GL_DEPTH_TEST);
            GL.glDepthFunc(GL.GL_LEQUAL);

            GL.glViewport(0, 0, this.Width, this.Height);
            GL.glClearColor(0, 0, 0, 0);
            GL.glMatrixMode(GL.GL_PROJECTION);
            GL.glLoadIdentity();

            GLU.gluPerspective(90.0, ((double)Width) / Height, 1.0, 1000.0);
            GL.glMatrixMode(GL.GL_MODELVIEW);
            GL.glLoadIdentity();


            GenerateTextures();
        }
// ############################################################################
// ############################################################################
// ############################################################################
// ############################################################################


// ============================================================================
// The following is an example of OpenGL rendering code, complete with
// buffer swapping.  This function can be called by a Form's "OnPaint()"
// method if a previous WGL.DemoInitOpenGL() call (for example) has
// already successfully established a valid Render Context (RC).
// ============================================================================

        public static void DemoOpenGLDraw
        (
            int int_WindowWidth,
            int int_WindowHeight,
            uint uint_DC
        )
        {
            int   int_Phase   = (int)(System.Environment.TickCount % 120000);
            float float_Phase = (float)(0.3f * (int_Phase));

            if (int_WindowWidth <= 0)
            {
                int_WindowWidth = 1;
            }
            if (int_WindowHeight <= 0)
            {
                int_WindowHeight = 1;
            }

            GL.glViewport(0, 0, int_WindowWidth, int_WindowHeight);

            GL.glEnable(GL.GL_DEPTH_TEST);
            GL.glDepthFunc(GL.GL_LEQUAL);
            GL.glEnable(GL.GL_CULL_FACE);
            GL.glCullFace(GL.GL_BACK);
            GL.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
            GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
            GL.glMatrixMode(GL.GL_PROJECTION);
            GL.glLoadIdentity();

            //GL.glOrtho( 0.0f, (float)(int_WindowWidth), 0.0f, (float)(int_WindowHeight), -1.0f, 1.0f );
            GLU.gluPerspective
            (
                60.0,  // Field of view angle (Y angle; degrees)
                ((double)(int_WindowWidth) / (double)(int_WindowHeight)),
                1.0,   // Near plane
                1000.0 // Far  plane
            );

            GL.glMatrixMode(GL.GL_MODELVIEW);
            GL.glLoadIdentity();

            // Translating the camera to +600.0f Z is essentially
            // adding -600.0f to all drawing commands.
            GL.glTranslatef(0.0f, 0.0f, -600.0f);

            GL.glRotatef((0.11f * float_Phase), 1.0f, 0.0f, 0.0f);
            GL.glRotatef((0.31f * float_Phase), 0.0f, 1.0f, 0.0f);
            GL.glRotatef((0.19f * float_Phase), 0.0f, 0.0f, 1.0f);

            float[][] vert_xyz = new float[8][]
            {
                new float[] { -100.0f, -100.0f, -100.0f }, // 0
                new float[] { -100.0f, -100.0f, 100.0f },  // 1
                new float[] { -100.0f, 100.0f, -100.0f },  // 2
                new float[] { -100.0f, 100.0f, 100.0f },   // 3
                new float[] { 100.0f, -100.0f, -100.0f },  // 4
                new float[] { 100.0f, -100.0f, 100.0f },   // 5
                new float[] { 100.0f, 100.0f, -100.0f },   // 6
                new float[] { 100.0f, 100.0f, 100.0f } // 7
            };
            int [][] tri_abc = new int [12][]
            {
                new int[] { 0, 2, 4 }, new int[] { 4, 2, 6 }, // Back
                new int[] { 0, 4, 1 }, new int[] { 1, 4, 5 }, // Bottom
                new int[] { 0, 1, 2 }, new int[] { 2, 1, 3 }, // Left
                new int[] { 4, 6, 5 }, new int[] { 5, 6, 7 }, // Right
                new int[] { 2, 3, 6 }, new int[] { 6, 3, 7 }, // Top
                new int[] { 1, 5, 3 }, new int[] { 3, 5, 7 } // Front
            };
            float[][] colors_rgb = new float[12][]
            {
                new float[] { 0.5f, 0.1f, 0.1f }, new float[] { 1.0f, 0.1f, 0.1f }, // Red
                new float[] { 0.5f, 0.5f, 0.1f }, new float[] { 1.0f, 1.0f, 0.1f }, // Yellow
                new float[] { 0.1f, 0.5f, 0.1f }, new float[] { 0.1f, 1.0f, 0.1f }, // Green
                new float[] { 0.1f, 0.5f, 0.5f }, new float[] { 0.1f, 1.0f, 1.0f }, // Cyan
                new float[] { 0.1f, 0.1f, 0.5f }, new float[] { 0.1f, 0.1f, 1.0f }, // Blue
                new float[] { 0.5f, 0.1f, 0.5f }, new float[] { 1.0f, 0.1f, 1.0f } // Magenta
            };

            int iTriTotal = 12;
            int iTriIndex = 0;

            GL.glBegin(GL.GL_TRIANGLES);
            for (iTriIndex = 0; iTriIndex < iTriTotal; iTriIndex++)
            {
                GL.glColor3fv(colors_rgb[iTriIndex]);
                GL.glVertex3fv(vert_xyz[tri_abc[iTriIndex][0]]);

                GL.glColor3fv(colors_rgb[iTriIndex]);
                GL.glVertex3fv(vert_xyz[tri_abc[iTriIndex][1]]);

                GL.glColor3fv(colors_rgb[iTriIndex]);
                GL.glVertex3fv(vert_xyz[tri_abc[iTriIndex][2]]);
            }
            GL.glEnd();

            WGL.wglSwapBuffers(uint_DC);
        }
Exemple #16
0
        /**********************************************************************************************************
        *
        *
        *
        * MAIN DRAW FUNCTION
        *
        *
        *
        **********************************************************************************************************/
        public void Draw()
        {
            if (m_uint_DC == 0 || m_uint_RC == 0)
            {
                return;
            }

            GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT | GL.GL_STENCIL_BUFFER_BIT);

            GL.glViewport(0, 0, Width, Height);
            GL.glLoadIdentity();

            GLU.gluLookAt(ScrollValue[0], ScrollValue[1], ScrollValue[2],
                          ScrollValue[3], ScrollValue[4], ScrollValue[5],
                          ScrollValue[6], ScrollValue[7], ScrollValue[8]);

            GL.glRotatef(xAngle, 1.0f, 0.0f, 0.0f);
            GL.glRotatef(yAngle, 0.0f, 1.0f, 0.0f);
            GL.glRotatef(zAngle, 0.0f, 0.0f, 1.0f);
            GL.glTranslatef(xShift, yShift, zShift);

            pos[0] = light_position[0] = ScrollValue[9];
            pos[1] = light_position[1] = ScrollValue[10];
            pos[2] = light_position[2] = ScrollValue[11];
            pos[3] = light_position[3] = 0;

            GL.glLightfv(GL.GL_LIGHT0, GL.GL_AMBIENT, light_ambient);
            GL.glLightfv(GL.GL_LIGHT0, GL.GL_DIFFUSE, light_diffuse);
            GL.glLightfv(GL.GL_LIGHT0, GL.GL_SPECULAR, light_specular);
            GL.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, light_position);

            GL.glLightModelfv(GL.GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);
            GL.glEnable(GL.GL_LIGHT0);

            /*
             *
             * Reflection
             *
             */
            GL.glEnable(GL.GL_BLEND);
            GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
            if (reflectionOn)
            {
                //draw only to STENCIL buffer
                GL.glEnable(GL.GL_STENCIL_TEST);
                GL.glStencilOp(GL.GL_REPLACE, GL.GL_REPLACE, GL.GL_REPLACE);
                GL.glStencilFunc(GL.GL_ALWAYS, 1, 0xFFFFFFFF);
                GL.glColorMask((byte)GL.GL_FALSE, (byte)GL.GL_FALSE, (byte)GL.GL_FALSE, (byte)GL.GL_FALSE);
                GL.glDisable(GL.GL_DEPTH_TEST);

                drawLake();

                // restore regular settings
                GL.glColorMask((byte)GL.GL_TRUE, (byte)GL.GL_TRUE, (byte)GL.GL_TRUE, (byte)GL.GL_TRUE);
                GL.glEnable(GL.GL_DEPTH_TEST);

                // reflection is drawn only where STENCIL buffer value equal to 1
                GL.glStencilFunc(GL.GL_EQUAL, 1, 0xFFFFFFFF);
                GL.glStencilOp(GL.GL_KEEP, GL.GL_KEEP, GL.GL_KEEP);

                /*
                 *
                 * draw reflected scene
                 *
                 */

                GL.glEnable(GL.GL_LIGHTING);
                for (currentTree = 0; currentTree < numOfTrees; currentTree++)
                {
                    GL.glPushMatrix();
                    //GL.glTranslated(randX[currentTree], 0,randZ[currentTree]);
                    GL.glTranslated(locationX[currentTree], 0, locationZ[currentTree]);
                    GL.glRotated(locationRotateY[currentTree], 0, 1, 0);
                    GL.glScalef(1, -1, 1); //swap on Z axis

                    if (scullFaceOn)
                    {
                        GL.glEnable(GL.GL_CULL_FACE);
                        GL.glCullFace(GL.GL_BACK);
                        GL.glCallList(TREE_LIST + currentTree);
                        GL.glCullFace(GL.GL_FRONT);
                        GL.glCallList(TREE_LIST + currentTree);
                        GL.glDisable(GL.GL_CULL_FACE);
                    }
                    else
                    {
                        GL.glCallList(TREE_LIST + currentTree);
                    }

                    GL.glPopMatrix();
                }

                drawLake();

                GL.glStencilFunc(GL.GL_NOTEQUAL, 1, 0xFFFFFFFF);
                GL.glStencilOp(GL.GL_KEEP, GL.GL_KEEP, GL.GL_KEEP);

                // really draw floor
                //( half-transparent ( see its color's alpha byte)))
                // in order to see reflected objects
                //GL.glDepthMask((byte)GL.GL_FALSE);
                GL.glDepthMask((byte)GL.GL_TRUE);
                if (!textureOn)
                {
                    drawFloor();
                }
                else
                {
                    drawFloorTextured();
                    DrawTexturedCube();
                }

                GL.glDisable(GL.GL_LIGHTING);
                GL.glDisable(GL.GL_STENCIL_TEST);
            }
            else
            {
                GL.glEnable(GL.GL_LIGHTING);
                drawLake();
                if (!textureOn)
                {
                    drawFloor();
                }
                else
                {
                    drawFloorTextured();
                    DrawTexturedCube();
                }
                GL.glDisable(GL.GL_LIGHTING);
            }

            DrawLight();

            /*
             * Draw trees
             */

            GL.glEnable(GL.GL_LIGHTING);
            GL.glPushMatrix();
            for (currentTree = 0; currentTree < numOfTrees; currentTree++)
            {
                GL.glPushMatrix();
                //GL.glTranslated(randX[currentTree], 0, randZ[currentTree]);
                GL.glTranslated(locationX[currentTree], 0, locationZ[currentTree]);
                GL.glRotated(locationRotateY[currentTree], 0, 1, 0);
                GL.glCallList(TREE_LIST + currentTree);
                GL.glPopMatrix();
            }
            GL.glPopMatrix();

            /*
             * Draw trees shadows
             */
            GL.glDisable(GL.GL_LIGHTING);
            GL.glColor3d(0, 0, 0);
            if (shadowOn)
            {
                GL.glPushMatrix();
                MakeShadowMatrix(ground);
                GL.glMultMatrixf(cubeXform);
                for (currentTree = 0; currentTree < numOfTrees; currentTree++)
                {
                    GL.glPushMatrix();
                    //GL.glTranslated(randX[currentTree], 0, randZ[currentTree]);
                    GL.glTranslated(locationX[currentTree], 0, locationZ[currentTree]);
                    GL.glRotated(locationRotateY[currentTree], 0, 1, 0);
                    GL.glCallList(TREE_LIST + currentTree);
                    GL.glPopMatrix();
                }
                GL.glPopMatrix();
            }

            GL.glFlush();
            WGL.wglSwapBuffers(m_uint_DC);
        }
 public void OnResize()
 {
     GL.glViewport(0, 0, m_DisplayPanel.Width, m_DisplayPanel.Height);
     Draw();
 }
        public void Draw()
        {
            if (m_uint_DC == 0 || m_uint_RC == 0)
            {
                return;
            }

            GL.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT | GL.GL_STENCIL_BUFFER_BIT);

            //TRIVIAL
            GL.glViewport(0, 0, Width, Height);
            GL.glLoadIdentity();
            GL.glEnable(GL.GL_NORMALIZE);

            GLU.gluLookAt(ScrollValue[0], ScrollValue[1], ScrollValue[2],
                          ScrollValue[3], ScrollValue[4], ScrollValue[5],
                          ScrollValue[6], ScrollValue[7], ScrollValue[8]);



            pos[0] = light_position[0] = ScrollValue[9];
            pos[1] = light_position[1] = ScrollValue[10];
            pos[2] = light_position[2] = ScrollValue[11];
            pos[3] = light_position[3] = 0;

            light_position_reflected[0] = -ScrollValue[9];
            light_position_reflected[1] = -ScrollValue[10];
            light_position_reflected[2] = -ScrollValue[11];
            light_position[3]           = 0;

            GL.glLightfv(GL.GL_LIGHT0, GL.GL_POSITION, light_position);
            GL.glEnable(GL.GL_LIGHT0);

            GL.glLightfv(GL.GL_LIGHT1, GL.GL_POSITION, light_position);
            GL.glEnable(GL.GL_LIGHT1);

            //beascender look angle
            GL.glTranslatef(0.0f, -50.0f, -340.0f); //how far from the lake
            GL.glTranslatef(0.0f, 1.0f, 0.0f);      //height from the lake
            GL.glRotatef(25, 1.0f, 0, 0);           //look at lake angle

            GL.glRotatef(xAngle, 1.0f, 0.0f, 0.0f);
            if (checkBox)
            {
                GL.glRotatef((float)spirala * 0.018f, 0.0f, 1.0f, 0.0f);
                GL.glRotatef((float)speed * 0.008f, 1.0f, 1.0f, 0.0f);
                GL.glRotatef((float)speed * 0.008f, 0.0f, 1.0f, 1.0f);
                GL.glRotatef((float)speed * -0.005f, 1.0f, 0.0f, 1.0f);
            }
            GL.glRotatef(yAngle, 0.0f, 1.0f, 0.0f);
            GL.glRotatef(zAngle, 0.0f, 0.0f, 1.0f);
            if (checkBox)
            {
                GL.glTranslatef(xShift, yShift + (float)-speed * 0.18f, zShift);
            }
            GL.glTranslatef(xShift, yShift, zShift);



            /*
             *
             * Reflection drawing area start here
             *
             */

            GL.glPushMatrix();

            GL.glEnable(GL.GL_BLEND);
            GL.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);

            //draw only to STENCIL buffer
            GL.glEnable(GL.GL_STENCIL_TEST);
            GL.glStencilOp(GL.GL_REPLACE, GL.GL_REPLACE, GL.GL_REPLACE);
            GL.glStencilFunc(GL.GL_ALWAYS, 1, 0xFFFFFFFF);
            GL.glColorMask((byte)GL.GL_FALSE, (byte)GL.GL_FALSE, (byte)GL.GL_FALSE, (byte)GL.GL_FALSE);
            GL.glDisable(GL.GL_DEPTH_TEST);

            Drawlake();//Draw area when we want to see reflect

            // restore regular seascendings
            GL.glColorMask((byte)GL.GL_TRUE, (byte)GL.GL_TRUE, (byte)GL.GL_TRUE, (byte)GL.GL_TRUE);
            GL.glEnable(GL.GL_DEPTH_TEST);

            // reflection is drawn only where STENCIL buffer value equal to 1
            GL.glStencilFunc(GL.GL_EQUAL, 1, 0xFFFFFFFF);
            GL.glStencilOp(GL.GL_KEEP, GL.GL_KEEP, GL.GL_KEEP);


            /*
             * draw reflected scene
             */

            GL.glScalef(1, -1, 1); //swap axes down


            GL.glPushMatrix();
            DrawTexturedCube();

            //reflected penguin
            drawPenguin();

            draw_sun();
            draw_moon();
            GL.glPopMatrix();


            GL.glPopMatrix();
            GL.glEnable(GL.GL_LIGHTING);

            Drawlake();

            GL.glDisable(GL.GL_LIGHTING);


            GL.glStencilFunc(GL.GL_NOTEQUAL, 1, 0xFFFFFFFF);
            GL.glStencilOp(GL.GL_KEEP, GL.GL_KEEP, GL.GL_KEEP);

            GL.glDepthMask((byte)GL.GL_FALSE);
            GL.glDepthMask((byte)GL.GL_TRUE);

            drawFloorTextured();

            draw_sun();
            draw_moon();


            GL.glDisable(GL.GL_STENCIL_TEST);

            DrawTexturedCube();    //SKY BOX



            /*
             *
             * paint main scene area - start here
             *
             */

            // drawaxe();



            GL.glShadeModel(GL.GL_FLAT);

            GL.glEnable(GL.GL_LIGHTING);

            //Main Penguin
            drawPenguin();



            /////////

            GL.glDisable(GL.GL_LIGHTING);



            /*
             *
             * Draw shadows area - start here
             *
             */
            GL.glDisable(GL.GL_LIGHTING);


            GL.glPushMatrix();

            MakeShadowMatrix(ground);  //sending fround matrix
            GL.glMultMatrixf(cubeXform);

            GL.glShadeModel(GL.GL_FLAT);
            GL.glColor3d(0, 0, 0);//black

            drawPenguinShade();

            GL.glPopMatrix();



            GL.glFlush();
            WGL.wglSwapBuffers(m_uint_DC);
        }