コード例 #1
0
ファイル: MissileWeapon.cs プロジェクト: hyyly/teslagame
        public void Draw(float frameTime, Frustum frustum)
        {
            position.set( position + frameTime * direction * 10.0f);
            ps.Draw(frameTime, frustum);

            quad.Draw(frameTime, frustum);
        }
コード例 #2
0
ファイル: BillboardedQuad.cs プロジェクト: hyyly/teslagame
 public void Draw(float frameTime, Frustum frustum)
 {
     Gl.glEnable(Gl.GL_BLEND);
     Gl.glColor3f(1.0f, 1.0f, 1.0f);
     Gl.glPushMatrix();
     Gl.glTranslatef(position.x, position.y, position.z);
     Gl.glScalef(size.x, size.y, 1.0f);
     texture.Bind();
     Gl.glCallList(displayList);
     Gl.glPopMatrix();
 }
コード例 #3
0
ファイル: ParticleSystem.cs プロジェクト: hyyly/teslagame
        public void Draw(float frameTime, Frustum frustum)
        {
            updateParticles(frameTime);
            drawParticles(frameTime, frustum);

            if (!endlessLife)
                emitterLife -= frameTime;
            if (particleEmitter.getActive() && (endlessLife || emitterLife > 0.0f) && listParticles.Count < maxParticles)
            {
                listParticles.Add(particleEmitter.emit(particleFactory));
            }
        }
コード例 #4
0
ファイル: Landscapev2.cs プロジェクト: hyyly/teslagame
        public void Draw(float frameTime, Frustum frustum)
        {
            Gl.glPushMatrix();
            //Gl.glDisable(Gl.GL_LIGHTING);

            //Gl.glMaterialfv(Gl.GL_FRONT_AND_BACK, Gl.GL_AMBIENT_AND_DIFFUSE, mcolor);

            //Gl.glMaterialfv(Gl.GL_FRONT_AND_BACK, Gl.GL_EMISSION, mcolor2);
            /*Gl.glMaterialfv(Gl.GL_FRONT_AND_BACK, Gl.GL_SPECULAR, mcolor3);
            Gl.glMaterialfv(Gl.GL_FRONT_AND_BACK, Gl.GL_SHININESS, mcolor3);*/
            Gl.glEnableClientState(Gl.GL_TEXTURE_COORD_ARRAY);
            Gl.glEnableClientState(Gl.GL_NORMAL_ARRAY);
            Gl.glEnableClientState(Gl.GL_VERTEX_ARRAY);
            //Gl.glEnableClientState(Gl.GL_COLOR_ARRAY);

            this.baseTexture.Bind();

            bool useVBO = true;
            if(useVBO) // supports VBO
            {
                Gl.glBindBufferARB( Gl.GL_ARRAY_BUFFER_ARB, vboReference[0] );
                Gl.glVertexPointer( 3, Gl.GL_FLOAT, 0, null );		// Set The Vertex Pointer To The Vertex Buffer
                Gl.glBindBufferARB( Gl.GL_ARRAY_BUFFER_ARB, vboReference[1] );
                Gl.glNormalPointer( Gl.GL_FLOAT, 0, null );
                Gl.glBindBufferARB( Gl.GL_ARRAY_BUFFER_ARB, vboReference[2] );
                Gl.glClientActiveTextureARB( Gl.GL_TEXTURE0_ARB);
                Gl.glTexCoordPointer( 2, Gl.GL_FLOAT, 0, null );
                Gl.glBindBufferARB( Gl.GL_ARRAY_BUFFER_ARB, vboReference[2] );
                Gl.glClientActiveTextureARB( Gl.GL_TEXTURE1_ARB);
                Gl.glTexCoordPointer( 2, Gl.GL_FLOAT, 0, null );
                Gl.glBindBufferARB( Gl.GL_ARRAY_BUFFER_ARB, vboReference[2] );
                Gl.glClientActiveTextureARB( Gl.GL_TEXTURE2_ARB);
                Gl.glTexCoordPointer( 2, Gl.GL_FLOAT, 0, null );

                /*Gl.glBindBufferARB( Gl.GL_ARRAY_BUFFER_ARB, vboReference[4] );
                Gl.glColorPointer( 4, Gl.GL_FLOAT, 0, null );*/
            }
            else
            {
                Gl.glVertexPointer( 3, Gl.GL_FLOAT, 0, v );	// Set The Vertex Pointer To Our Vertex Data
                //Gl.glTexCoordPointer( 2, Gl.GL_FLOAT, 0, g_pMesh->m_pTexCoords );	// Set The Vertex Pointer To Our TexCoord Data
            }

            Gl.glDrawArrays(Gl.GL_QUADS, 0, (4 * drawIndices.Length));

            Gl.glDisableClientState(Gl.GL_TEXTURE_COORD_ARRAY);
            Gl.glDisableClientState(Gl.GL_NORMAL_ARRAY);
            Gl.glDisableClientState(Gl.GL_VERTEX_ARRAY);
            Gl.glDisableClientState(Gl.GL_COLOR_ARRAY);

            Gl.glPopMatrix();
        }
コード例 #5
0
ファイル: GluSphere.cs プロジェクト: hyyly/teslagame
 public void Draw(float frameTime, Frustum frustum)
 {
     Gl.glPushMatrix();
     Gl.glDisable(Gl.GL_LIGHTING);
     Gl.glColor3f(1.0f, 1.0f, 1.0f);
     Gl.glTranslatef(position.x, position.y, position.z);
     Gl.glRotatef(angle, x_axis, y_axis, z_axis);
     texture.Bind();
     Gl.glScalef(radius, radius, radius);
     Glu.gluSphere(quad, radius, slices, slices);
     texture.UnBind();
     Gl.glPopMatrix();
 }
コード例 #6
0
ファイル: TexturedCube.cs プロジェクト: hyyly/teslagame
        public void Draw(float frameTime, Frustum frustum)
        {
            Gl.glPushMatrix();
            if (texture != null)
                texture.Bind();
            Gl.glColor3f(1.0f, 1.0f, 1.0f);
            Gl.glTranslatef(pos.x, pos.y, pos.z);
            Gl.glRotatef(rotation.a, rotation.r, rotation.g, rotation.b);
            Gl.glScalef(width, height, depth);

            Gl.glBegin(Gl.GL_QUADS);
                // Front Face
                Gl.glNormal3f( 0.0f, 0.0f, 1.0f);					// Normal Pointing Towards Viewer
                Gl.glTexCoord2f(0.0f, 0.0f); Gl.glVertex3f(-1.0f, -1.0f,  1.0f);	// Point 1 (Front)
                Gl.glTexCoord2f(1.0f, 0.0f); Gl.glVertex3f( 1.0f, -1.0f,  1.0f);	// Point 2 (Front)
                Gl.glTexCoord2f(1.0f, 1.0f); Gl.glVertex3f( 1.0f,  1.0f,  1.0f);	// Point 3 (Front)
                Gl.glTexCoord2f(0.0f, 1.0f); Gl.glVertex3f(-1.0f,  1.0f,  1.0f);	// Point 4 (Front)
                // Back Face
                Gl.glNormal3f( 0.0f, 0.0f,-1.0f);					// Normal Pointing Away From Viewer
                Gl.glTexCoord2f(1.0f, 0.0f); Gl.glVertex3f(-1.0f, -1.0f, -1.0f);	// Point 1 (Back)
                Gl.glTexCoord2f(1.0f, 1.0f); Gl.glVertex3f(-1.0f,  1.0f, -1.0f);	// Point 2 (Back)
                Gl.glTexCoord2f(0.0f, 1.0f); Gl.glVertex3f( 1.0f,  1.0f, -1.0f);	// Point 3 (Back)
                Gl.glTexCoord2f(0.0f, 0.0f); Gl.glVertex3f( 1.0f, -1.0f, -1.0f);	// Point 4 (Back)
                // Top Face
                Gl.glNormal3f( 0.0f, 1.0f, 0.0f);					// Normal Pointing Up
                Gl.glTexCoord2f(0.0f, 1.0f); Gl.glVertex3f(-1.0f,  1.0f, -1.0f);	// Point 1 (Top)
                Gl.glTexCoord2f(0.0f, 0.0f); Gl.glVertex3f(-1.0f,  1.0f,  1.0f);	// Point 2 (Top)
                Gl.glTexCoord2f(1.0f, 0.0f); Gl.glVertex3f( 1.0f,  1.0f,  1.0f);	// Point 3 (Top)
                Gl.glTexCoord2f(1.0f, 1.0f); Gl.glVertex3f( 1.0f,  1.0f, -1.0f);	// Point 4 (Top)
                // Bottom Face
                Gl.glNormal3f( 0.0f,-1.0f, 0.0f);					// Normal Pointing Down
                Gl.glTexCoord2f(1.0f, 1.0f); Gl.glVertex3f(-1.0f, -1.0f, -1.0f);	// Point 1 (Bottom)
                Gl.glTexCoord2f(0.0f, 1.0f); Gl.glVertex3f( 1.0f, -1.0f, -1.0f);	// Point 2 (Bottom)
                Gl.glTexCoord2f(0.0f, 0.0f); Gl.glVertex3f( 1.0f, -1.0f,  1.0f);	// Point 3 (Bottom)
                Gl.glTexCoord2f(1.0f, 0.0f); Gl.glVertex3f(-1.0f, -1.0f,  1.0f);	// Point 4 (Bottom)
                // Right face
                Gl.glNormal3f( 1.0f, 0.0f, 0.0f);					// Normal Pointing Right
                Gl.glTexCoord2f(1.0f, 0.0f); Gl.glVertex3f( 1.0f, -1.0f, -1.0f);	// Point 1 (Right)
                Gl.glTexCoord2f(1.0f, 1.0f); Gl.glVertex3f( 1.0f,  1.0f, -1.0f);	// Point 2 (Right)
                Gl.glTexCoord2f(0.0f, 1.0f); Gl.glVertex3f( 1.0f,  1.0f,  1.0f);	// Point 3 (Right)
                Gl.glTexCoord2f(0.0f, 0.0f); Gl.glVertex3f( 1.0f, -1.0f,  1.0f);	// Point 4 (Right)
                // Left Face
                Gl.glNormal3f(-1.0f, 0.0f, 0.0f);					// Normal Pointing Left
                Gl.glTexCoord2f(0.0f, 0.0f); Gl.glVertex3f(-1.0f, -1.0f, -1.0f);	// Point 1 (Left)
                Gl.glTexCoord2f(1.0f, 0.0f); Gl.glVertex3f(-1.0f, -1.0f,  1.0f);	// Point 2 (Left)
                Gl.glTexCoord2f(1.0f, 1.0f); Gl.glVertex3f(-1.0f,  1.0f,  1.0f);	// Point 3 (Left)
                Gl.glTexCoord2f(0.0f, 1.0f); Gl.glVertex3f(-1.0f,  1.0f, -1.0f);	// Point 4 (Left)
            Gl.glEnd();

            Gl.glPopMatrix();
        }
コード例 #7
0
ファイル: CenteredQuad.cs プロジェクト: hyyly/teslagame
        public void Draw(float frameTime, Frustum frustum)
        {
            texture.Bind();
            Gl.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
            Gl.glBegin(Gl.GL_QUADS);
            Gl.glNormal3f(0, 0, -1);
            Gl.glTexCoord2f(0, 0); Gl.glVertex3f(pos.x - w2, pos.y + h2, pos.z);
            Gl.glTexCoord2f(u, 0); Gl.glVertex3f(pos.x + w2, pos.y + h2, pos.z);
            Gl.glTexCoord2f(u, v); Gl.glVertex3f(pos.x + w2, pos.y - h2, pos.z);
            Gl.glTexCoord2f(0, v); Gl.glVertex3f(pos.x - w2, pos.y - h2, pos.z);

            Gl.glEnd();
            texture.UnBind();
        }
コード例 #8
0
ファイル: GroundPlane.cs プロジェクト: hyyly/teslagame
 public void Draw(float frameTime, Frustum frustum)
 {
     //Gl.glDisable(Gl.GL_LIGHTING);
     Gl.glColor3f(1.0f, 1.0f, 1.0f);
     if (texture != null)
         texture.Bind();
     Gl.glBegin(Gl.GL_QUADS);
     Gl.glNormal3fv(normal.vector);
     Gl.glTexCoord2f(0	 , 0);		Gl.glVertex3fv(pointA.vector);
     Gl.glTexCoord2f(0	 , tileV);	Gl.glVertex3fv(pointB.vector);
     Gl.glTexCoord2f(tileU, tileV); 	Gl.glVertex3fv(pointC.vector);
     Gl.glTexCoord2f(tileU, 0); 		Gl.glVertex3fv(pointD.vector);
     texture.UnBind();
     Gl.glEnd();
 }
コード例 #9
0
ファイル: Water.cs プロジェクト: hyyly/teslagame
        public void Draw(float frameTime, Frustum frustum)
        {
            uv += frameTime*0.05f;
            texture.Bind();
            Gl.glColor4f(1.0f, 1.0f, 1.0f, 0.5f);
            Gl.glDisable(Gl.GL_LIGHTING);
            Gl.glBegin(Gl.GL_QUADS);
            Gl.glNormal3f(0, 1, 0);
            Gl.glTexCoord2f(0 + uv, 1000 + uv); Gl.glVertex3f(-10000, y, -10000);
            Gl.glTexCoord2f(1000 + uv, 1000 + uv); Gl.glVertex3f( 10000, y, -10000);
            Gl.glTexCoord2f(1000 + uv, 0 + uv); Gl.glVertex3f( 10000, y,  10000);
            Gl.glTexCoord2f(0 + uv, 0 + uv); Gl.glVertex3f(-10000, y,  10000);

            Gl.glEnd();
            Gl.glEnable(Gl.GL_LIGHTING);
        }
コード例 #10
0
ファイル: Landscape2D.cs プロジェクト: hyyly/teslagame
        public void Draw(float frameTime, Frustum frustum)
        {
            Gl.glEnable(Gl.GL_COLOR_MATERIAL);
            Gl.glColor3f(1.0f, 1.0f, 1.0f);
            textureWall.Bind();
            Gl.glBegin(Gl.GL_QUADS);
            for (int i = 0; i < width - 1; i++)
            {
                float fiz = (float)i;
                fiz /= 5.0f;
                float fio = (float)i + 1.0f;
                fio /= 5.0f;
                Gl.glNormal3f(0.0f, 0.0f, 1.0f);
                Gl.glTexCoord2f(fiz, 1);
                Gl.glVertex3f(upperVertrices[i, 0].position.x, upperVertrices[i, 0].position.y, 0);
                Gl.glTexCoord2f(fio, 1);
                Gl.glVertex3f(upperVertrices[i+1, 0].position.x, upperVertrices[i+1, 0].position.y, 0);

                Gl.glTexCoord2f(fio, 0);
                Gl.glVertex3f(lowerVertrices[i+1, 0].position.x, lowerVertrices[i+1, 0].position.y, 0);
                Gl.glTexCoord2f(fiz, 0);
                Gl.glVertex3f(lowerVertrices[i, 0].position.x  , lowerVertrices[i, 0].position.y, 0);
            }
            Gl.glEnd();
            textureWall.UnBind();

            textureGround.Bind();
            Gl.glBegin(Gl.GL_QUADS);
            for (int i = 0; i < width - 1; i++)
            {
                for (int j = 0; j < depth - 1; j++)
                {
                    upperVertrices[i  ,j  ].draw();
                    upperVertrices[i+1,j  ].draw();
                    upperVertrices[i+1,j+1].draw();
                    upperVertrices[i  ,j+1].draw();

                    lowerVertrices[i  ,j  ].draw();
                    lowerVertrices[i+1,j  ].draw();
                    lowerVertrices[i+1,j+1].draw();
                    lowerVertrices[i  ,j+1].draw();
                }
            }
            Gl.glEnd();
            textureGround.UnBind();
        }
コード例 #11
0
ファイル: Cube.cs プロジェクト: hyyly/teslagame
        public void Draw(float frameTime, Frustum frustum)
        {
            Gl.glDisable(Gl.GL_TEXTURE_2D);
            Gl.glDisable(Gl.GL_LIGHTING);
            Gl.glColor4f(color.r, color.g, color.b, color.a);
            Gl.glPushMatrix();
            Gl.glTranslatef(pos.x,pos.y,pos.z);				// Move Right And Into The Screen
            Gl.glScalef(width, height, depth);
            Gl.glBegin(Gl.GL_QUADS);					// Start Drawing The Cube
                Gl.glVertex3f( 1.0f, 1.0f,-1.0f);			// Top Right Of The Quad (Top)
                Gl.glVertex3f(-1.0f, 1.0f,-1.0f);			// Top Left Of The Quad (Top)
                Gl.glVertex3f(-1.0f, 1.0f, 1.0f);			// Bottom Left Of The Quad (Top)
                Gl.glVertex3f( 1.0f, 1.0f, 1.0f);			// Bottom Right Of The Quad (Top)

                Gl.glVertex3f( 1.0f,-1.0f, 1.0f);			// Top Right Of The Quad (Bottom)
                Gl.glVertex3f(-1.0f,-1.0f, 1.0f);			// Top Left Of The Quad (Bottom)
                Gl.glVertex3f(-1.0f,-1.0f,-1.0f);			// Bottom Left Of The Quad (Bottom)
                Gl.glVertex3f( 1.0f,-1.0f,-1.0f);			// Bottom Right Of The Quad (Bottom)

                Gl.glVertex3f( 1.0f, 1.0f, 1.0f);			// Top Right Of The Quad (Front)
                Gl.glVertex3f(-1.0f, 1.0f, 1.0f);			// Top Left Of The Quad (Front)
                Gl.glVertex3f(-1.0f,-1.0f, 1.0f);			// Bottom Left Of The Quad (Front)
                Gl.glVertex3f( 1.0f,-1.0f, 1.0f);			// Bottom Right Of The Quad (Front)

                Gl.glVertex3f( 1.0f,-1.0f,-1.0f);			// Bottom Left Of The Quad (Back)
                Gl.glVertex3f(-1.0f,-1.0f,-1.0f);			// Bottom Right Of The Quad (Back)
                Gl.glVertex3f(-1.0f, 1.0f,-1.0f);			// Top Right Of The Quad (Back)
                Gl.glVertex3f( 1.0f, 1.0f,-1.0f);			// Top Left Of The Quad (Back)

                Gl.glVertex3f(-1.0f, 1.0f, 1.0f);			// Top Right Of The Quad (Left)
                Gl.glVertex3f(-1.0f, 1.0f,-1.0f);			// Top Left Of The Quad (Left)
                Gl.glVertex3f(-1.0f,-1.0f,-1.0f);			// Bottom Left Of The Quad (Left)
                Gl.glVertex3f(-1.0f,-1.0f, 1.0f);			// Bottom Right Of The Quad (Left)

                Gl.glVertex3f( 1.0f, 1.0f,-1.0f);			// Top Right Of The Quad (Right)
                Gl.glVertex3f( 1.0f, 1.0f, 1.0f);			// Top Left Of The Quad (Right)
                Gl.glVertex3f( 1.0f,-1.0f, 1.0f);			// Bottom Left Of The Quad (Right)
                Gl.glVertex3f( 1.0f,-1.0f,-1.0f);			// Bottom Right Of The Quad (Right)
            Gl.glEnd();

            rot -= 0.10f;

            Gl.glPopMatrix();
            Gl.glEnable(Gl.GL_LIGHTING);
            Gl.glEnable(Gl.GL_TEXTURE_2D);
        }
コード例 #12
0
ファイル: Frustum.cs プロジェクト: hyyly/teslagame
        public static void test()
        {
            Camera c = new Camera(new Vector3f(0.0f, 0.0f, 0.0f), 90.0f, 1.0f, 1.0f, 10.0f);
            Frustum f = new Frustum(c);
            Check.AssertEquals(f.fc, new Vector3f(0.0f, 0.0f, -10.0f));
            Check.AssertEquals(f.fbl, new Vector3f(-10.0f,-10.0f, -10.0f));
            Check.AssertEquals(f.fbr, new Vector3f( 10.0f,-10.0f, -10.0f));
            Check.AssertEquals(f.ftl, new Vector3f(-10.0f, 10.0f, -10.0f));
            Check.AssertEquals(f.ftr, new Vector3f( 10.0f, 10.0f, -10.0f));

            Check.AssertEquals("Testing p", f.inFrustum(new Vector3f(0.0f, 0.0f, -5.0f)), true);
            Check.AssertEquals(f.inFrustum(new Vector3f(10.0f, 10.0f, -10.0f)), true);
            Check.AssertEquals(f.inFrustum(new Vector3f(1.0f, 1.0f, -1.0f)), true);

            Check.AssertEquals(f.inFrustum(new Vector3f(0.0f, 0.0f, 0.0f)), false);
            Check.AssertEquals(f.inFrustum(new Vector3f(0.0f, 0.0f, 20.0f)), false);
            Check.AssertEquals(f.inFrustum(new Vector3f(-20.0f, -20.0f, 20.0f)), false);
        }
コード例 #13
0
ファイル: MultiTexturedQuad.cs プロジェクト: hyyly/teslagame
        public void Draw(float frameTime, Frustum frustum)
        {
            Gl.glPushMatrix();

            Gl.glDisable(Gl.GL_LIGHTING);
            //Gl.glColor3f(1.0f, 1.0f, 1.0f);
            /*float rgbValue   = c.r / (1.0f - c.b);
            float alphaValue = 1.0f - c.b;

            // Do some bounds checking...
            if( rgbValue < 0.0f )
                rgbValue = 0.0f;
            if( rgbValue > 1.0f )
                rgbValue = 1.0f;

            if( alphaValue < 0.0f )
                alphaValue = 0.0f;
            if( alphaValue > 1.0f )
                alphaValue = 1.0f;

            Gl.glColor4f( rgbValue, rgbValue, rgbValue, alphaValue );*/

            preDraw();

            Gl.glTranslatef(pos.x, pos.y, 0);

            Gl.glScalef(width, height, 1.0f);

            Gl.glBegin(Gl.GL_QUADS);
                // Front Face
                Gl.glNormal3f( 0.0f, 0.0f, 1.0f);					// Normal Pointing Towards Viewer
                setTex2f(0.0f, 0.0f);Gl.glVertex3f(-1.0f, -1.0f,  0.0f);	// Point 1 (Front)
                setTex2f(1.0f, 0.0f); Gl.glVertex3f( 1.0f, -1.0f,  0.0f);	// Point 2 (Front)
                setTex2f(1.0f, 1.0f); Gl.glVertex3f( 1.0f,  1.0f,  0.0f);	// Point 3 (Front)
                setTex2f(0.0f, 1.0f); Gl.glVertex3f(-1.0f,  1.0f,  0.0f);	// Point 4 (Front)
            Gl.glEnd();

            postDraw();

            Gl.glPopMatrix();
        }
コード例 #14
0
ファイル: AnimatedQuad.cs プロジェクト: hyyly/teslagame
        public void Draw(float frameTime, Frustum frustum)
        {
            f += (frameTime * 10);
            int i = (int)f;
            if (i >= textures.Length)
            {
                f = 0.0f;
                i = 0;
            }
            textures[i].Bind();
            Gl.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
            Gl.glBegin(Gl.GL_QUADS);
            Gl.glNormal3f(0, 0, -1);
            Gl.glTexCoord2f(0, 0); Gl.glVertex3f(pos.x, pos.y, pos.z);
            Gl.glTexCoord2f(1, 0); Gl.glVertex3f(pos.x + width, pos.y, pos.z);
            Gl.glTexCoord2f(1, 1); Gl.glVertex3f(pos.x + width, pos.y - height, pos.z);
            Gl.glTexCoord2f(0, 1); Gl.glVertex3f(pos.x, pos.y - height, pos.z);

            Gl.glEnd();
            textures[i].UnBind();
        }
コード例 #15
0
 void Drawable.Draw(float frameTime, Frustum frustum)
 {
     Draw(true);
 }
コード例 #16
0
ファイル: ParticleSystem.cs プロジェクト: hyyly/teslagame
 public void drawParticles(float frameTime, Frustum frustum)
 {
     particleFactory.preDraw();
     //int i = 0;
     //int j = 0;
     //if (frustum.inFrustum(boundingSphere)) //TODO Not working properly
     {
         foreach (Particle p in listParticles)
         {
             if (frustum.inFrustum(p.position))
                 p.Draw(activeCamera, frameTime);
         }
     }
     particleFactory.postDraw();
 }
コード例 #17
0
ファイル: SDLWindow.cs プロジェクト: hyyly/teslagame
        private void InitGL(Configuration configuration)
        {
            Gl.glShadeModel(Gl.GL_SMOOTH);
            Gl.glEnable(Gl.GL_TEXTURE_2D);
            //Gl.glDepthFunc(Gl.GL_ALWAYS);
            Gl.glDepthFunc(Gl.GL_LEQUAL);
            Gl.glEnable(Gl.GL_DEPTH_TEST);
            Gl.glEnable(Gl.GL_BLEND);

            Gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

            /* Setup LIGHTING  */
            float[] LightAmbient = { 0.1f, 0.09f, 0.06f, 1.0f };
            float[] LightDiffuse = { 1.0f, 0.819607843f, 0.450980392f, 1.0f };
            float[] LightPosition = { -0.33f, 0.33f, -0.33f, 0.0f };
            Gl.glEnable(Gl.GL_LIGHTING);
            Gl.glEnable(Gl.GL_LIGHT1);
            Gl.glLightfv(Gl.GL_LIGHT1, Gl.GL_AMBIENT, LightAmbient);
            Gl.glLightfv(Gl.GL_LIGHT1, Gl.GL_DIFFUSE, LightDiffuse);
            Gl.glLightfv(Gl.GL_LIGHT1, Gl.GL_POSITION, LightPosition);

            float[] LightSpot = {1.0f, 1.0f, 1.0f, 1.0f};

            //Gl.glBlendFunc(Gl.GL_ONE, Gl.GL_SRC_ALPHA);
            //Gl.glBlendFunc(Gl.GL_SRC_ALPHA_SATURATE, Gl.GL_ONE);
            Gl.glBlendFunc(Gl.GL_SRC_ALPHA, Gl.GL_ONE_MINUS_SRC_ALPHA);  //perfekt för alla mina TexturedQuad
            Gl.glHint(Gl.GL_PERSPECTIVE_CORRECTION_HINT, Gl.GL_NICEST);

            /* Required setup stuff */
            Gl.glViewport(0, 0, Width, Height);
            Gl.glMatrixMode(Gl.GL_PROJECTION);
            Gl.glLoadIdentity();
            Glu.gluPerspective(45.0f, Width / (float)Height, 0.1f, 2000.0f);
            camera = new Camera(new Vector3f(0.0f, 0.0f, 0.0f), 45.0f, (float)Width / (float)Height, 0.1f, 2000.0f);
            frustum = new Frustum(camera);
            Gl.glMatrixMode(Gl.GL_MODELVIEW);
            Gl.glLoadIdentity();

            //Gl.glEnable(Gl.GL_CULL_FACE);
            //Gl.glPolygonMode(Gl.GL_FRONT, Gl.GL_FILL);
            //Gl.glFrontFace(Gl.GL_CW);

            int error = Gl.glGetError();
            if (error != Gl.GL_NO_ERROR)
                Log.Write("OpenGL: " + Gl.glGetString(error), LogType.CriticalError);
        }
コード例 #18
0
ファイル: Drawable.cs プロジェクト: hyyly/teslagame
 void Drawable.Draw(float frameTime, Frustum frustum)
 {
     Draw(true);
 }
コード例 #19
0
ファイル: MultiTexturedCube.cs プロジェクト: hyyly/teslagame
        public void Draw(float frameTime, Frustum frustum)
        {
            Gl.glPushMatrix();

            Gl.glDisable(Gl.GL_LIGHTING);
            //Gl.glColor3f(1.0f, 1.0f, 1.0f);
            float rgbValue   = c.r / (1.0f - c.b);
            float alphaValue = 1.0f - c.b;

            // Do some bounds checking...
            if( rgbValue < 0.0f )
                rgbValue = 0.0f;
            if( rgbValue > 1.0f )
                rgbValue = 1.0f;

            if( alphaValue < 0.0f )
                alphaValue = 0.0f;
            if( alphaValue > 1.0f )
                alphaValue = 1.0f;

            Gl.glColor4f( rgbValue, rgbValue, rgbValue, alphaValue );

            preDraw();

            Gl.glTranslatef(pos.x, pos.y, pos.z);

            Gl.glScalef(width, height, depth);

            Gl.glBegin(Gl.GL_QUADS);
                // Front Face
                Gl.glNormal3f( 0.0f, 0.0f, 1.0f);					// Normal Pointing Towards Viewer
                setTex2f(0.0f, 0.0f);Gl.glVertex3f(-1.0f, -1.0f,  1.0f);	// Point 1 (Front)
                setTex2f(1.0f, 0.0f); Gl.glVertex3f( 1.0f, -1.0f,  1.0f);	// Point 2 (Front)
                setTex2f(1.0f, 1.0f); Gl.glVertex3f( 1.0f,  1.0f,  1.0f);	// Point 3 (Front)
                setTex2f(0.0f, 1.0f); Gl.glVertex3f(-1.0f,  1.0f,  1.0f);	// Point 4 (Front)
                // Back Face
                Gl.glNormal3f( 0.0f, 0.0f,-1.0f);					// Normal Pointing Away From Viewer
                setTex2f(1.0f, 0.0f); Gl.glVertex3f(-1.0f, -1.0f, -1.0f);	// Point 1 (Back)
                setTex2f(1.0f, 1.0f); Gl.glVertex3f(-1.0f,  1.0f, -1.0f);	// Point 2 (Back)
                setTex2f(0.0f, 1.0f); Gl.glVertex3f( 1.0f,  1.0f, -1.0f);	// Point 3 (Back)
                setTex2f(0.0f, 0.0f); Gl.glVertex3f( 1.0f, -1.0f, -1.0f);	// Point 4 (Back)
                // Top Face
                Gl.glNormal3f( 0.0f, 1.0f, 0.0f);					// Normal Pointing Up
                setTex2f(0.0f, 1.0f); Gl.glVertex3f(-1.0f,  1.0f, -1.0f);	// Point 1 (Top)
                setTex2f(0.0f, 0.0f); Gl.glVertex3f(-1.0f,  1.0f,  1.0f);	// Point 2 (Top)
                setTex2f(1.0f, 0.0f); Gl.glVertex3f( 1.0f,  1.0f,  1.0f);	// Point 3 (Top)
                setTex2f(1.0f, 1.0f); Gl.glVertex3f( 1.0f,  1.0f, -1.0f);	// Point 4 (Top)
                // Bottom Face
                Gl.glNormal3f( 0.0f,-1.0f, 0.0f);					// Normal Pointing Down
                setTex2f(1.0f, 1.0f); Gl.glVertex3f(-1.0f, -1.0f, -1.0f);	// Point 1 (Bottom)
                setTex2f(0.0f, 1.0f); Gl.glVertex3f( 1.0f, -1.0f, -1.0f);	// Point 2 (Bottom)
                setTex2f(0.0f, 0.0f); Gl.glVertex3f( 1.0f, -1.0f,  1.0f);	// Point 3 (Bottom)
                setTex2f(1.0f, 0.0f); Gl.glVertex3f(-1.0f, -1.0f,  1.0f);	// Point 4 (Bottom)
                // Right face
                Gl.glNormal3f( 1.0f, 0.0f, 0.0f);					// Normal Pointing Right
                setTex2f(1.0f, 0.0f); Gl.glVertex3f( 1.0f, -1.0f, -1.0f);	// Point 1 (Right)
                setTex2f(1.0f, 1.0f); Gl.glVertex3f( 1.0f,  1.0f, -1.0f);	// Point 2 (Right)
                setTex2f(0.0f, 1.0f); Gl.glVertex3f( 1.0f,  1.0f,  1.0f);	// Point 3 (Right)
                setTex2f(0.0f, 0.0f); Gl.glVertex3f( 1.0f, -1.0f,  1.0f);	// Point 4 (Right)
                // Left Face
                Gl.glNormal3f(-1.0f, 0.0f, 0.0f);					// Normal Pointing Left
                setTex2f(0.0f, 0.0f); Gl.glVertex3f(-1.0f, -1.0f, -1.0f);	// Point 1 (Left)
                setTex2f(1.0f, 0.0f); Gl.glVertex3f(-1.0f, -1.0f,  1.0f);	// Point 2 (Left)
                setTex2f(1.0f, 1.0f); Gl.glVertex3f(-1.0f,  1.0f,  1.0f);	// Point 3 (Left)
                setTex2f(0.0f, 1.0f); Gl.glVertex3f(-1.0f,  1.0f, -1.0f);	// Point 4 (Left)
            Gl.glEnd();

            postDraw();

            Gl.glPopMatrix();
        }
コード例 #20
0
ファイル: MultiTexturedCube.cs プロジェクト: topfs2/teslagame
        public void Draw(float frameTime, Frustum frustum)
        {
            Gl.glPushMatrix();

            Gl.glDisable(Gl.GL_LIGHTING);
            //Gl.glColor3f(1.0f, 1.0f, 1.0f);
            float rgbValue   = c.r / (1.0f - c.b);
            float alphaValue = 1.0f - c.b;

            // Do some bounds checking...
            if (rgbValue < 0.0f)
            {
                rgbValue = 0.0f;
            }
            if (rgbValue > 1.0f)
            {
                rgbValue = 1.0f;
            }

            if (alphaValue < 0.0f)
            {
                alphaValue = 0.0f;
            }
            if (alphaValue > 1.0f)
            {
                alphaValue = 1.0f;
            }

            Gl.glColor4f(rgbValue, rgbValue, rgbValue, alphaValue);

            preDraw();

            Gl.glTranslatef(pos.x, pos.y, pos.z);

            Gl.glScalef(width, height, depth);

            Gl.glBegin(Gl.GL_QUADS);
            // Front Face
            Gl.glNormal3f(0.0f, 0.0f, 1.0f);                                                    // Normal Pointing Towards Viewer
            setTex2f(0.0f, 0.0f); Gl.glVertex3f(-1.0f, -1.0f, 1.0f);                            // Point 1 (Front)
            setTex2f(1.0f, 0.0f); Gl.glVertex3f(1.0f, -1.0f, 1.0f);                             // Point 2 (Front)
            setTex2f(1.0f, 1.0f); Gl.glVertex3f(1.0f, 1.0f, 1.0f);                              // Point 3 (Front)
            setTex2f(0.0f, 1.0f); Gl.glVertex3f(-1.0f, 1.0f, 1.0f);                             // Point 4 (Front)
            // Back Face
            Gl.glNormal3f(0.0f, 0.0f, -1.0f);                                                   // Normal Pointing Away From Viewer
            setTex2f(1.0f, 0.0f); Gl.glVertex3f(-1.0f, -1.0f, -1.0f);                           // Point 1 (Back)
            setTex2f(1.0f, 1.0f); Gl.glVertex3f(-1.0f, 1.0f, -1.0f);                            // Point 2 (Back)
            setTex2f(0.0f, 1.0f); Gl.glVertex3f(1.0f, 1.0f, -1.0f);                             // Point 3 (Back)
            setTex2f(0.0f, 0.0f); Gl.glVertex3f(1.0f, -1.0f, -1.0f);                            // Point 4 (Back)
            // Top Face
            Gl.glNormal3f(0.0f, 1.0f, 0.0f);                                                    // Normal Pointing Up
            setTex2f(0.0f, 1.0f); Gl.glVertex3f(-1.0f, 1.0f, -1.0f);                            // Point 1 (Top)
            setTex2f(0.0f, 0.0f); Gl.glVertex3f(-1.0f, 1.0f, 1.0f);                             // Point 2 (Top)
            setTex2f(1.0f, 0.0f); Gl.glVertex3f(1.0f, 1.0f, 1.0f);                              // Point 3 (Top)
            setTex2f(1.0f, 1.0f); Gl.glVertex3f(1.0f, 1.0f, -1.0f);                             // Point 4 (Top)
            // Bottom Face
            Gl.glNormal3f(0.0f, -1.0f, 0.0f);                                                   // Normal Pointing Down
            setTex2f(1.0f, 1.0f); Gl.glVertex3f(-1.0f, -1.0f, -1.0f);                           // Point 1 (Bottom)
            setTex2f(0.0f, 1.0f); Gl.glVertex3f(1.0f, -1.0f, -1.0f);                            // Point 2 (Bottom)
            setTex2f(0.0f, 0.0f); Gl.glVertex3f(1.0f, -1.0f, 1.0f);                             // Point 3 (Bottom)
            setTex2f(1.0f, 0.0f); Gl.glVertex3f(-1.0f, -1.0f, 1.0f);                            // Point 4 (Bottom)
            // Right face
            Gl.glNormal3f(1.0f, 0.0f, 0.0f);                                                    // Normal Pointing Right
            setTex2f(1.0f, 0.0f); Gl.glVertex3f(1.0f, -1.0f, -1.0f);                            // Point 1 (Right)
            setTex2f(1.0f, 1.0f); Gl.glVertex3f(1.0f, 1.0f, -1.0f);                             // Point 2 (Right)
            setTex2f(0.0f, 1.0f); Gl.glVertex3f(1.0f, 1.0f, 1.0f);                              // Point 3 (Right)
            setTex2f(0.0f, 0.0f); Gl.glVertex3f(1.0f, -1.0f, 1.0f);                             // Point 4 (Right)
            // Left Face
            Gl.glNormal3f(-1.0f, 0.0f, 0.0f);                                                   // Normal Pointing Left
            setTex2f(0.0f, 0.0f); Gl.glVertex3f(-1.0f, -1.0f, -1.0f);                           // Point 1 (Left)
            setTex2f(1.0f, 0.0f); Gl.glVertex3f(-1.0f, -1.0f, 1.0f);                            // Point 2 (Left)
            setTex2f(1.0f, 1.0f); Gl.glVertex3f(-1.0f, 1.0f, 1.0f);                             // Point 3 (Left)
            setTex2f(0.0f, 1.0f); Gl.glVertex3f(-1.0f, 1.0f, -1.0f);                            // Point 4 (Left)
            Gl.glEnd();

            postDraw();

            Gl.glPopMatrix();
        }
コード例 #21
0
 public void Draw(float frameTime, Frustum frustum)
 {
     ps.Draw(frameTime, frustum);
 }
コード例 #22
0
ファイル: Frustum.cs プロジェクト: hyyly/teslagame
        public void Draw(float frameTime, Frustum frustum)
        {
            Gl.glDisable(Gl.GL_TEXTURE_2D);
            Gl.glDisable(Gl.GL_LIGHTING);
            Gl.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
            Gl.glBegin(Gl.GL_TRIANGLES);
            Gl.glVertex3fv(camera.getPosition().vector);
            Gl.glVertex3fv(fbl.vector);
            Gl.glVertex3fv(fbr.vector);

            Gl.glVertex3fv(camera.getPosition().vector);
            Gl.glVertex3fv(ftr.vector);
            Gl.glVertex3fv(ftl.vector);
            Gl.glEnd();

            Gl.glColor3f(1.0f, 1.0f, 0.0f);
            Gl.glBegin(Gl.GL_LINES);
            Gl.glVertex3fv(ftr.vector);
            Gl.glVertex3f(right.a + ftr.x, right.b + ftr.y, right.c + ftr.z);
            Gl.glColor3f(0.0f, 1.0f, 0.0f);
            Gl.glVertex3fv(ftl.vector);
            Gl.glVertex3f(left.a + ftl.x, left.b + ftl.y, left.c + ftl.z);
            Gl.glColor3f(0.0f, 1.0f, 1.0f);
            Gl.glVertex3fv(fc.vector);
            Gl.glVertex3f(far.a + fc.x, far.b + fc.y, far.c + fc.z);
            Gl.glVertex3fv(nc.vector);
            Gl.glVertex3f(near.a + nc.x, near.b + nc.y, near.c + nc.z);

            Gl.glColor3f(1.0f, 0.0f, 0.0f);
            Gl.glVertex3fv(fc.vector);
            Gl.glVertex3f(top.a + fc.x, top.b + fc.y, top.c + fc.z);
            Gl.glColor3f(0.0f, 0.0f, 1.0f);
            Gl.glVertex3fv(fc.vector);
            Gl.glVertex3f(bottom.a + fc.x, bottom.b + fc.y, bottom.c + fc.z);

            Gl.glColor3f(1.0f, 1.0f, 1.0f);
            Gl.glVertex3fv(camera.getPosition().vector);
            Gl.glVertex3fv((camera.getPosition() + camera.getFrontVector()*camera.Far).vector);

            Gl.glEnd();

            Gl.glBegin(Gl.GL_QUADS);
            Gl.glColor4f(0.0f, 0.0f, 1.0f, 1.0f);
            Gl.glVertex3fv(ftl.vector);
            Gl.glVertex3fv(ftr.vector);
            Gl.glVertex3fv(fbr.vector);
            Gl.glVertex3fv(fbl.vector);

            Gl.glVertex3fv(ntl.vector);
            Gl.glVertex3fv(ntr.vector);
            Gl.glVertex3fv(nbr.vector);
            Gl.glVertex3fv(nbl.vector);
            Gl.glEnd();
        }