Package fcagnin.jglsdk.glutil

Examples of fcagnin.jglsdk.glutil.MatrixStack


        glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

        {
            final Vec3 camPos = resolveCamPosition();

            MatrixStack camMatrix = new MatrixStack();
            camMatrix.setMatrix( calcLookAtMatrix( camPos, camTarget, new Vec3( 0.0f, 1.0f, 0.0f ) ) );

            glUseProgram( uniformColor.theProgram );
            glUniformMatrix4( uniformColor.worldToCameraMatrixUnif, false,
                    camMatrix.top().fillAndFlipBuffer( mat4Buffer ) );
            glUseProgram( objectColor.theProgram );
            glUniformMatrix4( objectColor.worldToCameraMatrixUnif, false,
                    camMatrix.top().fillAndFlipBuffer( mat4Buffer ) );
            glUseProgram( uniformColorTint.theProgram );
            glUniformMatrix4( uniformColorTint.worldToCameraMatrixUnif, false,
                    camMatrix.top().fillAndFlipBuffer( mat4Buffer ) );
            glUseProgram( 0 );

            MatrixStack modelMatrix = new MatrixStack();

            // Render the ground plane.
            {
                modelMatrix.push();
                modelMatrix.scale( 100.0f, 1.0f, 100.0f );

                glUseProgram( uniformColor.theProgram );
                glUniformMatrix4( uniformColor.modelToWorldMatrixUnif, false,
                        modelMatrix.top().fillAndFlipBuffer( mat4Buffer ) );
                glUniform4f( uniformColor.baseColorUnif, 0.302f, 0.416f, 0.0589f, 1.0f );
                planeMesh.render();
                glUseProgram( 0 );

                modelMatrix.pop();
            }

            // Draw the trees.
            drawForest( modelMatrix );

            // Draw the building.
            {
                modelMatrix.push();
                modelMatrix.translate( 20.0f, 0.0f, -10.0f );

                drawParthenon( modelMatrix );

                modelMatrix.pop();
            }

            if ( drawLookatPoint ) {
                glDisable( GL_DEPTH_TEST );

                modelMatrix.push();
                Vec3 cameraAimVec = Vec3.sub( camTarget, camPos );
                modelMatrix.translate( 0.0f, 0.0f, -Glm.length( cameraAimVec ) );
                modelMatrix.scale( 1.0f, 1.0f, 1.0f );

                Mat4 identity = new Mat4( 1.0f );

                glUseProgram( objectColor.theProgram );
                glUniformMatrix4( objectColor.modelToWorldMatrixUnif, false,
                        modelMatrix.top().fillAndFlipBuffer( mat4Buffer ) );
                glUniformMatrix4( objectColor.worldToCameraMatrixUnif, false,
                        identity.fillAndFlipBuffer( mat4Buffer ) );
                cubeColorMesh.render();
                glUseProgram( 0 );

                modelMatrix.pop();

                glEnable( GL_DEPTH_TEST );
            }
        }
    }
View Full Code Here


        }
    }

    @Override
    protected void reshape(int w, int h) {
        MatrixStack persMatrix = new MatrixStack();
        persMatrix.perspective( 45.0f, (w / (float) h), zNear, zFar );

        ProjectionBlock projData = new ProjectionBlock();
        projData.cameraToClipMatrix = persMatrix.top();

        glBindBuffer( GL_UNIFORM_BUFFER, projectionUniformBuffer );
        glBufferSubData( GL_UNIFORM_BUFFER, 0, projData.fillAndFlipBuffer( mat4Buffer ) );
        glBindBuffer( GL_UNIFORM_BUFFER, 0 );
View Full Code Here

        glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
        glClearDepth( 1.0f );
        glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

        MatrixStack modelMatrix = new MatrixStack();
        modelMatrix.setMatrix( viewPole.calcMatrix() );

        final Vec4 worldLightPos = calcLightPosition();

        Vec4 lightPosCameraSpace = Mat4.mul( modelMatrix.top(), worldLightPos );

        ProgramData whiteProgram;
        ProgramData vertColorProgram;

        if ( useFragmentLighting ) {
            whiteProgram = fragWhiteDiffuseColor;
            vertColorProgram = fragVertexDiffuseColor;
        } else {
            whiteProgram = whiteDiffuseColor;
            vertColorProgram = vertexDiffuseColor;
        }

        glUseProgram( whiteProgram.theProgram );
        glUniform4f( whiteProgram.lightIntensityUnif, 0.8f, 0.8f, 0.8f, 1.0f );
        glUniform4f( whiteProgram.ambientIntensityUnif, 0.2f, 0.2f, 0.2f, 1.0f );
        glUseProgram( vertColorProgram.theProgram );
        glUniform4f( vertColorProgram.lightIntensityUnif, 0.8f, 0.8f, 0.8f, 1.0f );
        glUniform4f( vertColorProgram.ambientIntensityUnif, 0.2f, 0.2f, 0.2f, 1.0f );
        glUseProgram( 0 );

        {
            modelMatrix.push();

            // Render the ground plane.
            {
                modelMatrix.push();

                glUseProgram( whiteProgram.theProgram );
                glUniformMatrix4( whiteProgram.modelToCameraMatrixUnif, false,
                        modelMatrix.top().fillAndFlipBuffer( mat4Buffer ) );

                Mat4 invTransform = Glm.inverse( modelMatrix.top() );
                Vec4 lightPosModelSpace = Mat4.mul( invTransform, lightPosCameraSpace );
                glUniform3( whiteProgram.modelSpaceLightPosUnif, lightPosModelSpace.fillAndFlipBuffer( vec4Buffer ) );

                planeMesh.render();
                glUseProgram( 0 );

                modelMatrix.pop();
            }

            // Render the Cylinder
            {
                modelMatrix.push();

                modelMatrix.applyMatrix( objtPole.calcMatrix() );

                if ( scaleCyl ) {
                    modelMatrix.scale( 1.0f, 1.0f, 0.2f );
                }

                Mat4 invTransform = Glm.inverse( modelMatrix.top() );
                Vec4 lightPosModelSpace = Mat4.mul( invTransform, lightPosCameraSpace );

                if ( drawColoredCyl ) {
                    glUseProgram( vertColorProgram.theProgram );
                    glUniformMatrix4( vertColorProgram.modelToCameraMatrixUnif, false,
                            modelMatrix.top().fillAndFlipBuffer( mat4Buffer ) );

                    glUniform3( vertColorProgram.modelSpaceLightPosUnif,
                            lightPosModelSpace.fillAndFlipBuffer( vec4Buffer ) );

                    cylinderMesh.render( "lit-color" );
                } else {
                    glUseProgram( whiteProgram.theProgram );
                    glUniformMatrix4( whiteProgram.modelToCameraMatrixUnif, false,
                            modelMatrix.top().fillAndFlipBuffer( mat4Buffer ) );

                    glUniform3( whiteProgram.modelSpaceLightPosUnif,
                            lightPosModelSpace.fillAndFlipBuffer( vec4Buffer ) );

                    cylinderMesh.render( "lit" );
                }
                glUseProgram( 0 );

                modelMatrix.pop();
            }

            // Render the light
            if ( drawLight ) {
                modelMatrix.push();

                modelMatrix.translate( worldLightPos.x, worldLightPos.y, worldLightPos.z );
                modelMatrix.scale( 0.1f, 0.1f, 0.1f );

                glUseProgram( unlit.theProgram );
                glUniformMatrix4( unlit.modelToCameraMatrixUnif, false,
                        modelMatrix.top().fillAndFlipBuffer( mat4Buffer ) );
                glUniform4f( unlit.objectColorUnif, 0.8078f, 0.8706f, 0.9922f, 1.0f );
                cubeMesh.render( "flat" );

                modelMatrix.pop();
            }

            modelMatrix.pop();
        }
    }
View Full Code Here

        }
    }

    @Override
    protected void reshape(int w, int h) {
        MatrixStack persMatrix = new MatrixStack();
        persMatrix.perspective( 45.0f, (w / (float) h), zNear, zFar );

        glUseProgram( uniformColor.theProgram );
        glUniformMatrix4( uniformColor.cameraToClipMatrixUnif, false,
                persMatrix.top().fillAndFlipBuffer( mat4Buffer ) );
        glUseProgram( objectColor.theProgram );
        glUniformMatrix4( objectColor.cameraToClipMatrixUnif, false,
                persMatrix.top().fillAndFlipBuffer( mat4Buffer ) );
        glUseProgram( uniformColorTint.theProgram );
        glUniformMatrix4( uniformColorTint.cameraToClipMatrixUnif, false,
                persMatrix.top().fillAndFlipBuffer( mat4Buffer ) );
        glUseProgram( 0 );

        glViewport( 0, 0, w, h );
    }
View Full Code Here

        }
    }

    @Override
    protected void reshape(int w, int h) {
        MatrixStack persMatrix = new MatrixStack();
        persMatrix.perspective( 45.0f, (w / (float) h), zNear, zFar );

        ProjectionBlock projData = new ProjectionBlock();
        projData.cameraToClipMatrix = persMatrix.top();

        glBindBuffer( GL_UNIFORM_BUFFER, projectionUniformBuffer );
        glBufferSubData( GL_UNIFORM_BUFFER, 0, projData.fillAndFlipBuffer( mat4Buffer ) );
        glBindBuffer( GL_UNIFORM_BUFFER, 0 );
View Full Code Here

    protected void display() {
        glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
        glClearDepth( 1.0f );
        glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

        MatrixStack currMatrix = new MatrixStack();
        currMatrix.translate( 0.0f, 0.0f, -200.0f );
        currMatrix.rotateX( gimbalAngles.angleX );
        drawGimbal( currMatrix, GimbalAxis.X_AXIS, new Vec4( 0.4f, 0.4f, 1.0f, 1.0f ) );
        currMatrix.rotateY( gimbalAngles.angleY );
        drawGimbal( currMatrix, GimbalAxis.Y_AXIS, new Vec4( 0.0f, 1.0f, 0.0f, 1.0f ) );
        currMatrix.rotateZ( gimbalAngles.angleZ );
        drawGimbal( currMatrix, GimbalAxis.Z_AXIS, new Vec4( 1.0f, 0.3f, 0.3f, 1.0f ) );

        glUseProgram( theProgram );

        currMatrix.scale( 3.0f, 3.0f, 3.0f );
        currMatrix.rotateX( -90.0f );

        // Set the base color for this object.
        glUniform4f( baseColorUnif, 1.0f, 1.0f, 1.0f, 1.0f );
        glUniformMatrix4( modelToCameraMatrixUnif, false, currMatrix.top().fillAndFlipBuffer( mat4Buffer ) );

        object.render( "tint" );

        glUseProgram( 0 );
    }
View Full Code Here

        glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

        final Mat4 cameraMatrix = viewPole.calcMatrix();
        final Mat4 lightView = lightViewPole.calcMatrix();

        MatrixStack modelMatrix = new MatrixStack();
        modelMatrix.applyMatrix( cameraMatrix );

        buildLights( cameraMatrix );

        nodes.get( 0 ).nodeSetOrient( Glm.rotate( new Quaternion( 1.0f ), 360.0f * timer.getAlpha(),
                new Vec3( 0.0f, 1.0f, 0.0f ) ) );

        nodes.get( 3 ).nodeSetOrient( Quaternion.mul( spinBarOrient, Glm.rotate( new Quaternion( 1.0f ),
                360.0f * timer.getAlpha(), new Vec3( 0.0f, 0.0f, 1.0f ) ) ) );

        {
            MatrixStack persMatrix = new MatrixStack();
            persMatrix.perspective( 60.0f, displayWidth / (float) displayHeight, zNear, zFar );

            ProjectionBlock projData = new ProjectionBlock();
            projData.cameraToClipMatrix = persMatrix.top();

            glBindBuffer( GL_UNIFORM_BUFFER, projectionUniformBuffer );
            glBufferData( GL_UNIFORM_BUFFER, projData.fillAndFlipBuffer( mat4Buffer ), GL_STREAM_DRAW );
            glBindBuffer( GL_UNIFORM_BUFFER, 0 );
        }

        glActiveTexture( GL_TEXTURE0 + lightProjTexUnit );
        glBindTexture( GL_TEXTURE_2D, lightTextures[currTextureIndex] );
        glBindSampler( lightProjTexUnit, samplers[currSampler] );

        {
            MatrixStack lightProjStack = new MatrixStack();
            // Texture-space transform
            lightProjStack.translate( 0.5f, 0.5f, 0.0f );
            lightProjStack.scale( 0.5f, 0.5f, 1.0f );

            // Project. Z-range is irrelevant.
            lightProjStack.perspective( lightFOVs[currFOVIndex], 1.0f, 1.0f, 100.0f );

            // Transform from main camera space to light camera space.
            lightProjStack.applyMatrix( lightView );
            lightProjStack.applyMatrix( Glm.inverse( cameraMatrix ) );

            lightProjMatBinder.setValue( lightProjStack.top() );

            Vec4 worldLightPos = Glm.inverse( lightView ).getColumn( 3 );
            Vec3 lightPos = new Vec3( Mat4.mul( cameraMatrix, worldLightPos ) );

            camLightPosBinder.setValue( lightPos );
View Full Code Here

        glClearColor( 0.75f, 0.75f, 1.0f, 1.0f );
        glClearDepth( 1.0f );
        glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

        MatrixStack modelMatrix = new MatrixStack();
        modelMatrix.setMatrix( viewPole.calcMatrix() );
        final Mat4 worldToCamMat = modelMatrix.top();

        LightBlock lightData = new LightBlock();
        lightData.ambientIntensity = new Vec4( 0.2f, 0.2f, 0.2f, 1.0f );
        float lightAttenuation = 1.0f / (halfLightDistance * halfLightDistance);
        lightData.lightAttenuation = lightAttenuation;

        lightData.lights[0] = new PerLight();
        lightData.lights[0].cameraSpaceLightPos = Mat4.mul( worldToCamMat, new Vec4( 0.707f, 0.707f, 0.0f, 0.0f ) );
        lightData.lights[0].lightIntensity = new Vec4( 0.6f, 0.6f, 0.6f, 1.0f );

        lightData.lights[1] = new PerLight();
        lightData.lights[1].cameraSpaceLightPos = Mat4.mul( worldToCamMat, calcLightPosition() );
        lightData.lights[1].lightIntensity = new Vec4( 0.4f, 0.4f, 0.4f, 1.0f );

        glBindBuffer( GL_UNIFORM_BUFFER, lightUniformBuffer );
        glBufferSubData( GL_UNIFORM_BUFFER, 0, lightData.fillAndFlipBuffer( lightBlockBuffer ) );
        glBindBuffer( GL_UNIFORM_BUFFER, 0 );

        {
            glBindBufferRange( GL_UNIFORM_BUFFER, materialBlockIndex, materialTerrainUniformBuffer, 0,
                    MaterialEntry.SIZE );

            Mat3 normMatrix = new Mat3( modelMatrix.top() );
            normMatrix = Glm.transpose( Glm.inverse( normMatrix ) );

            glUseProgram( litMeshProg.theProgram );
            glUniformMatrix4( litMeshProg.modelToCameraMatrixUnif, false,
                    modelMatrix.top().fillAndFlipBuffer( mat4Buffer ) );
            glUniformMatrix3( litMeshProg.normalModelToCameraMatrixUnif, false,
                    normMatrix.fillAndFlipBuffer( mat3Buffer ) );

            planeMesh.render();

            glUseProgram( 0 );
            glBindBufferBase( GL_UNIFORM_BUFFER, materialBlockIndex, 0 );
        }

        {
            VertexData[] posSizeArray = new VertexData[NUMBER_OF_SPHERES];

            posSizeArray[0] = new VertexData();
            posSizeArray[0].cameraPosition = new Vec3( Mat4.mul( worldToCamMat, new Vec4( 0.0f, 10.0f, 0.0f, 1.0f ) ) );
            posSizeArray[0].sphereRadius = 4.0f;

            posSizeArray[1] = new VertexData();
            posSizeArray[1].cameraPosition = getSphereOrbitPos( modelMatrix, new Vec3( 0.0f, 10.0f, 0.0f ),
                    new Vec3( 0.6f, 0.8f, 0.0f ), 20.0f, sphereTimer.getAlpha() );
            posSizeArray[1].sphereRadius = 2.0f;

            posSizeArray[2] = new VertexData();
            posSizeArray[2].cameraPosition = getSphereOrbitPos( modelMatrix, new Vec3( -10.0f, 1.0f, 0.0f ),
                    new Vec3( 0.0f, 1.0f, 0.0f ), 10.0f, sphereTimer.getAlpha() );
            posSizeArray[2].sphereRadius = 1.0f;

            posSizeArray[3] = new VertexData();
            posSizeArray[3].cameraPosition = getSphereOrbitPos( modelMatrix, new Vec3( 10.0f, 1.0f, 0.0f ),
                    new Vec3( 0.0f, 1.0f, 0.0f ), 10.0f, sphereTimer.getAlpha() * 2.0f );
            posSizeArray[3].sphereRadius = 1.0f;

            glBindBuffer( GL_ARRAY_BUFFER, imposterVBO );

            {
                FloatBuffer vertexDataBuffer = BufferUtils.createFloatBuffer( NUMBER_OF_SPHERES * VertexData.SIZE /
                        FLOAT_SIZE );

                for ( VertexData vertexData : posSizeArray ) {
                    vertexData.fillBuffer( vertexDataBuffer );
                }

                vertexDataBuffer.flip();

                glBufferData( GL_ARRAY_BUFFER, vertexDataBuffer, GL_STREAM_DRAW );
            }

            glBindBuffer( GL_ARRAY_BUFFER, 0 );
        }

        {
            glBindBufferRange( GL_UNIFORM_BUFFER, materialBlockIndex, materialArrayUniformBuffer, 0,
                    MaterialEntry.SIZE * NUMBER_OF_SPHERES );

            glUseProgram( litImpProg.theProgram );
            glBindVertexArray( imposterVAO );
            glDrawArrays( GL_POINTS, 0, NUMBER_OF_SPHERES );
            glBindVertexArray( 0 );
            glUseProgram( 0 );

            glBindBufferBase( GL_UNIFORM_BUFFER, materialBlockIndex, 0 );
        }

        if ( drawLights ) {
            modelMatrix.push();

            modelMatrix.translate( new Vec3( calcLightPosition() ) );
            modelMatrix.scale( 0.5f );

            glUseProgram( unlit.theProgram );
            glUniformMatrix4( unlit.modelToCameraMatrixUnif, false, modelMatrix.top().fillAndFlipBuffer( mat4Buffer ) );

            Vec4 lightColor = new Vec4( 1.0f );
            glUniform4( unlit.objectColorUnif, lightColor.fillAndFlipBuffer( vec4Buffer ) );
            cubeMesh.render( "flat" );

            modelMatrix.pop();
        }

        if ( drawCameraPos ) {
            modelMatrix.push();

            modelMatrix.setIdentity();
            modelMatrix.translate( new Vec3( 0.0f, 0.0f, -viewPole.getView().radius ) );

            glDisable( GL_DEPTH_TEST );
            glDepthMask( false );
            glUseProgram( unlit.theProgram );
            glUniformMatrix4( unlit.modelToCameraMatrixUnif, false, modelMatrix.top().fillAndFlipBuffer( mat4Buffer ) );
            glUniform4f( unlit.objectColorUnif, 0.25f, 0.25f, 0.25f, 1.0f );
            cubeMesh.render( "flat" );
            glDepthMask( true );
            glEnable( GL_DEPTH_TEST );
            glUniform4f( unlit.objectColorUnif, 1.0f, 1.0f, 1.0f, 1.0f );
            cubeMesh.render( "flat" );

            modelMatrix.pop();
        }
    }
View Full Code Here

        }
    }

    @Override
    protected void reshape(int w, int h) {
        MatrixStack persMatrix = new MatrixStack();
        persMatrix.perspective( 45.0f, (w / (float) h), zNear, zFar );

        ProjectionBlock projData = new ProjectionBlock();
        projData.cameraToClipMatrix = persMatrix.top();

        glBindBuffer( GL_UNIFORM_BUFFER, projectionUniformBuffer );
        glBufferSubData( GL_UNIFORM_BUFFER, 0, projData.fillAndFlipBuffer( mat4Buffer ) );
        glBindBuffer( GL_UNIFORM_BUFFER, 0 );
View Full Code Here

        glClearColor( 0.75f, 0.75f, 1.0f, 1.0f );
        glClearDepth( 1.0f );
        glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

        MatrixStack modelMatrix = new MatrixStack();
        modelMatrix.setMatrix( viewPole.calcMatrix() );
        final Mat4 worldToCamMat = modelMatrix.top();

        LightBlock lightData = new LightBlock();
        lightData.ambientIntensity = new Vec4( 0.2f, 0.2f, 0.2f, 1.0f );
        float halfLightDistance = 25.0f;
        float lightAttenuation = 1.0f / (halfLightDistance * halfLightDistance);
        lightData.lightAttenuation = lightAttenuation;

        Vec3 globalLightDirection = new Vec3( 0.707f, 0.707f, 0.0f );

        lightData.lights[0] = new PerLight();
        lightData.lights[0].cameraSpaceLightPos = Mat4.mul( worldToCamMat, new Vec4( globalLightDirection, 0.0f ) );
        lightData.lights[0].lightIntensity = new Vec4( 0.6f, 0.6f, 0.6f, 1.0f );

        lightData.lights[1] = new PerLight();
        lightData.lights[1].cameraSpaceLightPos = Mat4.mul( worldToCamMat, calcLightPosition() );
        lightData.lights[1].lightIntensity = new Vec4( 0.4f, 0.4f, 0.4f, 1.0f );

        glBindBuffer( GL_UNIFORM_BUFFER, lightUniformBuffer );
        glBufferSubData( GL_UNIFORM_BUFFER, 0, lightData.fillAndFlipBuffer( lightBlockBuffer ) );
        glBindBuffer( GL_UNIFORM_BUFFER, 0 );

        {
            glBindBufferRange( GL_UNIFORM_BUFFER, materialBlockIndex, materialUniformBuffer, 0, MaterialBlock.SIZE );

            modelMatrix.push();

            modelMatrix.applyMatrix( objtPole.calcMatrix() );
            modelMatrix.scale( 2.0f );

            Mat3 normMatrix = new Mat3( modelMatrix.top() );
            normMatrix = Glm.transpose( Glm.inverse( normMatrix ) );

            ProgramData prog = useTexture ? litTextureProg : litShaderProg;

            glUseProgram( prog.theProgram );
            glUniformMatrix4( prog.modelToCameraMatrixUnif, false, modelMatrix.top().fillAndFlipBuffer( mat4Buffer ) );
            glUniformMatrix3( prog.normalModelToCameraMatrixUnif, false, normMatrix.fillAndFlipBuffer( mat3Buffer ) );

            glActiveTexture( GL_TEXTURE0 + gaussTexUnit );
            glBindTexture( GL_TEXTURE_1D, gaussTextures[currTexture] );
            glBindSampler( gaussTexUnit, gaussSampler );

            objectMesh.render( "lit" );

            glBindSampler( gaussTexUnit, 0 );
            glBindTexture( GL_TEXTURE_1D, 0 );

            glUseProgram( 0 );
            glBindBufferBase( GL_UNIFORM_BUFFER, materialBlockIndex, 0 );

            modelMatrix.pop();
        }

        if ( drawLights ) {
            modelMatrix.push();

            modelMatrix.translate( new Vec3( calcLightPosition() ) );
            modelMatrix.scale( 0.25f );

            glUseProgram( unlit.theProgram );
            glUniformMatrix4( unlit.modelToCameraMatrixUnif, false, modelMatrix.top().fillAndFlipBuffer( mat4Buffer ) );

            Vec4 lightColor = new Vec4( 1.0f );
            glUniform4( unlit.objectColorUnif, lightColor.fillAndFlipBuffer( vec4Buffer ) );
            cubeMesh.render( "flat" );

            modelMatrix.pop();

            modelMatrix.translate( globalLightDirection.scale( 100.0f ) );
            modelMatrix.scale( 5.0f );

            glUniformMatrix4( unlit.modelToCameraMatrixUnif, false, modelMatrix.top().fillAndFlipBuffer( mat4Buffer ) );
            cubeMesh.render( "flat" );

            glUseProgram( 0 );
        }

        if ( drawCameraPos ) {
            modelMatrix.push();

            modelMatrix.setIdentity();
            modelMatrix.translate( new Vec3( 0.0f, 0.0f, -viewPole.getView().radius ) );
            modelMatrix.scale( 0.25f );

            glDisable( GL_DEPTH_TEST );
            glDepthMask( false );
            glUseProgram( unlit.theProgram );
            glUniformMatrix4( unlit.modelToCameraMatrixUnif, false, modelMatrix.top().fillAndFlipBuffer( mat4Buffer ) );
            glUniform4f( unlit.objectColorUnif, 0.25f, 0.25f, 0.25f, 1.0f );
            cubeMesh.render( "flat" );
            glDepthMask( true );
            glEnable( GL_DEPTH_TEST );
            glUniform4f( unlit.objectColorUnif, 1.0f, 1.0f, 1.0f, 1.0f );
            cubeMesh.render( "flat" );

            modelMatrix.pop();
        }
    }
View Full Code Here

TOP

Related Classes of fcagnin.jglsdk.glutil.MatrixStack

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.