示例#1
0
        public void writeVectorText()
        {
            // TODO 4.1: gluOrtho2D projekcija, ispis teksta
            Gl.glDisable(Gl.GL_LIGHTING);
            Gl.glViewport(m_width - 260, 0, 250, 250);
            Gl.glMatrixMode(Gl.GL_PROJECTION);
            Gl.glLoadIdentity();
            Glu.gluOrtho2D(-7, 7, -7, 7);

            Gl.glMatrixMode(Gl.GL_MODELVIEW);
            Gl.glPushMatrix();
            Gl.glLoadIdentity();

            Gl.glPushAttrib(Gl.GL_CURRENT_BIT);
            Gl.glColor3ub(255, 255, 0);

            Gl.glPushMatrix();
            Gl.glTranslatef(-7, -2, 0);
            m_font.DrawText("Predmet: Racunarska grafika");
            Gl.glPopMatrix();

            Gl.glPushMatrix();
            Gl.glTranslatef(-7, -3, 0);
            m_font.DrawText("Sk.god: 2015/16.");
            Gl.glPopMatrix();

            Gl.glPushMatrix();
            Gl.glTranslatef(-7, -4, 0);
            m_font.DrawText("Ime: Aleksandar");
            Gl.glPopMatrix();

            Gl.glPushMatrix();
            Gl.glTranslatef(-7, -5, 0);
            m_font.DrawText("Prezime: Bosnjak");
            Gl.glPopMatrix();

            Gl.glPushMatrix();
            Gl.glTranslatef(-7, -6, 0);
            m_font.DrawText("Sifra zad: 8.3");
            Gl.glPopMatrix();
            Gl.glPopAttrib();
            Gl.glPopMatrix();
            Gl.glEnable(Gl.GL_LIGHTING);
            Resize();

            //
        }
示例#2
0
        /// <summary>
        ///  Iscrtavanje OpenGL kontrole.
        /// </summary>
        public void Draw()
        {
            Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT);

            Gl.glPushMatrix();
            Gl.glTranslatef(0.0f, 0.0f, -m_sceneDistance);
            Gl.glRotatef(m_xRotation, 1.0f, 0.0f, 0.0f); //odamh za 10
            Gl.glRotatef(m_yRotation, 0.0f, 1.0f, 0.0f);

            // Tacka 6 faza 2: Pozicionirati kameru, tako da se vide deo planete, kao i bočna i gornja strana svemirskog broda.
            Glu.gluLookAt(-10.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f);

            //Tacka 9 faza 2 Pozicionirati tackasti izvor svetlosti iznad broda
            float[] positionLight0 = { 0.0f, 40.0f, 0.0f, 1.0f };
            Gl.glLightfv(Gl.GL_LIGHT0, Gl.GL_POSITION, positionLight0);

            //planeta
            Gl.glPushMatrix();
            Gl.glTranslatef(0.0f, -80.0f, 0.0f);
            Gl.glRotatef(moon_rotationAngle, 0.0f, 1.0f, 0.0f);
            Gl.glColor3f(0.4f, 0.4f, 0.4f);
            Glu.gluQuadricNormals(gluObject, Glu.GLU_SMOOTH);
            Glu.gluQuadricTexture(gluObject, Gl.GL_TRUE);
            Gl.glBindTexture(Gl.GL_TEXTURE_2D, m_textures[(int)TextureObjects.Moon]);
            Glu.gluSphere(gluObject, 60.0f, 128, 128);

            Gl.glPopMatrix();

            //nosac postolja
            Gl.glPushMatrix();
            Gl.glTranslatef(0.0f, -50.0f + standCarrier, 0.0f);
            Gl.glRotatef(-90.0f, 1.0f, 0.0f, 0.0f);
            Gl.glColor3f(0.4f, 0.4f, 0.4f);
            Glu.gluQuadricNormals(gluObject, Glu.GLU_SMOOTH);
            Glu.gluQuadricTexture(gluObject, Gl.GL_TRUE);
            Gl.glBindTexture(Gl.GL_TEXTURE_2D, m_textures[(int)TextureObjects.Metal_light]);
            Glu.gluCylinder(gluObject, 10.0f, 5.0f, 40.0f, 128, 128);
            Gl.glPopMatrix();

            //postolje
            Gl.glPushMatrix();
            postolje = new Box(boxScaleX, 5.0, boxScaleZ);
            Gl.glTranslatef(0.0f, -10.0f + standHeight, 0.0f);
            Gl.glRotatef(standAngle, 0.0f, 1.0f, 0.0f);
            // Tacka 10 faza 2: Način stapanja teksture sa materijalom postolja postaviti na GL_ADD
            Gl.glTexEnvi(Gl.GL_TEXTURE_ENV, Gl.GL_TEXTURE_ENV_MODE, Gl.GL_ADD);
            Gl.glBindTexture(Gl.GL_TEXTURE_2D, m_textures[(int)TextureObjects.Metal_dark]);
            Gl.glMatrixMode(Gl.GL_TEXTURE);

            Gl.glPushMatrix();
            Gl.glScalef(0.3f, 0.3f, 0.3f);
            Gl.glMatrixMode(Gl.GL_MODELVIEW);
            Gl.glColor3f(0.2f, 0.2f, 0.2f);
            postolje.Draw();
            Gl.glTexEnvi(Gl.GL_TEXTURE_ENV, Gl.GL_TEXTURE_ENV_MODE, Gl.GL_MODULATE);

            Gl.glMatrixMode(Gl.GL_TEXTURE);
            Gl.glPopMatrix();

            Gl.glMatrixMode(Gl.GL_MODELVIEW);
            Gl.glPopMatrix();

            //brod
            Gl.glPushMatrix();
            Gl.glRotatef(m_rotationAngle, 0.0f, 1.0f, 0.0f);
            Gl.glTranslatef(m_shipDistance, 4.0f + shipHeight, m_shipR);
            Gl.glScaled(scaleShip, scaleShip, scaleShip);
            m_scene.Draw();
            Gl.glPopMatrix();

            //ona prva
            Gl.glPopMatrix();

            //teskt
            Gl.glPushMatrix();
            Gl.glColor3f(1.0f, 0.0f, 0.0f);
            Gl.glMatrixMode(Gl.GL_PROJECTION);
            Gl.glLoadIdentity();
            Glu.gluOrtho2D(-15, 15, -15, 15);
            Gl.glMatrixMode(Gl.GL_MODELVIEW);
            Gl.glLoadIdentity();
            Gl.glPushMatrix();
            Gl.glDisable(Gl.GL_LIGHTING);

            Gl.glPushMatrix();
            Gl.glTranslatef(-outFont.CalculateTextWidth(predmet) * -0.25f, 13.5f, 0.0f);
            outFont.DrawText(predmet);
            Gl.glPopMatrix();

            Gl.glPushMatrix();
            Gl.glTranslatef(-outFont.CalculateTextWidth(predmet) * -0.25f, 12.5f, 0.0f);
            outFont.DrawText(skolGod);
            Gl.glPopMatrix();

            Gl.glPushMatrix();
            Gl.glTranslatef(-outFont.CalculateTextWidth(predmet) * -0.25f, 11.5f, 0.0f);
            outFont.DrawText(ime);
            Gl.glPopMatrix();

            Gl.glPushMatrix();
            Gl.glTranslatef(-outFont.CalculateTextWidth(predmet) * -0.25f, 10.5f, 0.0f);
            outFont.DrawText(prezime);
            Gl.glPopMatrix();

            Gl.glPushMatrix();
            Gl.glTranslatef(-outFont.CalculateTextWidth(predmet) * -0.25f, 9.5f, 0.0f);
            outFont.DrawText(sifraZad);
            Gl.glPopMatrix();
            Gl.glPopMatrix();
            Gl.glPopMatrix();
            Resize();

            // Oznaci kraj iscrtavanja
            Gl.glFlush();
        }