Exemple #1
0
        /// <summary>
        /// OpenGL rendering code itself (separated for clarity).
        /// </summary>
        private void RenderScene()
        {
            // Simulation scene rendering.
            MarblesRenderData rdata = null;

            if (renderer != null &&
                OGL.useShaders)
            {
                lock (renderer)
                    rdata = data;
            }

            if (rdata != null)
            {
                OGL.FormData();

                // Simulated scene.
                primitiveCounter += renderer.Render(OGL, rdata);

                // Light source.
                GL.PointSize(5.0f);
                GL.Begin(PrimitiveType.Points);
                GL.Color3(1.0f, 1.0f, 1.0f);
                GL.Vertex3(OGL.lightPosition);
                GL.End();

                primitiveCounter++;

                primitiveCounter += rdata.Cube.Draw();
            }
            else
            {
                CubeObject cube = new CubeObject(10);
                primitiveCounter += cube.Draw();
            }
        }
Exemple #2
0
        /// <summary>
        /// OpenGL rendering code itself (separated for clarity).
        /// </summary>
        private void RenderScene()
        {
            // Simulation scene rendering.
            MarblesRenderData rdata = null;

            if (renderer != null &&
                OGL.useShaders)
            {
                lock (renderer)
                    rdata = data;
            }

            if (rdata != null)
            {
                OGL.FormData();

                // Simulated scene.
                primitiveCounter += renderer.Render(OGL, rdata);

                // Light source.
                GL.PointSize(5.0f);
                GL.Begin(PrimitiveType.Points);
                GL.Color3(1.0f, 1.0f, 1.0f);
                GL.Vertex3(OGL.lightPosition);
                GL.End();

                primitiveCounter++;
            }
            else
            {
                // color cube:
                GL.Begin(PrimitiveType.Quads);

                GL.Color3(0.0f, 1.0f, 0.0f);      // Set The Color To Green
                GL.Vertex3(1.0f, 1.0f, -1.0f);    // Top Right Of The Quad (Top)
                GL.Vertex3(-1.0f, 1.0f, -1.0f);   // Top Left Of The Quad (Top)
                GL.Vertex3(-1.0f, 1.0f, 1.0f);    // Bottom Left Of The Quad (Top)
                GL.Vertex3(1.0f, 1.0f, 1.0f);     // Bottom Right Of The Quad (Top)

                GL.Color3(1.0f, 0.5f, 0.0f);      // Set The Color To Orange
                GL.Vertex3(1.0f, -1.0f, 1.0f);    // Top Right Of The Quad (Bottom)
                GL.Vertex3(-1.0f, -1.0f, 1.0f);   // Top Left Of The Quad (Bottom)
                GL.Vertex3(-1.0f, -1.0f, -1.0f);  // Bottom Left Of The Quad (Bottom)
                GL.Vertex3(1.0f, -1.0f, -1.0f);   // Bottom Right Of The Quad (Bottom)

                GL.Color3(1.0f, 0.0f, 0.0f);      // Set The Color To Red
                GL.Vertex3(1.0f, 1.0f, 1.0f);     // Top Right Of The Quad (Front)
                GL.Vertex3(-1.0f, 1.0f, 1.0f);    // Top Left Of The Quad (Front)
                GL.Vertex3(-1.0f, -1.0f, 1.0f);   // Bottom Left Of The Quad (Front)
                GL.Vertex3(1.0f, -1.0f, 1.0f);    // Bottom Right Of The Quad (Front)

                GL.Color3(1.0f, 1.0f, 0.0f);      // Set The Color To Yellow
                GL.Vertex3(1.0f, -1.0f, -1.0f);   // Bottom Left Of The Quad (Back)
                GL.Vertex3(-1.0f, -1.0f, -1.0f);  // Bottom Right Of The Quad (Back)
                GL.Vertex3(-1.0f, 1.0f, -1.0f);   // Top Right Of The Quad (Back)
                GL.Vertex3(1.0f, 1.0f, -1.0f);    // Top Left Of The Quad (Back)

                GL.Color3(0.0f, 0.0f, 1.0f);      // Set The Color To Blue
                GL.Vertex3(-1.0f, 1.0f, 1.0f);    // Top Right Of The Quad (Left)
                GL.Vertex3(-1.0f, 1.0f, -1.0f);   // Top Left Of The Quad (Left)
                GL.Vertex3(-1.0f, -1.0f, -1.0f);  // Bottom Left Of The Quad (Left)
                GL.Vertex3(-1.0f, -1.0f, 1.0f);   // Bottom Right Of The Quad (Left)

                GL.Color3(1.0f, 0.0f, 1.0f);      // Set The Color To Violet
                GL.Vertex3(1.0f, 1.0f, -1.0f);    // Top Right Of The Quad (Right)
                GL.Vertex3(1.0f, 1.0f, 1.0f);     // Top Left Of The Quad (Right)
                GL.Vertex3(1.0f, -1.0f, 1.0f);    // Bottom Left Of The Quad (Right)
                GL.Vertex3(1.0f, -1.0f, -1.0f);   // Bottom Right Of The Quad (Right)

                GL.End();

                primitiveCounter += 12;
            }
        }