예제 #1
0
        // --- Basecode Methods ---
        #region Initialize()
        /// <summary>
        /// Overrides OpenGL's initialization.
        /// </summary>
        public override void Initialize()
        {
            LoadTextures();                                                                                                     // Jump To The Texture Loading Routine

            glEnable(GL_TEXTURE_2D);                                                                                            // Enable Texture Mapping
            glShadeModel(GL_SMOOTH);                                                                                            // Enable Smooth Shading
            glClearColor(0.0f, 0.0f, 0.0f, 0.5f);                                                                               // Black Background
            glClearDepth(1.0f);                                                                                                 // Depth Buffer Setup
            glDisable(GL_DEPTH_TEST);                                                                                           // Disables Depth Testing
            glDepthFunc(GL_LEQUAL);                                                                                             // The Type Of Depth Testing To Do
            glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);                                                                  // Really Nice Perspective Calculations

            glColor4f(1.0f, 1.0f, 1.0f, 0.5f);                                                                                  // Full Brightness.  50% Alpha
            glBlendFunc(GL_ONE, GL_ONE);                                                                                        // Set The Blending Function For Translucency

            fireworkArray = new Firework[MAX_FIREWORKS];

            Vector3D origin = new Vector3D(40 * (((rand.Next() % 1000) / 1000f) - 0.5f), 30 * (((rand.Next() % 1000) / 1000f) - 0.5f) + 20, -50 * ((rand.Next() % 1000) / 1000f) - 20);

            fireworkArray[0] = new Firework(MAX_PARTICLES, origin, 0.0f, -30, texture[0]);
            fireworkArray[0].Reset();

            for (int i = 0; i < MAX_FIREWORKS; i++)
            {
                fireworkArray[i] = new Firework();
            }
        }
예제 #2
0
        /// <summary>
        /// Draws Schaap Fireworks scene.
        /// </summary>
        public override void Draw()                                                                                                             // Here's Where We Do All The Drawing
        {
            glMatrixMode(GL_MODELVIEW);                                                                                                         // Select The Modelview Matrix
            glLoadIdentity();                                                                                                                   // Reset The Current Modelview Matrix

            glBindTexture(GL_TEXTURE_2D, texture[0]);

            glBlendFunc(GL_ONE, GL_ONE);                                                                                                        // Set The Blending Function For Translucency
            glColor4f(1.0f, 1.0f, 1.0f, 5.0f);                                                                                                  // Full Brightness, 50% Alpha
            glEnable(GL_BLEND);

            for (int i = 0; i < MAX_FIREWORKS; i++)
            {
                fireworkArray[i].Render();                                                                                                              // Render Particles
                fireworkArray[i].Update(2);                                                                                                             // Update Particles For Next Cycle

                if (fireworkArray[i].Done && ((rand.Next() % 1000) / 1000f) > 0.99f)
                {
                    Vector3D origin = new Vector3D(40 * (((rand.Next() % 1000) / 1000f) - 0.5f), 30 * (((rand.Next() % 1000) / 1000f) - 0.5f) + 20, -50 * ((rand.Next() % 1000) / 1000f) - 20);
                    fireworkArray[i] = new Firework(MAX_PARTICLES, origin, 0.0f, -30, texture[0]);
                    fireworkArray[i].Reset();                                                                                                           // Resets (Initializes) Particle Engine
                }
            }

            // Update Rotation
            rotXAngle += 0.8f;
            rotYAngle += 0.95f;
            rotZAngle += 0.4f;

            glDisable(GL_TEXTURE_2D);
            glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

            glColor4f(0, 0, 0, 0.05f);
            const int BOUNDS = 10;

            glBegin(GL_TRIANGLE_STRIP);
            glVertex3f(-BOUNDS, BOUNDS, -10);
            glVertex3f(-BOUNDS, -BOUNDS, -10);
            glVertex3f(BOUNDS, BOUNDS, -10);
            glVertex3f(BOUNDS, -BOUNDS, -10);
            glEnd();

            glEnable(GL_TEXTURE_2D);
            glBlendFunc(GL_ONE, GL_ONE);
        }