Пример #1
0
        private void Sync(bool pollEvents)
        {
            double dt          = 1 / 60.0;
            double currentTime = GLFW.glfwGetTime();

            // Main loop
            while (GLFW.glfwWindowShouldClose(Handle) == 0)
            {
                double newTime   = GLFW.glfwGetTime();
                double frameTime = newTime - currentTime;
                currentTime = newTime;

                while (frameTime > 0)
                {
                    double deltaTime = Math.Min(frameTime, dt);
                    frameTime -= deltaTime;

                    for (var i = 0; i < blocks.Length; i++)
                    {
                        blocks[i].UseDelta = useDelta;
                        blocks[i].Update(deltaTime, width, height);
                    }
                }

                // Render a background and enable some stuff for 2d rendering with alpha
                GL10.glMatrixMode(GL11.GL_PROJECTION);
                GL10.glLoadIdentity();
                GL10.glOrtho(0, width, height, 0, -1, 1);
                GL10.glMatrixMode(GL11.GL_MODELVIEW);
                GL10.glLoadIdentity();

                GL10.glEnable(GL11.GL_BLEND);
                GL10.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
                GL10.glViewport(0, 0, Width, Height);
                GL10.glClearColor(0, 0, 0, 1);
                GL10.glClear(GL11.GL_COLOR_BUFFER_BIT);

                // Render
                for (var i = 0; i < blocks.Length; i++)
                {
                    blocks[i].Render();
                }

                GLFW.glfwSwapBuffers(Handle);
                GLFW.glfwPollEvents();
            }

            GLFW.glfwDestroyWindow(Handle);
        }
Пример #2
0
            public void onDrawFrame(GL10 gl)
            {
                // clear the color buffer and the depth buffer
                gl.glClear(GL10_GL_COLOR_BUFFER_BIT | GL10_GL_DEPTH_BUFFER_BIT);

                gl.glVertexPointer(3, GL10_GL_FLOAT, 0, _vertexBuffer);
                gl.glColorPointer(4, GL10_GL_FLOAT, 0, _colorBuffer);

                for (int i = 1; i <= 10; i++)
                {
                    gl.glLoadIdentity();
                    gl.glTranslatef(0.0f, -1f, -1.0f + -1.5f * i);
                    // set rotation
                    gl.glRotatef(_xAngle, 1f, 0f, 0f);
                    gl.glRotatef(_yAngle, 0f, 1f, 0f);
                    gl.glDrawElements(GL10_GL_TRIANGLES, _nrOfVertices, GL10_GL_UNSIGNED_SHORT, _indexBuffer);
                }
            }
Пример #3
0
            public void onDrawFrame(GL10 gl)
            {
                // define the color we want to be displayed as the "clipping wall"
                gl.glClearColor(0f, 0f, 0f, 1.0f);

                // reset the matrix - good to fix the rotation to a static angle
                gl.glLoadIdentity();

                // clear the color buffer to show the ClearColor we called above...
                gl.glClear(GL10_GL_COLOR_BUFFER_BIT);

                // set rotation
                gl.glRotatef(_xAngle, 1f, 0f, 0f);
                gl.glRotatef(_yAngle, 0f, 1f, 0f);

                //gl.glColor4f(0.5f, 0f, 0f, 0.5f);
                gl.glVertexPointer(3, GL10_GL_FLOAT, 0, _vertexBuffer);
                gl.glColorPointer(4, GL10_GL_FLOAT, 0, _colorBuffer);
                gl.glDrawElements(GL10_GL_TRIANGLES, _nrOfVertices, GL10_GL_UNSIGNED_SHORT, _indexBuffer);
            }
            public void onDrawFrame(GL10 gl)
            {
                // clear the color buffer and the depth buffer
                gl.glClear(GL10_GL_COLOR_BUFFER_BIT | GL10_GL_DEPTH_BUFFER_BIT);

                gl.glVertexPointer(3, GL10_GL_FLOAT, 0, _vertexBuffer);
                gl.glColorPointer(4, GL10_GL_FLOAT, 0, _colorBuffer);

                for (int i = 1; i <= 10; i++)
                {
                    gl.glLoadIdentity();
                    gl.glTranslatef(0.0f, -1f, -1.0f + -1.5f * i);
                    // set rotation
                    gl.glRotatef(_xAngle, 1f, 0f, 0f);
                    gl.glRotatef(_yAngle, 0f, 1f, 0f);
                    gl.glDrawElements(GL10_GL_TRIANGLES, _nrOfVertices, GL10_GL_UNSIGNED_SHORT, _indexBuffer);
                }
            }
            public void onDrawFrame(GL10 gl)
            {
                // define the color we want to be displayed as the "clipping wall"
                gl.glClearColor(_red, _green, _blue, 1.0f);

                // reset the matrix - good to fix the rotation to a static angle
                gl.glLoadIdentity();

                // clear the color buffer to show the ClearColor we called above...
                gl.glClear(GL10_GL_COLOR_BUFFER_BIT);

                // set rotation for the non-static triangle
                gl.glRotatef(_angle, 0f, 1f, 0f);

                gl.glColor4f(0.5f, 0f, 0f, 0.5f);
                gl.glVertexPointer(3, GL10_GL_FLOAT, 0, _vertexBuffer);
                gl.glDrawElements(GL10_GL_TRIANGLES, _nrOfVertices, GL10_GL_UNSIGNED_SHORT, _indexBuffer);

                // gl.glColor4f(0.5f, 0f, 0f, 0.5f);
                gl.glVertexPointer(3, GL10_GL_FLOAT, 0, _vertexBuffer);
                gl.glColorPointer(4, GL10_GL_FLOAT, 0, _colorBuffer);
                gl.glDrawElements(GL10_GL_TRIANGLES, _nrOfVertices, GL10_GL_UNSIGNED_SHORT, _indexBuffer);
            }