예제 #1
0
        void Update(IntPtr pParameter)
        {
            // render into the texture for advanced example part
            RenderPlanetInToTexture();

            // create water polygon for advanced example part
            TRectF section_adv_rect = new TRectF(ScreenWidth / 2f, ScreenHeight / 2f,
                                                 ScreenWidth / 2f, ScreenHeight / 2f);
            float bottom_y            = section_adv_rect.y + section_adv_rect.height;
            float right_x             = section_adv_rect.x + section_adv_rect.width;
            float texture_coord_koeff = 75f;

            waterWaves.Clear();
            waterWaves.Add(new TVertex2((int)section_adv_rect.x, (int)bottom_y,
                                        (int)(section_adv_rect.x / texture_coord_koeff), (int)(bottom_y / texture_coord_koeff),
                                        (int)0.274f, (int)0.863f, (int)0.863f, (int)1f));

            for (int i = 0; i < 33; ++i)
            {
                float x = section_adv_rect.x + i * section_adv_rect.width / 32f,
                      y = (float)((section_adv_rect.y + section_adv_rect.height / 2f) + Math.Sin((float)counter / 20f + (float)i * 50f) * 15f);
                waterWaves.Add(new TVertex2(x, y, x / texture_coord_koeff, y / texture_coord_koeff, 0.274f, 0.863f, 0.863f, 1f));
            }

            waterWaves.Add(new TVertex2(right_x, bottom_y, right_x / texture_coord_koeff, bottom_y / texture_coord_koeff, 0.274f, 0.863f, 0.863f, 1f));

            // other stuff
            stRandomCol = new TColor4((byte)(rand.Next(255)), (byte)(rand.Next(255)), (byte)(rand.Next(255)), 255);
            ++counter;
        }
예제 #2
0
        void Render(IntPtr pParam)
        {
            pRender2D.Begin2D();

            TPoint2 pc;

            pc = new TPoint2((float)(350 + Math.Cos(counter / 200.0) * 200), (float)(350 + Math.Sin(counter / 200.0) * 80));
            TPoint2 ps = new TPoint2(1, 1);

            // make floating camera
            pRender2D.SetCamera(ref pc,                               //camera center
                                (float)Math.Sin(counter / 50.0) * 15, //camera angle
                                ref ps                                //camera scale
                                );
            pRender2D.ProjectScreenToCamera(ref stMouseOnScreen, out stMouseInCamera);

            pc = new TPoint2(-750f, -750f);
            ps = new TPoint2(2000f, 2000f);
            pRender2D.DrawTexture(pTextures[7], ref pc, ref ps, 0f, E_EFFECT2D_FLAGS.EF_TILE_TEXTURE);

            //draw stone layer with per vertex blending
            TColor4 white = TColor4.ColorWhite();
            TColor4 col = TColor4.ColorWhite(0);
            TPoint2 p1 = new TPoint2(0f, 225f);
            uint    x, y;

            pTextures[8].GetDimensions(out x, out y);
            TPoint2 pdim = new TPoint2((float)x, (float)y);

            pRender2D.SetVerticesColors(ref col, ref white, ref white, ref col);
            pRender2D.DrawTexture(pTextures[8], ref p1, ref pdim, 0f, (E_EFFECT2D_FLAGS.EF_VERTICES_COLORS | E_EFFECT2D_FLAGS.EF_BLEND));

            pRender2D.SetVerticesColors(ref white, ref col, ref col, ref white);
            p1 = new TPoint2(0f + 256f, 225f);
            pRender2D.DrawTexture(pTextures[8], ref p1, ref pdim, 0f, (E_EFFECT2D_FLAGS.EF_VERTICES_COLORS | E_EFFECT2D_FLAGS.EF_BLEND));

            pRender2D.SetVerticesColors(ref white, ref col, ref col, ref col);
            p1 = new TPoint2(0f + 256f, 225f + 256f);
            pRender2D.DrawTexture(pTextures[8], ref p1, ref pdim, 0f, (E_EFFECT2D_FLAGS.EF_VERTICES_COLORS | E_EFFECT2D_FLAGS.EF_BLEND));

            pRender2D.SetVerticesColors(ref col, ref white, ref col, ref col);
            p1 = new TPoint2(0f, 225f + 256f);
            pRender2D.DrawTexture(pTextures[8], ref p1, ref pdim, 0f, (E_EFFECT2D_FLAGS.EF_VERTICES_COLORS | E_EFFECT2D_FLAGS.EF_BLEND));

            //// set color mix to semi-transparent black for object shadows
            col = TColor4.ColorBlack(128);
            pRender2D.SetColorMix(ref col);

            for (int i = 0; i < MyMeshes.Length; i++) // all meshes with shadows except copter
            {
                MyMeshes[i].Draw();
            }

            zombie.Render();

            copter.Render((float)counter);

            pRender2D.End2D();
        }
예제 #3
0
파일: CSpark.cs 프로젝트: whztt07/DGLE
 public override void Draw()
 {
     _pRender2D.SetBlendMode(E_BLENDING_EFFECT.BE_ADD);
     TColor4 c = new TColor4(255, 128, 40, (byte)(255 - _uiCounter / 12));
     _pRender2D.SetColorMix(ref c);
     _pRender2D.DrawTexture(pTexSpark, ref pos, ref dim, _fAngle,
         E_EFFECT2D_FLAGS.EF_COLOR_MIX | E_EFFECT2D_FLAGS.EF_BLEND);
 }
예제 #4
0
        void DrawFont(TRectF screen)
        {
            string  txt;
            uint    width, height;
            TColor4 c;

            txt = "I'm rotating... +_+";
            pFontBold.GetTextDimensions(txt, out width, out height);
            c = TColor4.ColorWhite();
            pFontBold.Draw2D(screen.x + screen.width - width - 10f, 200, txt, ref c, counter % 360);

            txt = "I'm just right aligned text. -_-";
            pFontBold.GetTextDimensions(txt, out width, out height);
            pFontBold.Draw2D((int)(screen.x + screen.width - width), 10, txt, ref c);

            txt = "I have a shadow! ;-)";
            pFontBold.GetTextDimensions(txt, out width, out height);
            c = TColor4.ColorBlack();
            pFontBold.Draw2D((int)(screen.x + screen.width - width - 7f), 53, txt, ref c);
            c = TColor4.ColorWhite();
            pFontBold.Draw2D((int)(screen.x + screen.width - width - 10f), 50, txt, ref c);

            txt = "Cool colored me! ^_^";
            pFontBold.GetTextDimensions(txt, out width, out height);
            TColor4 c1 = TColor4.ColorRed();
            TColor4 c2 = TColor4.ColorGreen();

            pRender2D.SetVerticesColors(ref c1, ref c2, ref c1, ref c2);
            c = TColor4.ColorWhite();
            pFontBold.Draw2D(screen.x + screen.width - width - 10f, 100f, txt, ref c, 0, true);

            txt = "I'm randomly colored... >_<";
            pFont.Draw2D(screen.x + 5f, 10, txt, ref stRandomCol);

            txt = "I'm per vertex colored! -_0";
            TColor4 c3 = TColor4.ColorAqua();
            TColor4 c4 = TColor4.ColorOrange();

            pRender2D.SetVerticesColors(ref c3, ref c3, ref c4, ref c4);
            c = TColor4.ColorWhite();
            pFontBold.Draw2D(screen.x + 5f, 50f, txt, ref c, 0, true);

            txt = "А я могу говорить по-русски! [:-|";
            c   = TColor4.ColorRed();
            pFont.Draw2D(screen.x + 5f, 100, txt, ref c);

            txt = "I'm scaling... o_O";
            pFontBold.SetScale((float)Math.Abs(Math.Sin(counter / 50f)) * 2f);
            c = TColor4.ColorWhite();
            pFontBold.Draw2D(screen.x + 5f, 200, txt, ref c);
            pFontBold.SetScale(1f);

            txt = "I am just very brutal..!";
            pFontHard.GetTextDimensions(txt, out width, out height);
            c = TColor4.ColorOfficialOrange();
            pFontHard.Draw2D((int)(screen.x + (screen.width - width) / 2f), 300f, txt, ref c);
        }
예제 #5
0
파일: CSpark.cs 프로젝트: yunatoomi/DGLE
        public override void Draw()
        {
            _pRender2D.SetBlendMode(E_BLENDING_EFFECT.BE_ADD);
            TColor4 c = new TColor4(255, 128, 40, (byte)(255 - _uiCounter / 12));

            _pRender2D.SetColorMix(ref c);
            _pRender2D.DrawTexture(pTexSpark, ref pos, ref dim, _fAngle,
                                   E_EFFECT2D_FLAGS.EF_COLOR_MIX | E_EFFECT2D_FLAGS.EF_BLEND);
        }
예제 #6
0
파일: Program.cs 프로젝트: yunatoomi/DGLE
        static void Render(IntPtr pParam)
        {
            string  txt = "Hello, world!";
            TColor4 color = TColor4.ColorWhite();
            uint    w, h;

            mainFont.GetTextDimensions(txt, out w, out h);
            mainFont.Draw2DSimple((int)((SCREEN_WIDTH - w) / 2), (int)((SCREEN_HEIGHT - h) / 2), txt, ref color);
        }
예제 #7
0
            public void Render(float counter)
            {
                CopterMesh.Draw();
                pRender2D.DrawTexture(RotorTex, ref vint_pos, ref vint_dim, counter * 25f);
                // make blinky rotor shadow
                TColor4 col = TColor4.ColorBlack((byte)(counter % 3 == 2 ? 64 : 16));

                pRender2D.SetColorMix(ref col);
                TPoint2 p1 = vint_pos + new TPoint2(100f, 100f);

                pRender2D.DrawTexture(RotorShadow, ref p1, ref vint_dim, 0f, (E_EFFECT2D_FLAGS.EF_COLOR_MIX | E_EFFECT2D_FLAGS.EF_BLEND));
            }
예제 #8
0
        public virtual void Draw()
        {
            if (!_pObjMan.IsDebugMode())
            {
                return;
            }
            TColor4 c = TColor4.ColorWhite();

            _pRender2D.DrawCircle(ref _stPos, (uint)(_fSize / 2f), 32, ref c);
            c = TColor4.ColorRed();
            _pRender2D.DrawCircle(ref _stPos, (uint)(_fSize * _fColScale / 2f), 32, ref c);
        }
예제 #9
0
        public override void Draw()
        {
            string res = _uiScore.ToString();

            uint w, h;

            _pFnt.SetScale(_fSize);
            _pFnt.GetTextDimensions(res, out w, out h);
            _pRender2D.SetBlendMode(E_BLENDING_EFFECT.BE_NORMAL);
            TColor4 c = TColor4.ColorWhite((byte)(255 - _uiCounter * 5));

            _pFnt.Draw2D(_stPos.x - w / 2f, _stPos.y - h / 2f, res, ref c);
        }
예제 #10
0
        public override void Draw()
        {
            TColor4 c = TColor4.ColorRed();

            _pRender2D.SetColorMix(ref c);

            TPoint2 pos = new TPoint2(_stPos.x - _fSize / 2f, _stPos.y - _fSize / 2f);
            TPoint2 dim = new TPoint2(_fSize, _fSize);

            _pRender2D.DrawTexture(pTexSpark, ref pos, ref dim, _uiCounter * 2f, E_EFFECT2D_FLAGS.EF_COLOR_MIX |
                                   E_EFFECT2D_FLAGS.EF_BLEND);

            base.Draw();
        }
예제 #11
0
        void DrawAdvanced(TRectF screen)
        {
            pTexBg.Draw2D((int)screen.x, (int)screen.y, (uint)screen.width, (uint)screen.height, 0, 0);

            TPoint2 pos = new TPoint2(screen.x + screen.width - 160f, screen.y + 20f);
            TPoint2 dim = new TPoint2(128f, 128f);

            pRender2D.DrawTexture(pTexPlanetRenderIn, ref pos, ref dim, 0, E_EFFECT2D_FLAGS.EF_BLEND |
                                  E_EFFECT2D_FLAGS.EF_FLIP_VERTICALLY /* because render targets are flipped */);

            pRender2D.SetBlendMode(E_BLENDING_EFFECT.BE_ADD);

            // not to triangulate complex polygon every frame we can batch it this way and triangulation will be done only after update tick
            pRender2D.BeginBatch(false);
            pRender2D.DrawPolygon(pTexAnimWater[counter / 5 % 11], ref waterWaves.ToArray()[0], (uint)waterWaves.Count,
                                  E_PRIMITIVE2D_FLAGS.PF_FILL);
            pRender2D.EndBatch();

            uint w, h;

            pTexJellyFish.GetDimensions(out w, out h);
            float   x_offset = (float)(Math.Abs(Math.Cos(counter / 20f)) * 50);
            float   y_offset = (float)(Math.Sin(counter / 10f) * 75);
            TPoint2 jellyPos = new TPoint2(screen.x + 175f, screen.y + 200f);

            TPoint2 vert1 = new TPoint2();
            TPoint2 vert2 = new TPoint2();
            TPoint2 vert3 = new TPoint2(x_offset, -y_offset);
            TPoint2 vert4 = new TPoint2(-x_offset, -y_offset);

            pRender2D.SetVerticesOffsets(ref vert1, ref vert2, ref vert3, ref vert4);
            TColor4 c = TColor4.ColorViolet();

            pRender2D.SetColorMix(ref c);
            dim = new TPoint2(w / 2f, h / 2f);
            pRender2D.DrawTexture(pTexJellyFish, ref jellyPos, ref dim, -45f, E_EFFECT2D_FLAGS.EF_BLEND |
                                  E_EFFECT2D_FLAGS.EF_VERTICES_OFFSETS | E_EFFECT2D_FLAGS.EF_COLOR_MIX);

            pTexLightRound.GetDimensions(out w, out h);
            pos = jellyPos - new TPoint2(90f, 15f);
            dim = new TPoint2(w, h);
            pRender2D.DrawTexture(pTexLightRound, ref pos, ref dim, 0, E_EFFECT2D_FLAGS.EF_BLEND |
                                  E_EFFECT2D_FLAGS.EF_COLOR_MIX);
        }
예제 #12
0
파일: Program.cs 프로젝트: yunatoomi/DGLE
        void Render(IntPtr pParam)
        {
            pTex.Draw2D(0, 0, ScreenWidth, ScreenHeight, 0, 0);

            uint width, height, framecount;

            TColor4 c = TColor4.ColorWhite();

            const string txt = AppCaption;

            pFont.GetTextDimensions(txt, out width, out height);
            pFont.Draw2DSimple((int)((ScreenWidth - width) / 2),
                               (int)((ScreenHeight - height) / 2), txt, ref c);

            pTexSprite.GetFrameSize(out width, out height);
            pTexSprite.FramesCount(out framecount);
            pTexSprite.Draw2DSimple((int)((ScreenWidth - width) / 2),
                                    5, (counter / 2) % framecount);
        }
예제 #13
0
파일: Game.cs 프로젝트: yunatoomi/DGLE
        void Render(IntPtr pParam)
        {
            TColor4 c;
            uint    w, h;
            string  acTxt;

            // render game objects
            for (int i = 0; i < _clObjects.Count; i++)
            {
                _clObjects[i].Draw();
            }

            // render in-game user interface
            pRender2D.SetBlendMode(E_BLENDING_EFFECT.BE_NORMAL);
            pFnt.SetScale(1f);

            // if player is dead draw message
            if (!IsPlayerExists())
            {
                acTxt = "You are dead! Press \"Enter\" to restart.";
                pFnt.GetTextDimensions(acTxt, out w, out h);
                c = TColor4.ColorRed();
                pFnt.Draw2DSimple((int)((Res.GameVpWidth - w) / 2), (int)(Res.GameVpHeight - h) / 2, acTxt, ref c);
            }

            // draw help before game start
            if (_uiScore == 0)
            {
                acTxt = "Use \"Arrows\" to move and \"Space Bar\" to shoot.";
                pFnt.GetTextDimensions(acTxt, out w, out h);
                c = TColor4.ColorWhite();
                pFnt.Draw2DSimple((int)((Res.GameVpWidth - w) / 2), (int)(Res.GameVpHeight - h), acTxt, ref c);
            }

            acTxt = "Score: " + _uiScore.ToString();
            pFnt.GetTextDimensions(acTxt, out w, out h);
            c = TColor4.ColorWhite();
            pFnt.Draw2DSimple((int)((Res.GameVpWidth - w) / 2), 0, acTxt, ref c);
        }
예제 #14
0
        void RenderPlanetInToTexture()
        {
            TColor4 c = TColor4.ColorWhite(0); // set clear color here because SetRenderTarget will clear color buffer for us

            pRender.SetClearColor(ref c);
            pRender.SetRenderTarget(pTexPlanetRenderIn);

            pRender2D.Begin2D();

            TPoint2 pos = new TPoint2();
            TPoint2 dim = new TPoint2(256f, 256f);

            pRender2D.DrawTexture(pTexMask, ref pos, ref dim, 0f, E_EFFECT2D_FLAGS.EF_BLEND);

            pRender2D.SetBlendMode(E_BLENDING_EFFECT.BE_MASK);

            float texOffsetX = counter / 200f;

            // generate two triangles to form a quad and move their texture coordinates horizontally
            TVertex2[] quad =
            {
                new TVertex2(0f,     0f, texOffsetX,      0f, 1f, 1f, 1f, 1f),
                new TVertex2(256f,   0f, 1f + texOffsetX, 0f, 1f, 1f, 1f, 1f),
                new TVertex2(256f, 256f, 1f + texOffsetX, 1f, 1f, 1f, 1f, 1f),
                new TVertex2(0f,     0f, texOffsetX,      0f, 1f, 1f, 1f, 1f),
                new TVertex2(256f, 256f, 1f + texOffsetX, 1f, 1f, 1f, 1f, 1f),
                new TVertex2(0f,   256f, 0f + texOffsetX, 1f, 1f, 1f, 1f, 1f)
            };

            pRender2D.DrawTriangles(pTexPlanet, ref quad[0], (uint)quad.Length, E_PRIMITIVE2D_FLAGS.PF_FILL);

            pRender2D.End2D();

            c = TColor4.ColorOfficialBlack();
            pRender.SetClearColor(ref c); // set clear color back
            pRender.SetRenderTarget(null);
        }
예제 #15
0
        void Init(IntPtr pParam)
        {
            IEngineSubSystem pSubSys;

            pEngineCore.GetSubSystem(E_ENGINE_SUB_SYSTEM.ESS_CORE_RENDERER, out pSubSys);
            pCoreRenderer = (ICoreRenderer)pSubSys;

            pEngineCore.GetSubSystem(E_ENGINE_SUB_SYSTEM.ESS_RENDER, out pSubSys);
            IRender pRender = (IRender)pSubSys;

            pRender.GetRender3D(out pRender3D);
            TColor4 c = TColor4.ColorGray();

            pRender.SetClearColor(ref c);

            IResourceManager pResMan;

            pEngineCore.GetSubSystem(E_ENGINE_SUB_SYSTEM.ESS_RESOURCE_MANAGER, out pSubSys);
            pResMan = (IResourceManager)pSubSys;

            IEngineBaseObject pBaseObj;

            const uint load_3d_flag = (uint)(E_TEXTURE_LOAD_FLAGS.TLF_FILTERING_ANISOTROPIC |
                                             E_TEXTURE_LOAD_FLAGS.TLF_ANISOTROPY_4X | E_TEXTURE_LOAD_FLAGS.TLF_GENERATE_MIPMAPS);

            pResMan.Load(RESOURCE_PATH + "fonts\\Times_New_Roman_18_Bold.dft", out pBaseObj,
                         (uint)E_BITMAP_FONT_LOAD_FLAGS.BFLF_GENERATE_MIPMAPS);
            pFont = (IBitmapFont)pBaseObj;
            pResMan.Load(RESOURCE_PATH + "textures\\grass.jpg", out pBaseObj, load_3d_flag |
                         (uint)E_TEXTURE_LOAD_FLAGS.TLF_COORDS_REPEAT /* cause we will tile this texture */);
            pTexGrass = (ITexture)pBaseObj;

            pResMan.Load(RESOURCE_PATH + "sprites\\cartoon_owl.png", out pBaseObj, load_3d_flag | (uint)E_TEXTURE_LOAD_FLAGS.TLF_COORDS_CLAMP);
            pTexOwl = (ITexture)pBaseObj;
            pTexOwl.SetFrameSize(48, 128);

            pResMan.Load(RESOURCE_PATH + "meshes\\trees\\tree_1.png", out pBaseObj, load_3d_flag | (uint)E_TEXTURE_LOAD_FLAGS.TLF_COORDS_CLAMP);
            pTexTree1 = (ITexture)pBaseObj;
            pResMan.Load(RESOURCE_PATH + "meshes\\trees\\tree_1.dmd", out pBaseObj, (uint)E_MESH_MODEL_LOAD_FLAGS.MMLF_FORCE_MODEL_TO_MESH);
            pMeshTree1 = (IMesh)pBaseObj;

            pResMan.Load(RESOURCE_PATH + "meshes\\trees\\tree_2.png", out pBaseObj, load_3d_flag | (uint)E_TEXTURE_LOAD_FLAGS.TLF_COORDS_CLAMP);
            pTexTree2 = (ITexture)pBaseObj;
            pResMan.Load(RESOURCE_PATH + "meshes\\trees\\tree_2.dmd", out pBaseObj, (uint)E_MESH_MODEL_LOAD_FLAGS.MMLF_FORCE_MODEL_TO_MESH);
            pMeshTree2 = (IMesh)pBaseObj;

            pResMan.Load(RESOURCE_PATH + "meshes\\trees\\tree_3.png", out pBaseObj, load_3d_flag | (uint)E_TEXTURE_LOAD_FLAGS.TLF_COORDS_CLAMP);
            pTexTree3 = (ITexture)pBaseObj;
            pResMan.Load(RESOURCE_PATH + "meshes\\trees\\tree_3.dmd", out pBaseObj, (uint)E_MESH_MODEL_LOAD_FLAGS.MMLF_FORCE_MODEL_TO_MESH);
            pMeshTree3 = (IMesh)pBaseObj;

            pResMan.Load(RESOURCE_PATH + "meshes\\zard\\zard_diff.dds", out pBaseObj, load_3d_flag | (uint)E_TEXTURE_LOAD_FLAGS.TLF_COORDS_CLAMP);
            pTexZard = (ITexture)pBaseObj;
            pResMan.Load(RESOURCE_PATH + "meshes\\zard\\zard_walk.dmd", out pBaseObj, 0);
            pModelZard = (IModel)pBaseObj;

            // add some fog to the scene
            pRender3D.SetFogColor(ref c);
            pRender3D.SetLinearFogBounds(1.5f, 4f);
            pRender3D.ToggleFog(true);

            PlaneDataPtr = Unmanaged.New <float>(c_afPlane.Length);
            PlaneDataPtr.Copy(c_afPlane);

            desc = new TDrawDataDesc
                   (
                PlaneDataPtr,
                12 * sizeof(float),
                24 * sizeof(float),
                false
                   );
        }
예제 #16
0
파일: Program.cs 프로젝트: whztt07/DGLE
        void Init(IntPtr pParam)
        {
            IEngineSubSystem p_sub_sys = null;

            IResourceManager p_res_man = null;
            pEngineCore.GetSubSystem(E_ENGINE_SUB_SYSTEM.ESS_RESOURCE_MANAGER, out p_sub_sys);
            p_res_man = (IResourceManager)p_sub_sys;

            IRender p_render = null;
            pEngineCore.GetSubSystem(E_ENGINE_SUB_SYSTEM.ESS_RENDER, out p_sub_sys);
            p_render = (IRender)p_sub_sys;
            p_render.GetRender2D(out pRender2D);

            IEngineBaseObject p_obj = null;

            pEngineCore.GetSubSystem(E_ENGINE_SUB_SYSTEM.ESS_INPUT, out p_sub_sys);
            pInput = (IInput)p_sub_sys;
            pInput.Configure(E_INPUT_CONFIGURATION_FLAGS.ICF_HIDE_CURSOR);

            p_res_man.GetDefaultResource(E_ENGINE_OBJECT_TYPE.EOT_BITMAP_FONT, out  p_obj);
            pFont = (IBitmapFont)p_obj;

            // Background clear color setup.
            TColor4 tc = new TColor4(38, 38, 55, 255);
            p_render.SetClearColor(ref tc);

            // This example adapted only for 800X600 resolution, if even resolution will be higher it won't effect it.
            pRender2D.SetResolutionCorrection(GAME_VP_WIDTH, GAME_VP_HEIGHT, true);

            p_res_man.Load(RESOURCE_PATH + "sounds\\owl.wav", out p_obj, 0);
            pSndOwl = (ISoundSample)p_obj;

            p_res_man.Load(RESOURCE_PATH + "sounds\\forest_ambient.wav", out p_obj, 0);
            pForestAmbient = (ISoundSample)p_obj;
            pForestAmbient.PlayEx(out pChannelAmbientLoop, E_SOUND_SAMPLE_PARAMS.SSP_LOOPED);

            p_res_man.Load(RESOURCE_PATH + "sprites\\cartoon_forest_background.png", out p_obj, (uint)E_TEXTURE_LOAD_FLAGS.TEXTURE_LOAD_DEFAULT_2D);
            pBg = (ITexture)p_obj;
            p_res_man.Load(RESOURCE_PATH + "sprites\\cartoon_cloudy_night_sky.jpg", out p_obj, (uint)E_TEXTURE_LOAD_FLAGS.TEXTURE_LOAD_DEFAULT_2D);
            pSky = (ITexture)p_obj;
            p_res_man.Load(RESOURCE_PATH + "sprites\\smoke.png", out p_obj, (uint)E_TEXTURE_LOAD_FLAGS.TEXTURE_LOAD_DEFAULT_2D);
            pFog = (ITexture)p_obj;
            p_res_man.Load(RESOURCE_PATH + "sprites\\light.jpg", out p_obj, (uint)E_TEXTURE_LOAD_FLAGS.TEXTURE_LOAD_DEFAULT_2D);
            pLightRound = (ITexture)p_obj;

            p_res_man.Load(RESOURCE_PATH + "sprites\\vox.jpg", out p_obj, (uint)E_TEXTURE_LOAD_FLAGS.TEXTURE_LOAD_DEFAULT_2D);
            pVox = (ITexture)p_obj;
            pVox.SetFrameSize(149, 149);

            p_res_man.Load(RESOURCE_PATH + "sprites\\cartoon_owl.png", out p_obj, (uint)E_TEXTURE_LOAD_FLAGS.TEXTURE_LOAD_DEFAULT_2D);
            pOwl = (ITexture)p_obj;
            pOwl.SetFrameSize(48, 128);

            p_res_man.Load(RESOURCE_PATH + "sprites\\cartoon_anime_girl.png", out p_obj, (uint)E_TEXTURE_LOAD_FLAGS.TEXTURE_LOAD_DEFAULT_2D);
            pTexGirl = (ITexture)p_obj;
            pTexGirl.SetFrameSize(55, 117);

            p_res_man.Load(RESOURCE_PATH + "sprites\\cartoon_mistery_light.jpg", out p_obj, (uint)E_TEXTURE_LOAD_FLAGS.TEXTURE_LOAD_DEFAULT_2D);
            pLight = (ITexture)p_obj;
            pLight.SetFrameSize(64, 128);
        }
예제 #17
0
파일: Program.cs 프로젝트: whztt07/DGLE
        void Render(IntPtr pParam)
        {
            if (pRender2D == null) return;

            pRender2D.Begin2D();

            // Draw  sky

            TPoint2 ps = new TPoint2();
            TPoint2 pt = new TPoint2(GAME_VP_WIDTH, GAME_VP_HEIGHT);

            pRender2D.DrawTexture(pSky, ref ps, ref pt, 0, E_EFFECT2D_FLAGS.EF_NONE);

            // Draw background

            ps = new TPoint2(cameraPosition.x / 1.5f, cameraPosition.y / 1.5f);
            pt = new TPoint2(cameraScale, cameraScale);

            pRender2D.SetCamera(ref ps, cameraAngle, ref pt);

            pRender2D.SetBlendMode(E_BLENDING_EFFECT.BE_NORMAL);

            ps = new TPoint2(-200f, 150f);
            pt = new TPoint2(1399f, 517f);
            TRectF rect = new TRectF(0f, 905f, 1399f, 517f);

            pRender2D.DrawTextureCropped(pBg, ref ps, ref pt, ref rect, 0.0f, E_EFFECT2D_FLAGS.EF_BLEND);

            // Draw moving fog on background

            ps = new TPoint2(cameraPosition.x / 1.2f, cameraPosition.y / 1.2f);
            pt = new TPoint2(cameraScale, cameraScale);
            pRender2D.SetCamera(ref ps, cameraAngle, ref pt);

            pRender2D.SetBlendMode(E_BLENDING_EFFECT.BE_ADD);

            // Sometimes it's better to batch a lot of similar objects.

            pRender2D.BeginBatch();

            TColor4 col = new TColor4(255, 255, 255, 64);

            pRender2D.SetColorMix(ref col);

            for (uint i = 0; i < 22; ++i)
                for (uint j = 0; j < 2; ++j)
                {
                    ps = new TPoint2((float)(500f + Math.Sin((float)i) * 600f - Math.Cos((float)counter / 50f) * 10f * (i % 4)),
                               (float)(475f + Math.Sin((float)j * 2.5f) * 150f - Math.Sin((float)counter / 50f) * 20f * (i % 3)));
                    pt = new TPoint2(250f, 150f);
                    pRender2D.DrawTexture(pFog, ref ps, ref pt, 0f, (E_EFFECT2D_FLAGS.EF_BLEND | E_EFFECT2D_FLAGS.EF_COLOR_MIX));
                }

            pRender2D.EndBatch();

            // Draw foreground scene

            // Setup camera and blending
            pt = new TPoint2(cameraScale, cameraScale);
            pRender2D.SetCamera(ref cameraPosition, cameraAngle, ref pt);

            pRender2D.SetBlendMode(E_BLENDING_EFFECT.BE_NORMAL);

            // Owl
            col = new TColor4(150, 150, 150, 255);
            pRender2D.SetColorMix(ref col); // make sprite little darker

            ps = new TPoint2(owlX, 425f);
            pt = new TPoint2(48f, 128f);
            E_EFFECT2D_FLAGS EEF = (E_EFFECT2D_FLAGS.EF_BLEND | E_EFFECT2D_FLAGS.EF_COLOR_MIX | (owlGoLeft ? E_EFFECT2D_FLAGS.EF_FLIP_HORIZONTALLY : E_EFFECT2D_FLAGS.EF_DEFAULT));
            pRender2D.DrawTextureSprite(pOwl, ref ps, ref pt, (uint)(counter / 3) % 15, 0f, EEF);

            // Draw tree
            ps = new TPoint2();
            pt = new TPoint2(1399f, 900f);
            rect = new TRectF(0f, 0f, 1399f, 900f);
            pRender2D.DrawTextureCropped(pBg, ref ps, ref pt, ref rect, 0f, E_EFFECT2D_FLAGS.EF_BLEND);

            // Glowing disc under moving light

            pRender2D.SetBlendMode(E_BLENDING_EFFECT.BE_ADD);

            ps = new TPoint2(-100f, 0f);
            pt = new TPoint2();
            pRender2D.SetVerticesOffsets(ref ps, ref ps, ref pt, ref pt);
            col = new TColor4(65, 59, 193, 255);
            pRender2D.SetColorMix(ref col);
            ps = new TPoint2(lights[0].x - 32f, lights[0].y + 64f);
            pt = new TPoint2(256f, 256f);
            pRender2D.DrawTexture(pLightRound, ref ps, ref pt, 0f, (E_EFFECT2D_FLAGS.EF_VERTICES_OFFSETS | E_EFFECT2D_FLAGS.EF_BLEND | E_EFFECT2D_FLAGS.EF_COLOR_MIX));

            // Girl Shadow

            pRender2D.SetBlendMode(E_BLENDING_EFFECT.BE_NORMAL);
            ps = new TPoint2(-150f + (float)Math.Cos((float)counter / 100f) * 100f, -55f);
            pt = new TPoint2(-50f + (float)Math.Cos((float)counter / 100f) * 100f, -55f);
            TPoint2 pp = new TPoint2(15f, 5f);
            pRender2D.SetVerticesOffsets(ref ps, ref pt, ref pp, ref pp);
            col = new TColor4(0, 0, 0, 128);
            pRender2D.SetColorMix(ref col);
            ps = new TPoint2(550f, 725f);
            pt = new TPoint2(60f, 120f);
            pRender2D.DrawTextureSprite(pTexGirl, ref ps, ref pt, (uint)(counter / 5) % 16, 0f, (E_EFFECT2D_FLAGS.EF_VERTICES_OFFSETS | E_EFFECT2D_FLAGS.EF_BLEND | E_EFFECT2D_FLAGS.EF_COLOR_MIX));

            // Girl Sprite
            pRender2D.DrawTextureSprite(pTexGirl, ref ps, ref pt, (uint)(counter / 5) % 16, 0f, E_EFFECT2D_FLAGS.EF_BLEND);

            // Lights

            pRender2D.SetBlendMode(E_BLENDING_EFFECT.BE_ADD);

            for (uint i = 0; i < 5; ++i)
            {
                ps = new TPoint2(lights[i].x, lights[i].y);
                pt = new TPoint2(64f, 128f);
                pRender2D.DrawTextureSprite(pLight, ref ps, ref pt, (uint)(counter / 2) % 14, 0f, E_EFFECT2D_FLAGS.EF_BLEND);
            }

            pRender2D.ResetCamera();

            // We must calculate correct coordinates in game space because game resolution and screen resolution can be different.
            TPoint2 pos;
            pRender2D.AbsoluteToResolutionCorrect(ref stMousePos, out pos);
            ps = new TPoint2(pos.x - 37, pos.y - 37);
            pt = new TPoint2(75f, 75f);
            pRender2D.DrawTextureSprite(pVox, ref ps, ref pt, (uint)(counter / 2) % 16, 0f, E_EFFECT2D_FLAGS.EF_BLEND);

            uint tw, th;
            pFont.GetTextDimensions(HELP_TEXT, out tw, out th);
            col = TColor4.White;
            pFont.Draw2D((float)((GAME_VP_WIDTH - tw) / 2), (float)(GAME_VP_HEIGHT - th), HELP_TEXT, ref col);

            pRender2D.End2D();
        }
예제 #18
0
파일: Program.cs 프로젝트: yunatoomi/DGLE
        void Render(IntPtr pParam)
        {
            // camera setup
            TMatrix4x4 mat = TMatrix4x4.MatrixIdentity;

            transform.Clear(ref mat);
            mat = TMatrix4x4.MatrixTranslate(new TPoint3(0f, -4.5f, -4f - (float)Math.Abs(Math.Sin(uiCounter / 250f)) * 5f));
            transform.MultLocal(ref mat);
            mat = TMatrix4x4.MatrixRotate(15f + (float)Math.Cos(uiCounter / 200f) * 10f, new TPoint3(1f, 0f, 0f));
            transform.MultLocal(ref mat);
            mat = TMatrix4x4.MatrixRotate(uiCounter / 5f, new TPoint3(0f, 1f, 0f));
            transform.MultLocal(ref mat);

            mat = transform.Top;
            pRender3D.SetMatrix(ref mat);

            // set light in the world coordinate system
            pLightDirect.Update();

            // draw floor

            p_render.Unbind(E_ENGINE_OBJECT_TYPE.EOT_MATERIAL); // unbind last material from previous frame

            for (int i = -5; i < 5; ++i)
            {
                for (int j = -5; j < 5; ++j)
                {
                    transform.Push();
                    mat = TMatrix4x4.MatrixTranslate(new TPoint3(i * 5f, 0f, j * 5f));
                    transform.MultLocal(ref mat);
                    mat = TMatrix4x4.MatrixScale(new TPoint3(5f, 5f, 5f));
                    transform.MultLocal(ref mat);
                    mat = TMatrix4x4.MatrixRotate(-90f, new TPoint3(1f, 0f, 0f));
                    transform.MultLocal(ref mat);
                    mat = transform.Top;
                    pRender3D.SetMatrix(ref mat);
                    pTexFloor.Draw3D();

                    transform.Pop();
                }
            }

            // draw desk

            TPoint3 desk_extents, extents;

            pMdlDesk.GetExtents(out desk_extents);
            TPoint3 desk_pos = new TPoint3(0f, desk_extents.z * 10f, 0f);

            transform.Push();
            mat = TMatrix4x4.MatrixTranslate(desk_pos);
            transform.MultLocal(ref mat);
            mat = TMatrix4x4.MatrixScale(new TPoint3(10f, 10f, 10f));
            transform.MultLocal(ref mat);
            mat = TMatrix4x4.MatrixRotate(-90f, new TPoint3(1f, 0f, 0f));
            transform.MultLocal(ref mat);
            mat = TMatrix4x4.MatrixRotate(180f, new TPoint3(0f, 0f, 1f));
            transform.MultLocal(ref mat);
            mat = transform.Top;
            pRender3D.SetMatrix(ref mat);
            pMdlDesk.Draw();
            transform.Pop();

            // draw chair
            pMdlChair.GetExtents(out extents);
            transform.Push();
            mat = TMatrix4x4.MatrixTranslate(new TPoint3(-1.5f, extents.z * 5f, 4.5f));
            transform.MultLocal(ref mat);
            mat = TMatrix4x4.MatrixScale(new TPoint3(5f, 5f, 5f));
            transform.MultLocal(ref mat);
            mat = TMatrix4x4.MatrixRotate(-90f, new TPoint3(1f, 0f, 0f));
            transform.MultLocal(ref mat);
            mat = TMatrix4x4.MatrixRotate(65f, new TPoint3(0f, 0f, 1f));
            transform.MultLocal(ref mat);
            mat = transform.Top;
            pRender3D.SetMatrix(ref mat);
            pMdlChair.Draw();
            transform.Pop();

            // draw music box
            pMdlMusicBox.GetExtents(out extents);
            transform.Push();
            mat = TMatrix4x4.MatrixTranslate(desk_pos + new TPoint3(-2.75f, extents.y * 6f, -1f));
            transform.MultLocal(ref mat);
            mat = TMatrix4x4.MatrixScale(new TPoint3(3f, 3f, 3f));
            transform.MultLocal(ref mat);
            mat = TMatrix4x4.MatrixRotate(-90f, new TPoint3(1f, 0f, 0f));
            transform.MultLocal(ref mat);
            mat = TMatrix4x4.MatrixRotate(25f, new TPoint3(0f, 0f, 1f));
            transform.MultLocal(ref mat);
            mat = transform.Top;
            pRender3D.SetMatrix(ref mat);
            pMdlMusicBox.Draw();
            transform.Pop();

            // draw table-lamp
            pMdlLamp.GetExtents(out extents);
            transform.Push();
            mat = TMatrix4x4.MatrixTranslate(desk_pos + new TPoint3(3.75f, extents.z * 8f - 0.2f, -1f));
            transform.MultLocal(ref mat);
            mat = TMatrix4x4.MatrixScale(new TPoint3(4f, 4f, 4f));
            transform.MultLocal(ref mat);
            mat = TMatrix4x4.MatrixRotate(-90f, new TPoint3(1f, 0f, 0f));
            transform.MultLocal(ref mat);
            mat = TMatrix4x4.MatrixRotate(-150f, new TPoint3(0f, 0f, 1f));
            transform.MultLocal(ref mat);
            mat = transform.Top;
            pRender3D.SetMatrix(ref mat);
            pMdlLamp.Draw();

            // here we set light position in the coordinate space of the lamp (object space)
            TPoint3 light_pos = new TPoint3(0.35f, 0f, extents.z - 0.15f);

            pLightSpot.SetPosition(ref light_pos);
            pLightSpot.Update();

            // draw light halo
            bool is_light_active;

            pLightSpot.GetEnabled(out is_light_active);

            if (is_light_active)
            {
                pRender3D.ToggleLighting(false);
                pRender3D.SetBlendMode(E_BLENDING_EFFECT.BE_ADD);
                pRender3D.ToggleBlending(true);
                TColor4 col = TColor4.ColorYellow(200);
                pRender3D.SetColor(ref col);
                mat = TMatrix4x4.MatrixTranslate(light_pos + new TPoint3(0f, 0f, -0.1f));
                transform.MultLocal(ref mat);
                mat = TMatrix4x4.MatrixScale(new TPoint3(0.25f, 0.25f, 0.25f));
                transform.MultLocal(ref mat);
                mat = TMatrix4x4.MatrixBillboard(transform.Top);
                pRender3D.SetMatrix(ref mat);
                pTexLight.Draw3D();
                pRender3D.ToggleLighting(true);
            }

            transform.Pop();

            // draw snow globe and church
            pSnowGlobe.GetExtents(out extents);
            transform.Push();
            mat = TMatrix4x4.MatrixTranslate(desk_pos + new TPoint3(1f, extents.z * 4f + 0.75f, 0.5f));
            transform.MultLocal(ref mat);
            mat = TMatrix4x4.MatrixScale(new TPoint3(2f, 2f, 2f));
            transform.MultLocal(ref mat);
            mat = TMatrix4x4.MatrixRotate(-90f, new TPoint3(1f, 0f, 0f));
            transform.MultLocal(ref mat);

            transform.Push();
            mat = TMatrix4x4.MatrixTranslate(new TPoint3(0f, 0f, 0.125f));
            transform.MultLocal(ref mat);
            mat = TMatrix4x4.MatrixScale(new TPoint3(0.7f, 0.7f, 0.7f));
            transform.MultLocal(ref mat);
            mat = transform.Top;
            pRender3D.SetMatrix(ref mat);
            pModelChurch.Draw();
            transform.Pop();

            mat = transform.Top;
            pRender3D.SetMatrix(ref mat);
            pSnowGlobe.Draw();

            transform.Pop();
        }
예제 #19
0
        void Init(IntPtr pParam)
        {
            IEngineSubSystem pSubSys;

            pEngineCore.GetSubSystem(E_ENGINE_SUB_SYSTEM.ESS_RENDER, out pSubSys);
            pRender = (IRender)pSubSys;
            TColor4 c = TColor4.ColorOfficialBlack();

            pRender.SetClearColor(ref c);
            pRender.GetRender2D(out pRender2D);

            IResourceManager pResMan;

            pEngineCore.GetSubSystem(E_ENGINE_SUB_SYSTEM.ESS_RESOURCE_MANAGER, out pSubSys);
            pResMan = (IResourceManager)pSubSys;

            IEngineBaseObject pBaseObj = null;

            // for fonts part
            pResMan.Load(ResPath + "fonts\\Times_New_Roman_12_rus.dft", out pBaseObj, 0);
            pFont = (IBitmapFont)pBaseObj;
            pResMan.Load(ResPath + "fonts\\Times_New_Roman_18_Bold.dft", out pBaseObj, 0);
            pFontBold = (IBitmapFont)pBaseObj;
            pResMan.Load(ResPath + "fonts\\TheHard_18.dft", out pBaseObj, 0);
            pFontHard = (IBitmapFont)pBaseObj;

            // for sprites part
            const uint unfiltered_2d_flag = (uint)(E_TEXTURE_LOAD_FLAGS.TLF_FILTERING_NONE /* for cool old-school pixelized image */ |
                                                   E_TEXTURE_LOAD_FLAGS.TLF_COORDS_CLAMP);

            pResMan.Load(ResPath + "textures\\cartoon_grass.tga", out pBaseObj, unfiltered_2d_flag |
                         (uint)E_TEXTURE_LOAD_FLAGS.TLF_DECREASE_QUALITY_MEDIUM /* decrease texture size to make it more pixelized */);
            pTexGrass = (ITexture)pBaseObj;
            pResMan.Load(ResPath + "sprites\\cartoon_tank_body.png", out pBaseObj, unfiltered_2d_flag);
            pTexTankBody = (ITexture)pBaseObj;
            pResMan.Load(ResPath + "sprites\\cartoon_tank_turret.png", out pBaseObj, unfiltered_2d_flag);
            pTexTankTurret = (ITexture)pBaseObj;
            pResMan.Load(ResPath + "sprites\\cartoon_anime_girl.png", out pBaseObj, unfiltered_2d_flag);
            pTexGirl = (ITexture)pBaseObj;
            pResMan.Load(ResPath + "sprites\\cartoon_mistery_light.jpg", out pBaseObj, unfiltered_2d_flag |
                         (uint)E_TEXTURE_LOAD_FLAGS.TLF_DECREASE_QUALITY_HIGH);
            pTexLight = (ITexture)pBaseObj;

            pTexGirl.SetFrameSize(55, 117);
            pTexLight.SetFrameSize(64, 128);

            // for advanced part
            pResMan.Load(ResPath + "meshes\\planets\\asteroid.jpg", out pBaseObj, (uint)(E_TEXTURE_LOAD_FLAGS.TLF_FILTERING_BILINEAR |
                                                                                         E_TEXTURE_LOAD_FLAGS.TLF_COORDS_MIRROR_REPEAT));
            pTexPlanet = (ITexture)pBaseObj;
            pResMan.Load(ResPath + "sprites\\light.jpg", out pBaseObj, 0);
            pTexLightRound = (ITexture)pBaseObj;
            pResMan.Load(ResPath + "sprites\\sphere_mask.png", out pBaseObj, 0);
            pTexMask = (ITexture)pBaseObj;
            pResMan.Load(ResPath + "sprites\\cartoon_cloudy_night_sky.jpg", out pBaseObj, 0);
            pTexBg = (ITexture)pBaseObj;
            pResMan.Load(ResPath + "sprites\\jellyfish.png", out pBaseObj, 0);
            pTexJellyFish = (ITexture)pBaseObj;

            for (int i = 0; i < 11; i++)
            {
                pResMan.Load(ResPath + "textures\\water\\water_" + i + ".tga", out pBaseObj, (uint)(E_TEXTURE_LOAD_FLAGS.TLF_FILTERING_BILINEAR |
                                                                                                    E_TEXTURE_LOAD_FLAGS.TLF_COORDS_MIRROR_REPEAT /* let's repeat the texture this way to make it little weird */));
                pTexAnimWater[i] = (ITexture)pBaseObj;
            }

            pResMan.CreateTexture(out pTexPlanetRenderIn, null, 256, 256, E_TEXTURE_DATA_FORMAT.TDF_RGBA8,
                                  E_TEXTURE_CREATE_FLAGS.TCF_DEFAULT, E_TEXTURE_LOAD_FLAGS.TLF_FILTERING_BILINEAR |
                                  E_TEXTURE_LOAD_FLAGS.TLF_COORDS_CLAMP);
        }
예제 #20
0
        void Render(IntPtr pParameter)
        {
            TRectF  sectionRect;
            uint    txt_w, txt_h;
            TColor4 white = TColor4.ColorWhite();;

            pRender2D.Begin2D();

            // First section with primitives. //
            sectionRect = new TRectF(0f, 0f, ScreenWidth / 2f, ScreenHeight / 2f);
            pRender.EnableScissor(ref sectionRect); // here and below scissor test is used to prevent drawing something to another section of the screen

            DrawPrimitives(sectionRect);
            pRender2D.DrawRectangle(ref sectionRect, ref white);

            const string txtSec1 = "Primitives";

            pFont.GetTextDimensions(txtSec1, out txt_w, out txt_h);
            // here and below draw section label near the end of each section
            pFont.Draw2DSimple((int)((ScreenWidth / 2 - txt_w) / 2), (int)(ScreenHeight / 2 - txt_h), txtSec1, ref white);

            // Second section with font rendering. //
            sectionRect = new TRectF(ScreenWidth / 2f, 0f, ScreenWidth / 2f, ScreenHeight / 2f);
            pRender.EnableScissor(ref sectionRect);

            DrawFont(sectionRect);
            pRender2D.DrawRectangle(ref sectionRect, ref white);

            const string txtSec2 = "Fonts";

            pFont.GetTextDimensions(txtSec2, out txt_w, out txt_h);
            pFont.Draw2DSimple((int)(ScreenWidth / 2 + (ScreenWidth / 2 - txt_w) / 2),
                               (int)(ScreenHeight / 2 - txt_h), txtSec2, ref white);

            // Third section with sprites. //
            sectionRect = new TRectF(0f, ScreenHeight / 2f, ScreenWidth / 2f, ScreenHeight / 2f);
            pRender.EnableScissor(ref sectionRect);

            DrawSprites(sectionRect);
            pRender2D.DrawRectangle(ref sectionRect, ref white);

            const string txtSec3 = "Sprites";

            pFont.GetTextDimensions(txtSec3, out txt_w, out txt_h);
            pFont.Draw2DSimple((int)((ScreenWidth / 2 - txt_w) / 2f), (int)(ScreenHeight - txt_h - 25), txtSec3, ref white);

            // Fourth section with advanced techniques. //
            sectionRect = new TRectF(ScreenWidth / 2f, ScreenHeight / 2f, ScreenWidth / 2f, ScreenHeight / 2f);
            pRender.EnableScissor(ref sectionRect);

            DrawAdvanced(sectionRect);
            pRender2D.DrawRectangle(ref sectionRect, ref white);

            const string txtSec4 = "Advanced";

            pFont.GetTextDimensions(txtSec4, out txt_w, out txt_h);
            pFont.Draw2DSimple((int)(ScreenWidth / 2 + (ScreenWidth / 2 - txt_w) / 2f), (int)(ScreenHeight - txt_h - 25), txtSec4, ref white);

            pRender.DisableScissor(); // The way to turn off scissor test, you must do it manually before the end of the frame.

            pRender2D.End2D();
        }
예제 #21
0
파일: Program.cs 프로젝트: yunatoomi/DGLE
        void Init(IntPtr pParam)
        {
            TMatrix4x4 mat = TMatrix4x4.MatrixIdentity;

            transform = new TTransformStack(ref mat);
            rand      = new Random();

            IEngineSubSystem p_sub_sys = null;

            IResourceManager p_res_man = null;

            pEngineCore.GetSubSystem(E_ENGINE_SUB_SYSTEM.ESS_RESOURCE_MANAGER, out p_sub_sys);
            p_res_man = (IResourceManager)p_sub_sys;

            pEngineCore.GetSubSystem(E_ENGINE_SUB_SYSTEM.ESS_RENDER, out p_sub_sys);
            p_render = (IRender)p_sub_sys;
            p_render.GetRender3D(out pRender3D);
            IEngineBaseObject p_obj = null;

            p_res_man.Load(RESOURCE_PATH + "textures\\floor.dds", out p_obj, (uint)E_TEXTURE_LOAD_FLAGS.TEXTURE_LOAD_DEFAULT_3D);
            pTexFloor = (ITexture)p_obj;
            p_res_man.Load(RESOURCE_PATH + "sprites\\light.jpg", out p_obj, (uint)E_TEXTURE_LOAD_FLAGS.TEXTURE_LOAD_DEFAULT_2D);
            pTexLight = (ITexture)p_obj;

            // some global lighting

            pRender3D.ToggleLighting(true);
            TColor4 col = TColor4.ColorBlack();

            pRender3D.SetGlobalAmbientLighting(ref col); // turn off ambient lighting

            // setup lights

            // use single directional light to simulate ambient lighting
            p_res_man.CreateLight(out pLightDirect);
            pLightDirect.SetType(E_LIGHT_TYPE.LT_DIRECTIONAL);
            col = TColor4.ColorGray();
            pLightDirect.SetColor(ref col); // dim light
            TPoint3 p3 = new TPoint3(-0.5f, 0.5f, 0.75f);

            pLightDirect.SetDirection(ref p3);
            pLightDirect.SetEnabled(true);

            // Position is ignored for direction lights but is used by engine for debug drawing.
            // Use "rnd3d_draw_lights 1" console command to debug lights.
            p3 = new TPoint3(0f, 7.5f, 0f);
            pLightDirect.SetPosition(ref p3);

            // create light for the table-lamp
            p_res_man.CreateLight(out pLightSpot);
            pLightSpot.SetType(E_LIGHT_TYPE.LT_SPOT);
            col = TColor4.ColorYellow();
            pLightSpot.SetColor(ref col);
            pLightSpot.SetSpotAngle(100f);
            p3 = new TPoint3(0.15f, 0f, -1f);
            pLightSpot.SetDirection(ref p3);
            pLightSpot.SetEnabled(true);

            // create and setup materials and load models

            ITexture  p_tex;
            IMaterial p_mat;

            // desk
            p_res_man.CreateMaterial(out p_mat);
            p_res_man.Load(RESOURCE_PATH + "meshes\\furniture\\desk\\desk_diff.jpg", out p_obj, (uint)E_TEXTURE_LOAD_FLAGS.TEXTURE_LOAD_DEFAULT_3D);
            p_tex = (ITexture)p_obj;
            p_mat.SetDiffuseTexture(p_tex);
            p_res_man.Load(RESOURCE_PATH + "meshes\\furniture\\desk\\desk.dmd", out p_obj, 0);
            pMdlDesk = (IModel)p_obj;
            pMdlDesk.SetModelMaterial(p_mat);

            // table-lamp
            p_res_man.CreateMaterial(out p_mat);
            p_res_man.Load(RESOURCE_PATH + "meshes\\furniture\\table_lamp\\lamp_diff.jpg", out p_obj, (uint)E_TEXTURE_LOAD_FLAGS.TEXTURE_LOAD_DEFAULT_3D);
            p_tex = (ITexture)p_obj;
            p_mat.SetDiffuseTexture(p_tex);
            p_res_man.Load(RESOURCE_PATH + "meshes\\furniture\\table_lamp\\lamp.dmd", out p_obj, 0);
            pMdlLamp = (IModel)p_obj;
            pMdlLamp.SetModelMaterial(p_mat);

            // chair
            p_res_man.CreateMaterial(out p_mat);
            p_res_man.Load(RESOURCE_PATH + "meshes\\furniture\\chair\\chair_diff.jpg", out p_obj, (uint)E_TEXTURE_LOAD_FLAGS.TEXTURE_LOAD_DEFAULT_3D);
            p_tex = (ITexture)p_obj;
            p_mat.SetDiffuseTexture(p_tex);
            p_res_man.Load(RESOURCE_PATH + "meshes\\furniture\\chair\\chair.dmd", out p_obj, 0);
            pMdlChair = (IModel)p_obj;
            pMdlChair.SetModelMaterial(p_mat);

            // music box
            p_res_man.CreateMaterial(out p_mat);
            p_res_man.Load(RESOURCE_PATH + "meshes\\furniture\\music_box\\mbox_d.dds", out p_obj, (uint)E_TEXTURE_LOAD_FLAGS.TEXTURE_LOAD_DEFAULT_3D);
            p_tex = (ITexture)p_obj;
            p_mat.SetDiffuseTexture(p_tex);
            p_res_man.Load(RESOURCE_PATH + "meshes\\furniture\\music_box\\music_box.dmd", out p_obj, 0);
            pMdlMusicBox = (IModel)p_obj;
            pMdlMusicBox.SetModelMaterial(p_mat);

            // church
            p_res_man.Load(RESOURCE_PATH + "meshes\\church\\church.dmd", out p_obj, 0);
            pModelChurch = (IModel)p_obj;
            pModelChurch.SetModelMaterial(p_mat);

            p_res_man.CreateMaterial(out p_mat);
            col = TColor4.ColorSilver();
            p_mat.SetDiffuseColor(ref col);
            col = TColor4.ColorWhite();
            p_mat.SetSpecularColor(ref col);
            p_mat.SetShininess(25f);
            pModelChurch.SetMeshMaterial(0, p_mat);

            p_res_man.CreateMaterial(out p_mat);
            p_res_man.Load(RESOURCE_PATH + "meshes\\church\\church_roof.jpg", out p_obj, (uint)E_TEXTURE_LOAD_FLAGS.TEXTURE_LOAD_DEFAULT_3D);
            p_tex = (ITexture)p_obj;
            p_mat.SetDiffuseTexture(p_tex);
            pModelChurch.SetMeshMaterial(1, p_mat);

            p_res_man.CreateMaterial(out p_mat);
            p_res_man.Load(RESOURCE_PATH + "meshes\\church\\church_main.jpg", out p_obj, (uint)E_TEXTURE_LOAD_FLAGS.TEXTURE_LOAD_DEFAULT_3D);
            p_tex = (ITexture)p_obj;
            p_mat.SetDiffuseTexture(p_tex);
            pModelChurch.SetMeshMaterial(2, p_mat);

            // snow globe
            p_res_man.Load(RESOURCE_PATH + "meshes\\snow_globe.dmd", out p_obj, 0);
            pSnowGlobe = (IModel)p_obj;
            p_res_man.CreateMaterial(out p_mat);
            col = TColor4.ColorWhite();
            p_mat.SetDiffuseColor(ref col);
            pSnowGlobe.SetMeshMaterial(0, p_mat);

            p_res_man.CreateMaterial(out p_mat);
            col = TColor4.ColorBrown();
            p_mat.SetDiffuseColor(ref col);
            col = TColor4.ColorWhite();
            p_mat.SetSpecularColor(ref col);
            p_mat.SetShininess(25f);
            pSnowGlobe.SetMeshMaterial(2, p_mat);

            p_res_man.CreateMaterial(out p_mat);
            col = TColor4.ColorWhite(100);
            p_mat.SetDiffuseColor(ref col);
            col = TColor4.ColorWhite();
            p_mat.SetSpecularColor(ref col);
            p_mat.SetShininess(50f);
            p_mat.SetBlending(true, E_BLENDING_EFFECT.BE_NORMAL);

            // When material with blending is set model will sort mesh order for meshes with blending to be the last.
            pSnowGlobe.SetMeshMaterial(1, p_mat);

            // We will use black fog to simulate darkness.
            col = TColor4.ColorBlack();
            pRender3D.SetFogColor(ref col);
            pRender3D.SetLinearFogBounds(12.5f, 20f);
            pRender3D.ToggleFog(true);
        }
예제 #22
0
        void Init(IntPtr pParam)
        {
            // get subsystems

            pEngineCore.GetSubSystem(E_ENGINE_SUB_SYSTEM.ESS_RESOURCE_MANAGER, out p_sub_sys);
            pResMan = (IResourceManager)p_sub_sys;

            pEngineCore.GetSubSystem(E_ENGINE_SUB_SYSTEM.ESS_INPUT, out p_sub_sys);
            pInput = (IInput)p_sub_sys;
            pEngineCore.GetSubSystem(E_ENGINE_SUB_SYSTEM.ESS_RENDER, out p_sub_sys);
            pRender = (IRender)p_sub_sys;
            pRender.GetRender2D(out pRender2D);

            // create arrays
            IEngineBaseObject pObj = null;

            pTextures = new ITexture[TexCount];
            pShadows  = new ITexture[ShadowCount];
            pMeshes   = new IMesh[MeshCount];

            // loading data
            pResMan.Load(RESOURCE_PATH + "sounds\\helicopter.wav", out pObj, 0);
            pSound = (ISoundSample)pObj;
            pSound.PlayEx(out pSoundChannel, E_SOUND_SAMPLE_PARAMS.SSP_LOOPED);

            for (int i = 0; i < TexCount; i++)
            {
                uint flags = TexNames[i].Contains("grass") ? (uint)(E_TEXTURE_LOAD_FLAGS.TLF_FILTERING_BILINEAR | E_TEXTURE_LOAD_FLAGS.TLF_COORDS_REPEAT) : (uint)E_TEXTURE_LOAD_FLAGS.TEXTURE_LOAD_DEFAULT_2D;
                pResMan.Load(RESOURCE_PATH + TexNames[i], out pObj, flags);
                pTextures[i] = (ITexture)pObj;
            }

            pTextures[6].SetFrameSize(256, 256); // zombie sprite splitting

            for (int i = 0; i < MeshCount; i++)
            {
                pResMan.Load(RESOURCE_PATH + MeshNames[i], out pObj, (uint)E_MESH_MODEL_LOAD_FLAGS.MMLF_FORCE_MODEL_TO_MESH);
                pMeshes[i] = (IMesh)pObj;
            }

            // render shadows
            for (int i = 0; i < MeshCount; i++)
            {
                RenderMeshToTexture(out pShadows[i], pMeshes[i], pTextures[i]);
            }

            // render rotor shadow
            pResMan.CreateTexture(out pShadows[5], null, 256, 256, E_TEXTURE_DATA_FORMAT.TDF_RGBA8, E_TEXTURE_CREATION_FLAGS.TCF_DEFAULT, E_TEXTURE_LOAD_FLAGS.TLF_FILTERING_BILINEAR);
            pRender.SetRenderTarget(pShadows[5]);
            TPoint2 coords = new TPoint2(128f, 128f);
            TColor4 col    = TColor4.ColorWhite();

            pRender2D.DrawCircle(ref coords, 100, 64, ref col, E_PRIMITIVE2D_FLAGS.PF_FILL);
            pRender.SetRenderTarget(null);


            // gather, fill and init 3d-objects data
            MyMeshes = new MyMesh[8]
            {
                new MyMesh(pMeshes[0], pTextures[0], pShadows[0], new TPoint2(900f, 500f), new TPoint3(400f, 400f, 500f), 225),
                new MyMesh(pMeshes[0], pTextures[0], pShadows[0], new TPoint2(-250f, 300f), new TPoint3(400f, 400f, 500f), 225),
                new MyMesh(pMeshes[0], pTextures[0], pShadows[0], new TPoint2(800f, 200f), new TPoint3(400f, 400f, 400f), 225),
                new MyMesh(pMeshes[1], pTextures[1], pShadows[1], new TPoint2(0f, 450f), new TPoint3(300f, 300f, 400f), 175),
                new MyMesh(pMeshes[1], pTextures[1], pShadows[1], new TPoint2(50f, 750f), new TPoint3(300f, 300f, 300f), 175),
                new MyMesh(pMeshes[2], pTextures[2], pShadows[2], new TPoint2(500f, 150f), new TPoint3(400f, 400f, 500f), 225),
                new MyMesh(pMeshes[3], pTextures[3], pShadows[3], new TPoint2(180f, 150f), new TPoint3(400f, 400f, 600f), 200),
                new MyMesh(pMeshes[3], pTextures[3], pShadows[3], new TPoint2(600f, 550f), new TPoint3(400f, 400f, 600f), 200, 90)
            };

            copter = new Copter(new MyMesh(pMeshes[4], pTextures[4], pShadows[4], new TPoint2(), new TPoint3(600, 600, 600), 200, 0, true), pTextures[5], pShadows[5]);
            zombie = new Zombie(pTextures[6]);
        }
예제 #23
0
        void DrawPrimitives(TRectF screen)
        {
            TColor4 c;
            TRectF  rect;

            rect = new TRectF(5f, 5f, 170f, 170f);
            c    = TColor4.ColorBlue();
            pRender2D.DrawRectangle(ref rect, ref c, E_PRIMITIVE2D_FLAGS.PF_LINE);

            rect = new TRectF(10f, 10f, 160f, 160f);
            c    = TColor4.ColorGray();
            pRender2D.DrawRectangle(ref rect, ref c, E_PRIMITIVE2D_FLAGS.PF_FILL);

            pRender2D.DrawTriangles(null, ref triangles[0], (uint)triangles.Length, E_PRIMITIVE2D_FLAGS.PF_FILL);

            for (int i = 0; i <= 12; i++)
            {
                TPoint2 p = new TPoint2(screen.x, screen.y) + new TPoint2(15f + 12 * i, 15f + 12 * i);
                c = TColor4.ColorTeal();
                pRender2D.DrawPoint(ref p, ref c, (uint)(1 + i));
            }

            for (int i = 0; i < 15; i++)
            {
                pRender2D.SetLineWidth((uint)(1 + i / 2));
                TPoint2 p  = new TPoint2(screen.width - i * 20, screen.height);
                TPoint2 p1 = new TPoint2(screen.width, screen.height - i * 20);
                c = TColor4.ColorOfficialOrange((byte)(255 - i * 17));
                pRender2D.DrawLine(ref p, ref p1, ref c);
            }

            pRender2D.SetLineWidth(2);
            TColor4 c1 = TColor4.ColorAqua(), c2 = TColor4.ColorFuchsia(), c3 = new TColor4(), c4 = new TColor4();

            pRender2D.SetVerticesColors(ref c1, ref c2, ref c3, ref c4); // override per vertex color for the line
            c = new TColor4();
            TPoint2 p2 = new TPoint2(screen.width, 75f);
            TPoint2 p3 = new TPoint2(200f, screen.height);

            pRender2D.DrawLine(ref p2, ref p3, ref c, E_PRIMITIVE2D_FLAGS.PF_VERTICES_COLORS);

            pRender2D.SetLineWidth(1);

            c1 = TColor4.ColorGray();
            c2 = TColor4.ColorMagenta();
            c3 = TColor4.ColorOrange();
            c4 = TColor4.ColorViolet();
            pRender2D.SetVerticesColors(ref c1, ref c2, ref c3, ref c4); // override per vertex color for the rectangle
            rect = new TRectF(250f, 25f, 125f, 125f);
            pRender2D.DrawRectangle(ref rect, ref c, (E_PRIMITIVE2D_FLAGS.PF_LINE | E_PRIMITIVE2D_FLAGS.PF_VERTICES_COLORS));

            c1 = TColor4.ColorBlack(0);
            c2 = TColor4.ColorGreen();
            c3 = TColor4.ColorGreen();
            c4 = TColor4.ColorBlack(0);
            pRender2D.SetVerticesColors(ref c1, ref c2, ref c3, ref c4);
            rect = new TRectF(260f, 35f, 105f, 105f);
            pRender2D.DrawRectangle(ref rect, ref c, (E_PRIMITIVE2D_FLAGS.PF_FILL | E_PRIMITIVE2D_FLAGS.PF_VERTICES_COLORS));

            p2 = new TPoint2(125f, 50f);
            c  = TColor4.ColorOrange();
            pRender2D.DrawCircle(ref p2, 40, 32, ref c, E_PRIMITIVE2D_FLAGS.PF_FILL);

            c = TColor4.ColorWhite();
            for (int i = 0; i < 6; i++)
            {
                pRender2D.DrawCircle(ref p2, (uint)(10 + i * 5), (uint)(4 + i * 2), ref c, E_PRIMITIVE2D_FLAGS.PF_LINE);
            }

            p2 = new TPoint2(200f, 250f);
            p3 = new TPoint2(110f, 34f);
            c  = TColor4.ColorViolet();
            pRender2D.DrawEllipse(ref p2, ref p3, 64, ref c, E_PRIMITIVE2D_FLAGS.PF_FILL);

            pRender2D.SetLineWidth(3);
            p3 = new TPoint2(100f, 30f);
            c  = TColor4.ColorWhite();
            pRender2D.DrawEllipse(ref p2, ref p3, 32, ref c, E_PRIMITIVE2D_FLAGS.PF_LINE);

            p3 = new TPoint2(80f, 24f);
            c  = TColor4.ColorFuchsia();
            pRender2D.DrawEllipse(ref p2, ref p3, 8, ref c, E_PRIMITIVE2D_FLAGS.PF_FILL);

            p3 = new TPoint2(30f, 75f);
            c  = TColor4.ColorOrange(100);
            pRender2D.DrawEllipse(ref p2, ref p3, 64, ref c, E_PRIMITIVE2D_FLAGS.PF_FILL);

            pRender2D.DrawPolygon(null, ref star_polygon[0], (uint)triangles.Length, E_PRIMITIVE2D_FLAGS.PF_FILL);
        }
예제 #24
0
파일: Program.cs 프로젝트: whztt07/DGLE
        void DrawPrimitives(TRectF screen)
        {
            TColor4 c;
            TRectF rect;

            rect = new TRectF(5f, 5f, 170f, 170f);
            c = TColor4.ColorBlue();
            pRender2D.DrawRectangle(ref rect, ref c, E_PRIMITIVE2D_FLAGS.PF_LINE);

            rect = new TRectF(10f, 10f, 160f, 160f);
            c = TColor4.ColorGray();
            pRender2D.DrawRectangle(ref rect, ref c, E_PRIMITIVE2D_FLAGS.PF_FILL);

            pRender2D.DrawTriangles(null, ref triangles[0], (uint)triangles.Length, E_PRIMITIVE2D_FLAGS.PF_FILL);

            for (int i = 0; i <= 12; i++)
            {
                TPoint2 p = new TPoint2(screen.x, screen.y) + new TPoint2(15f + 12 * i, 15f + 12 * i);
                c = TColor4.ColorTeal();
                pRender2D.DrawPoint(ref p, ref c, (uint)(1 + i));
            }

            for (int i = 0; i < 15; i++)
            {
                pRender2D.SetLineWidth((uint)(1 + i / 2));
                TPoint2 p = new TPoint2(screen.width - i * 20, screen.height);
                TPoint2 p1 = new TPoint2(screen.width, screen.height - i * 20);
                c = TColor4.ColorOfficialOrange((byte)(255 - i * 17));
                pRender2D.DrawLine(ref p, ref p1, ref c);
            }

            pRender2D.SetLineWidth(2);
            TColor4 c1 = TColor4.ColorAqua(), c2 = TColor4.ColorFuchsia(), c3 = new TColor4(), c4 = new TColor4();
            pRender2D.SetVerticesColors(ref c1, ref c2, ref c3, ref c4); // override per vertex color for the line
            c = new TColor4();
            TPoint2 p2 = new TPoint2(screen.width, 75f);
            TPoint2 p3 = new TPoint2(200f, screen.height);
            pRender2D.DrawLine(ref p2, ref p3, ref c, E_PRIMITIVE2D_FLAGS.PF_VERTICES_COLORS);

            pRender2D.SetLineWidth(1);

            c1 = TColor4.ColorGray();
            c2 = TColor4.ColorMagenta();
            c3 = TColor4.ColorOrange();
            c4 = TColor4.ColorViolet();
            pRender2D.SetVerticesColors(ref c1, ref c2, ref c3, ref c4); // override per vertex color for the rectangle
            rect = new TRectF(250f, 25f, 125f, 125f);
            pRender2D.DrawRectangle(ref rect, ref c, (E_PRIMITIVE2D_FLAGS.PF_LINE | E_PRIMITIVE2D_FLAGS.PF_VERTICES_COLORS));

            c1 = TColor4.ColorBlack(0);
            c2 = TColor4.ColorGreen();
            c3 = TColor4.ColorGreen();
            c4 = TColor4.ColorBlack(0);
            pRender2D.SetVerticesColors(ref c1, ref c2, ref c3, ref c4);
            rect = new TRectF(260f, 35f, 105f, 105f);
            pRender2D.DrawRectangle(ref rect, ref c, (E_PRIMITIVE2D_FLAGS.PF_FILL | E_PRIMITIVE2D_FLAGS.PF_VERTICES_COLORS));

            p2 = new TPoint2(125f, 50f);
            c = TColor4.ColorOrange();
            pRender2D.DrawCircle(ref p2, 40, 32, ref c, E_PRIMITIVE2D_FLAGS.PF_FILL);

            c = TColor4.ColorWhite();
            for (int i = 0; i < 6; i++)
            {
                pRender2D.DrawCircle(ref p2, (uint)(10 + i * 5), (uint)(4 + i * 2), ref c, E_PRIMITIVE2D_FLAGS.PF_LINE);
            }

            p2 = new TPoint2(200f, 250f);
            p3 = new TPoint2(110f, 34f);
            c = TColor4.ColorViolet();
            pRender2D.DrawEllipse(ref p2, ref p3, 64, ref c, E_PRIMITIVE2D_FLAGS.PF_FILL);

            pRender2D.SetLineWidth(3);
            p3 = new TPoint2(100f, 30f);
            c = TColor4.ColorWhite();
            pRender2D.DrawEllipse(ref p2, ref p3, 32, ref c, E_PRIMITIVE2D_FLAGS.PF_LINE);

            p3 = new TPoint2(80f, 24f);
            c = TColor4.ColorFuchsia();
            pRender2D.DrawEllipse(ref p2, ref p3, 8, ref c, E_PRIMITIVE2D_FLAGS.PF_FILL);

            p3 = new TPoint2(30f, 75f);
            c = TColor4.ColorOrange(100);
            pRender2D.DrawEllipse(ref p2, ref p3, 64, ref c, E_PRIMITIVE2D_FLAGS.PF_FILL);

            pRender2D.DrawPolygon(null, ref star_polygon[0], (uint)triangles.Length, E_PRIMITIVE2D_FLAGS.PF_FILL);
        }
예제 #25
0
파일: Program.cs 프로젝트: whztt07/DGLE
        void Update(IntPtr pParameter)
        {
            // render into the texture for advanced example part
            RenderPlanetInToTexture();

            // create water polygon for advanced example part
            TRectF section_adv_rect = new TRectF(ScreenWidth / 2f, ScreenHeight / 2f,
                ScreenWidth / 2f, ScreenHeight / 2f);
            float bottom_y = section_adv_rect.y + section_adv_rect.height;
            float right_x = section_adv_rect.x + section_adv_rect.width;
            float texture_coord_koeff = 75f;

            waterWaves.Clear();
            waterWaves.Add(new TVertex2((int)section_adv_rect.x, (int)bottom_y,
                (int)(section_adv_rect.x / texture_coord_koeff), (int)(bottom_y / texture_coord_koeff),
                (int)0.274f, (int)0.863f, (int)0.863f, (int)1f));

            for (int i = 0; i < 33; ++i)
            {
                float x = section_adv_rect.x + i * section_adv_rect.width / 32f,
                y = (float)((section_adv_rect.y + section_adv_rect.height / 2f) + Math.Sin((float)counter / 20f + (float)i * 50f) * 15f);
                waterWaves.Add(new TVertex2(x, y, x / texture_coord_koeff, y / texture_coord_koeff, 0.274f, 0.863f, 0.863f, 1f));
            }

            waterWaves.Add(new TVertex2(right_x, bottom_y, right_x / texture_coord_koeff, bottom_y / texture_coord_koeff, 0.274f, 0.863f, 0.863f, 1f));

            // other stuff
            stRandomCol = new TColor4((byte)(rand.Next(255)), (byte)(rand.Next(255)), (byte)(rand.Next(255)), 255);
            ++counter;
        }
예제 #26
0
파일: Program.cs 프로젝트: whztt07/DGLE
        void Update(IntPtr pParam)
        {
            // We must switch between two textures, because we can't call DrawTexture for texture which is current render target.

            // Firstly rendering previous background texture with new bugs corpses and trails.
            TPoint2 pos = new TPoint2();
            TPoint2 dim;
            TColor4 c;
            uint co = counter % 2;
            pRender.SetRenderTarget(pTexTarget[co]);
            pRender2D.DrawTexture(pTexTarget[co == 1 ? 0 : 1], ref pos, ref ScreenSize, 0,
                E_EFFECT2D_FLAGS.EF_FLIP_VERTICALLY);

            for (int index = 0; index < bugs.Count; index++)
            {
                var bug = bugs[index];
                if (bug.lifes < 0)
                {
                    pSndDeath.Play();

                    pos = bug.pos + new TPoint2(5f, 0f);
                    dim = new TPoint2(42f, 42f);
                    pRender2D.DrawTexture(pTexBugCorpse, ref pos, ref dim, 90f + bug.angle);
                    bugs.RemoveAt(index);
                }
            }

            // Secondly rendering background texture with moving bugs.
            pRender.SetRenderTarget(pTexTarget[2]);
            pos = new TPoint2();
            pRender2D.DrawTexture(pTexTarget[counter % 2], ref pos, ref ScreenSize, 0, E_EFFECT2D_FLAGS.EF_FLIP_VERTICALLY);
            dim = new TPoint2(52f, 42f);

            foreach (var bug in bugs)
            {
                TPoint2 old = bug.pos;

                bug.pos.x += (float)Math.Cos(bug.angle * Math.PI / 180f) * 0.5f;
                bug.pos.y += (float)Math.Sin(bug.angle * Math.PI / 180f) * 0.5f;

                if (bug.pos.x > ScreenWidth || bug.pos.y > ScreenHeight || bug.pos.x < 0f || bug.pos.y < 0f)
                {
                    bug.pos = old;
                    bug.angle = rand.Next(360);
                }

                if (mousePos.DistTo(bug.pos) < 50f)
                {
                    bug.lifes -= 2;
                }
                byte hp = (byte)(bug.lifes > 0 ? (bug.lifes * 2.5 > 256 ? 255: bug.lifes * 2.5) : 0);
                c = new TColor4(255, hp, hp, 255);
                pRender2D.SetColorMix(ref c);
                pRender2D.DrawTextureSprite(pTexBug, ref bug.pos, ref dim, ((uint)(bug.angle + counter / 4) % 8),
                    90f + bug.angle, E_EFFECT2D_FLAGS.EF_BLEND | E_EFFECT2D_FLAGS.EF_COLOR_MIX);
            }

            pRender.SetRenderTarget(null);
            // process user input here
            TMouseStates ms;
            pInput.GetMouseStates(out ms);
            mousePos = new TPoint2(ms.iX, ms.iY);

            bool prsd;
            pInput.GetKey(E_KEYBOARD_KEY_CODES.KEY_ESCAPE, out prsd);
            if (prsd)
            {
                pEngineCore.QuitEngine();
                return;
            }

            pInput.GetKey(E_KEYBOARD_KEY_CODES.KEY_SPACE, out prsd);
            if (prsd)
            {
                Clear();
                counter = 0;
                return;
            }

            ++counter;
        }
예제 #27
0
        void Render(IntPtr pParam)
        {
            if (pRender2D == null)
            {
                return;
            }

            pRender2D.Begin2D();

            // Draw  sky

            TPoint2 ps = new TPoint2();
            TPoint2 pt = new TPoint2(GAME_VP_WIDTH, GAME_VP_HEIGHT);

            pRender2D.DrawTexture(pSky, ref ps, ref pt, 0, E_EFFECT2D_FLAGS.EF_NONE);

            // Draw background

            ps = new TPoint2(cameraPosition.x / 1.5f, cameraPosition.y / 1.5f);
            pt = new TPoint2(cameraScale, cameraScale);

            pRender2D.SetCamera(ref ps, cameraAngle, ref pt);

            pRender2D.SetBlendMode(E_BLENDING_EFFECT.BE_NORMAL);

            ps = new TPoint2(-200f, 150f);
            pt = new TPoint2(1399f, 517f);
            TRectF rect = new TRectF(0f, 905f, 1399f, 517f);


            pRender2D.DrawTextureCropped(pBg, ref ps, ref pt, ref rect, 0.0f, E_EFFECT2D_FLAGS.EF_BLEND);

            // Draw moving fog on background

            ps = new TPoint2(cameraPosition.x / 1.2f, cameraPosition.y / 1.2f);
            pt = new TPoint2(cameraScale, cameraScale);
            pRender2D.SetCamera(ref ps, cameraAngle, ref pt);

            pRender2D.SetBlendMode(E_BLENDING_EFFECT.BE_ADD);

            // Sometimes it's better to batch a lot of similar objects.

            pRender2D.BeginBatch();

            TColor4 col = new TColor4(255, 255, 255, 64);

            pRender2D.SetColorMix(ref col);

            for (uint i = 0; i < 22; ++i)
            {
                for (uint j = 0; j < 2; ++j)
                {
                    ps = new TPoint2((float)(500f + Math.Sin((float)i) * 600f - Math.Cos((float)counter / 50f) * 10f * (i % 4)),
                                     (float)(475f + Math.Sin((float)j * 2.5f) * 150f - Math.Sin((float)counter / 50f) * 20f * (i % 3)));
                    pt = new TPoint2(250f, 150f);
                    pRender2D.DrawTexture(pFog, ref ps, ref pt, 0f, (E_EFFECT2D_FLAGS.EF_BLEND | E_EFFECT2D_FLAGS.EF_COLOR_MIX));
                }
            }

            pRender2D.EndBatch();

            // Draw foreground scene

            // Setup camera and blending
            pt = new TPoint2(cameraScale, cameraScale);
            pRender2D.SetCamera(ref cameraPosition, cameraAngle, ref pt);

            pRender2D.SetBlendMode(E_BLENDING_EFFECT.BE_NORMAL);

            // Owl
            col = new TColor4(150, 150, 150, 255);
            pRender2D.SetColorMix(ref col); // make sprite little darker

            ps = new TPoint2(owlX, 425f);
            pt = new TPoint2(48f, 128f);
            E_EFFECT2D_FLAGS EEF = (E_EFFECT2D_FLAGS.EF_BLEND | E_EFFECT2D_FLAGS.EF_COLOR_MIX | (owlGoLeft ? E_EFFECT2D_FLAGS.EF_FLIP_HORIZONTALLY : E_EFFECT2D_FLAGS.EF_DEFAULT));

            pRender2D.DrawTextureSprite(pOwl, ref ps, ref pt, (uint)(counter / 3) % 15, 0f, EEF);

            // Draw tree
            ps   = new TPoint2();
            pt   = new TPoint2(1399f, 900f);
            rect = new TRectF(0f, 0f, 1399f, 900f);
            pRender2D.DrawTextureCropped(pBg, ref ps, ref pt, ref rect, 0f, E_EFFECT2D_FLAGS.EF_BLEND);

            // Glowing disc under moving light

            pRender2D.SetBlendMode(E_BLENDING_EFFECT.BE_ADD);

            ps = new TPoint2(-100f, 0f);
            pt = new TPoint2();
            pRender2D.SetVerticesOffsets(ref ps, ref ps, ref pt, ref pt);
            col = new TColor4(65, 59, 193, 255);
            pRender2D.SetColorMix(ref col);
            ps = new TPoint2(lights[0].x - 32f, lights[0].y + 64f);
            pt = new TPoint2(256f, 256f);
            pRender2D.DrawTexture(pLightRound, ref ps, ref pt, 0f, (E_EFFECT2D_FLAGS.EF_VERTICES_OFFSETS | E_EFFECT2D_FLAGS.EF_BLEND | E_EFFECT2D_FLAGS.EF_COLOR_MIX));

            // Girl Shadow

            pRender2D.SetBlendMode(E_BLENDING_EFFECT.BE_NORMAL);
            ps = new TPoint2(-150f + (float)Math.Cos((float)counter / 100f) * 100f, -55f);
            pt = new TPoint2(-50f + (float)Math.Cos((float)counter / 100f) * 100f, -55f);
            TPoint2 pp = new TPoint2(15f, 5f);

            pRender2D.SetVerticesOffsets(ref ps, ref pt, ref pp, ref pp);
            col = new TColor4(0, 0, 0, 128);
            pRender2D.SetColorMix(ref col);
            ps = new TPoint2(550f, 725f);
            pt = new TPoint2(60f, 120f);
            pRender2D.DrawTextureSprite(pTexGirl, ref ps, ref pt, (uint)(counter / 5) % 16, 0f, (E_EFFECT2D_FLAGS.EF_VERTICES_OFFSETS | E_EFFECT2D_FLAGS.EF_BLEND | E_EFFECT2D_FLAGS.EF_COLOR_MIX));

            // Girl Sprite
            pRender2D.DrawTextureSprite(pTexGirl, ref ps, ref pt, (uint)(counter / 5) % 16, 0f, E_EFFECT2D_FLAGS.EF_BLEND);

            // Lights

            pRender2D.SetBlendMode(E_BLENDING_EFFECT.BE_ADD);

            for (uint i = 0; i < 5; ++i)
            {
                ps = new TPoint2(lights[i].x, lights[i].y);
                pt = new TPoint2(64f, 128f);
                pRender2D.DrawTextureSprite(pLight, ref ps, ref pt, (uint)(counter / 2) % 14, 0f, E_EFFECT2D_FLAGS.EF_BLEND);
            }

            pRender2D.ResetCamera();

            // We must calculate correct coordinates in game space because game resolution and screen resolution can be different.
            TPoint2 pos;

            pRender2D.AbsoluteToResolutionCorrect(ref stMousePos, out pos);
            ps = new TPoint2(pos.x - 37, pos.y - 37);
            pt = new TPoint2(75f, 75f);
            pRender2D.DrawTextureSprite(pVox, ref ps, ref pt, (uint)(counter / 2) % 16, 0f, E_EFFECT2D_FLAGS.EF_BLEND);

            uint tw, th;

            pFont.GetTextDimensions(HELP_TEXT, out tw, out th);
            col = TColor4.White;
            pFont.Draw2D((float)((GAME_VP_WIDTH - tw) / 2), (float)(GAME_VP_HEIGHT - th), HELP_TEXT, ref col);

            pRender2D.End2D();
        }
예제 #28
0
        void Render(IntPtr pParam)
        {
            // Attention!
            // The main thing you should keep in the mind is that matrix multiplication order should be
            // reversed when passing matrix to pRender3D->SetMatrix or pRender3D->MultMatrix methods.

            // camera setup
            // here and below matrix multiplication order is reversed
            TMatrix4x4 set = TMatrix4x4.MatrixRotate((float)(Math.Sin(uiCounter / 150f) * 65f), new TPoint3(0f, 1f, 0f)) *
                             TMatrix4x4.MatrixRotate(30f, new TPoint3(1f, 0f, 0f)) *
                             TMatrix4x4.MatrixTranslate(new TPoint3(0f, 0f, -2.5f)) *
                             TMatrix4x4.MatrixIdentity;

            pRender3D.SetMatrix(ref set);

            // Draw entire scene.

            // draw tiled grass floor

            // Some low-level things will be shown below, mainly for education purpose.
            // Of course, there is a way to do the same thing without using low-level API.

            pRender3D.PushMatrix(); // save current matrix

            // multiplicates current matrix with given one
            TMatrix4x4 mult = TMatrix4x4.MatrixScale(new TPoint3(8f, 8f, 8f)) *
                              TMatrix4x4.MatrixRotate(-90f, new TPoint3(1f, 0f, 0f));

            pRender3D.MultMatrix(ref mult);

            set = TMatrix4x4.MatrixScale(new TPoint3(8f, 8f, 8f));

            pCoreRenderer.SetMatrix(ref set, E_MATRIX_TYPE.MT_TEXTURE); // a simple way to tile texture

            // Here is the way for instant rendering of any custom geometry.

            pTexGrass.Bind(0); // current texture setup
            pRender3D.Draw(ref desc, E_CORE_RENDERER_DRAW_MODE.CRDM_TRIANGLE_STRIP, 4);

            set = TMatrix4x4.MatrixIdentity;

            pCoreRenderer.SetMatrix(ref set, E_MATRIX_TYPE.MT_TEXTURE); // return texture matrix to its normal state

            pRender3D.PopMatrix();                                      // return previous matrix

            // Ok, that's all with low-level things in this example.

            // turn off backface culling because of trees leaves (they will look better) and sprites rendering (we want txt and owl to be visible from both sides)
            pRender3D.ToggleBackfaceCulling(false);

            // draw some trees

            // turn on alpha test for correct rendering of trees leaves
            pRender3D.ToggleAlphaTest(true);

            // precalculate similar for all trees transformation part to make it faster
            TMatrix4x4 tree_rotate_and_scale = TMatrix4x4.MatrixScale(new TPoint3(2f, 2f, 2f)) *
                                               TMatrix4x4.MatrixRotate(-90f, new TPoint3(1f, 0f, 0f));

            // some copy-pasted code for each tree to draw all of them

            pRender3D.PushMatrix();
            mult = tree_rotate_and_scale * TMatrix4x4.MatrixTranslate(new TPoint3(2.3f, 0f, 1.2f));
            pRender3D.MultMatrix(ref mult);
            pTexTree1.Bind(0); // way to set current texture
            pMeshTree1.Draw();
            pRender3D.PopMatrix();

            pRender3D.PushMatrix();
            mult = tree_rotate_and_scale * TMatrix4x4.MatrixTranslate(new TPoint3(-2.15f, 0f, -1.75f));
            pRender3D.MultMatrix(ref mult);
            pTexTree1.Bind(0);
            pMeshTree1.Draw();
            pRender3D.PopMatrix();

            pRender3D.PushMatrix();
            mult = tree_rotate_and_scale * TMatrix4x4.MatrixTranslate(new TPoint3(-0.5f, 0f, -1f));
            pRender3D.MultMatrix(ref mult);
            pTexTree2.Bind(0);
            pMeshTree2.Draw();
            pRender3D.PopMatrix();

            pRender3D.PushMatrix();
            mult = tree_rotate_and_scale * TMatrix4x4.MatrixTranslate(new TPoint3(0.75f, 0f, 0.1f));
            pRender3D.MultMatrix(ref mult);
            pTexTree2.Bind(0);
            pMeshTree2.Draw();
            pRender3D.PopMatrix();

            pRender3D.PushMatrix();
            mult = tree_rotate_and_scale * TMatrix4x4.MatrixTranslate(new TPoint3(0.5f, 0f, -1.5f));
            pRender3D.MultMatrix(ref mult);
            pTexTree3.Bind(0);
            pMeshTree3.Draw();
            pRender3D.PopMatrix();

            pRender3D.PushMatrix();
            mult = tree_rotate_and_scale * TMatrix4x4.MatrixTranslate(new TPoint3(-0.75f, 0f, 0.25f));
            pRender3D.MultMatrix(ref mult);
            pTexTree3.Bind(0);
            pMeshTree3.Draw();
            pRender3D.PopMatrix();

            pRender3D.ToggleAlphaTest(false); // we don't need alphatest anymore

            // we use blending for further font and sprite rendering
            pRender3D.ToggleBlending(true);

            // draw text
            pRender3D.PushMatrix();

            const string txt       = "The very basics of the 3D graphics.";
            const float  txt_scale = 0.005f;

            uint w, h;

            pFont.GetTextDimensions(txt, out w, out h);

            mult = TMatrix4x4.MatrixScale(new TPoint3(txt_scale, txt_scale, txt_scale)) *
                   // tex is drawing in rather huge coordinates, so we will downscale it
                   TMatrix4x4.MatrixTranslate(new TPoint3(0f, h / 2f * txt_scale, 1.25f));           // move text up on half of it's height and little forward

            pRender3D.MultMatrix(ref mult);

            TColor4 c = TColor4.ColorOfficialOrange();

            pRender3D.SetColor(ref c); // set current color

            pFont.Draw3D(txt);

            c = TColor4.ColorWhite();
            pRender3D.SetColor(ref c); // return color back to white

            pRender3D.PopMatrix();

            // draw owl animated sprite as billboard
            pRender3D.PushMatrix();

            // here is a way to make a billboard sprite in 3D
            TMatrix4x4 cur_matrix = new TMatrix4x4();

            pRender3D.GetMatrix(out cur_matrix); // first we must get current matrix

            // now we set new current matrix
            TMatrix4x4 matr = TMatrix4x4.MatrixScale(new TPoint3((owlGoLeft ? -1f : 1f), 1f, 1f)) *
                                                          // the way to mirror sprite picture
                              TMatrix4x4.MatrixBillboard( // this function will remove any rotation from given matrix
                TMatrix4x4.MatrixScale(new TPoint3(0.35f, 0.35f, 0.35f)) *
                TMatrix4x4.MatrixTranslate(new TPoint3(owlX, 1f, -0.35f)) *
                cur_matrix);

            pRender3D.SetMatrix(ref matr);

            pTexOwl.Draw3D((uiCounter / 2) % 15); // fast way to render texture as square plane with size 1.0

            pRender3D.PopMatrix();

            pRender3D.ToggleBlending(false);
            pRender3D.ToggleBackfaceCulling(true); // turn backface culling back on here

            // draw monster
            pRender3D.PushMatrix();

            TPoint3 extents = new TPoint3();

            pModelZard.GetExtents(out extents); // retrieves dimensions of the model (ex. extents.x is a half of the models width)

            // here we will let monster go circles
            const float speed         = 1.2f;
            float       angle         = uiCounter / 75f;
            TPoint3     circle_center = new TPoint3(1f, 0f, 0.25f);

            mult = TMatrix4x4.MatrixRotate(-90f, new TPoint3(1f, 0f, 0f)) *
                   TMatrix4x4.MatrixRotate(angle * 180f / (float)Math.PI, new TPoint3(0f, -1f, 0f)) *
                   TMatrix4x4.MatrixTranslate(new TPoint3((float)(Math.Cos(angle) * speed), extents.z,
                                                          (float)(Math.Sin(angle) * speed)) + circle_center);

            pRender3D.MultMatrix(ref mult);

            pTexZard.Bind(0);

            // this model uses frame based animation, we just need to switch between meshes
            uint meshes_count;

            pModelZard.MeshsCount(out meshes_count);
            pModelZard.DrawMesh(uiCounter % meshes_count);

            pRender3D.PopMatrix();
        }
예제 #29
0
        void Init(IntPtr pParam)
        {
            IEngineSubSystem p_sub_sys = null;

            IResourceManager p_res_man = null;

            pEngineCore.GetSubSystem(E_ENGINE_SUB_SYSTEM.ESS_RESOURCE_MANAGER, out p_sub_sys);
            p_res_man = (IResourceManager)p_sub_sys;

            IRender p_render = null;

            pEngineCore.GetSubSystem(E_ENGINE_SUB_SYSTEM.ESS_RENDER, out p_sub_sys);
            p_render = (IRender)p_sub_sys;
            p_render.GetRender2D(out pRender2D);

            IEngineBaseObject p_obj = null;

            pEngineCore.GetSubSystem(E_ENGINE_SUB_SYSTEM.ESS_INPUT, out p_sub_sys);
            pInput = (IInput)p_sub_sys;
            pInput.Configure(E_INPUT_CONFIGURATION_FLAGS.ICF_HIDE_CURSOR);

            p_res_man.GetDefaultResource(E_ENGINE_OBJECT_TYPE.EOT_BITMAP_FONT, out p_obj);
            pFont = (IBitmapFont)p_obj;


            // Background clear color setup.
            TColor4 tc = new TColor4(38, 38, 55, 255);

            p_render.SetClearColor(ref tc);

            // This example adapted only for 800X600 resolution, if even resolution will be higher it won't effect it.
            pRender2D.SetResolutionCorrection(GAME_VP_WIDTH, GAME_VP_HEIGHT, true);



            p_res_man.Load(RESOURCE_PATH + "sounds\\owl.wav", out p_obj, 0);
            pSndOwl = (ISoundSample)p_obj;

            p_res_man.Load(RESOURCE_PATH + "sounds\\forest_ambient.wav", out p_obj, 0);
            pForestAmbient = (ISoundSample)p_obj;
            pForestAmbient.PlayEx(out pChannelAmbientLoop, E_SOUND_SAMPLE_PARAMS.SSP_LOOPED);

            p_res_man.Load(RESOURCE_PATH + "sprites\\cartoon_forest_background.png", out p_obj, (uint)E_TEXTURE_LOAD_FLAGS.TEXTURE_LOAD_DEFAULT_2D);
            pBg = (ITexture)p_obj;
            p_res_man.Load(RESOURCE_PATH + "sprites\\cartoon_cloudy_night_sky.jpg", out p_obj, (uint)E_TEXTURE_LOAD_FLAGS.TEXTURE_LOAD_DEFAULT_2D);
            pSky = (ITexture)p_obj;
            p_res_man.Load(RESOURCE_PATH + "textures\\smoke.png", out p_obj, (uint)E_TEXTURE_LOAD_FLAGS.TEXTURE_LOAD_DEFAULT_2D);
            pFog = (ITexture)p_obj;
            p_res_man.Load(RESOURCE_PATH + "textures\\light.jpg", out p_obj, (uint)E_TEXTURE_LOAD_FLAGS.TEXTURE_LOAD_DEFAULT_2D);
            pLightRound = (ITexture)p_obj;

            p_res_man.Load(RESOURCE_PATH + "sprites\\vox.jpg", out p_obj, (uint)E_TEXTURE_LOAD_FLAGS.TEXTURE_LOAD_DEFAULT_2D);
            pVox = (ITexture)p_obj;
            pVox.SetFrameSize(149, 149);

            p_res_man.Load(RESOURCE_PATH + "sprites\\cartoon_owl.png", out p_obj, (uint)E_TEXTURE_LOAD_FLAGS.TEXTURE_LOAD_DEFAULT_2D);
            pOwl = (ITexture)p_obj;
            pOwl.SetFrameSize(48, 128);

            p_res_man.Load(RESOURCE_PATH + "sprites\\cartoon_anime_girl.png", out p_obj, (uint)E_TEXTURE_LOAD_FLAGS.TEXTURE_LOAD_DEFAULT_2D);
            pTexGirl = (ITexture)p_obj;
            pTexGirl.SetFrameSize(55, 117);

            p_res_man.Load(RESOURCE_PATH + "sprites\\cartoon_mistery_light.jpg", out p_obj, (uint)E_TEXTURE_LOAD_FLAGS.TEXTURE_LOAD_DEFAULT_2D);
            pLight = (ITexture)p_obj;
            pLight.SetFrameSize(64, 128);
        }
예제 #30
0
파일: Program.cs 프로젝트: yunatoomi/DGLE
        void Update(IntPtr pParam)
        {
            // We must switch between two textures, because we can't call DrawTexture for texture which is current render target.

            // Firstly rendering previous background texture with new bugs corpses and trails.
            TPoint2 pos = new TPoint2();
            TPoint2 dim;
            TColor4 c;
            uint    co = counter % 2;

            pRender.SetRenderTarget(pTexTarget[co]);
            pRender2D.DrawTexture(pTexTarget[co == 1 ? 0 : 1], ref pos, ref ScreenSize, 0,
                                  E_EFFECT2D_FLAGS.EF_FLIP_VERTICALLY);

            for (int index = 0; index < bugs.Count; index++)
            {
                var bug = bugs[index];
                if (bug.lifes < 0)
                {
                    pSndDeath.Play();

                    pos = bug.pos + new TPoint2(5f, 0f);
                    dim = new TPoint2(42f, 42f);
                    pRender2D.DrawTexture(pTexBugCorpse, ref pos, ref dim, 90f + bug.angle);
                    bugs.RemoveAt(index);
                }
            }

            // Secondly rendering background texture with moving bugs.
            pRender.SetRenderTarget(pTexTarget[2]);
            pos = new TPoint2();
            pRender2D.DrawTexture(pTexTarget[counter % 2], ref pos, ref ScreenSize, 0, E_EFFECT2D_FLAGS.EF_FLIP_VERTICALLY);
            dim = new TPoint2(52f, 42f);

            foreach (var bug in bugs)
            {
                TPoint2 old = bug.pos;

                bug.pos.x += (float)Math.Cos(bug.angle * Math.PI / 180f) * 0.5f;
                bug.pos.y += (float)Math.Sin(bug.angle * Math.PI / 180f) * 0.5f;

                if (bug.pos.x > ScreenWidth || bug.pos.y > ScreenHeight || bug.pos.x < 0f || bug.pos.y < 0f)
                {
                    bug.pos   = old;
                    bug.angle = rand.Next(360);
                }

                if (mousePos.DistTo(bug.pos) < 50f)
                {
                    bug.lifes -= 2;
                }
                byte hp = (byte)(bug.lifes > 0 ? (bug.lifes * 2.5 > 256 ? 255: bug.lifes * 2.5) : 0);
                c = new TColor4(255, hp, hp, 255);
                pRender2D.SetColorMix(ref c);
                pRender2D.DrawTextureSprite(pTexBug, ref bug.pos, ref dim, ((uint)(bug.angle + counter / 4) % 8),
                                            90f + bug.angle, E_EFFECT2D_FLAGS.EF_BLEND | E_EFFECT2D_FLAGS.EF_COLOR_MIX);
            }

            pRender.SetRenderTarget(null);
            // process user input here
            TMouseStates ms;

            pInput.GetMouseStates(out ms);
            mousePos = new TPoint2(ms.iX, ms.iY);

            bool prsd;

            pInput.GetKey(E_KEYBOARD_KEY_CODES.KEY_ESCAPE, out prsd);
            if (prsd)
            {
                pEngineCore.QuitEngine();
                return;
            }

            pInput.GetKey(E_KEYBOARD_KEY_CODES.KEY_SPACE, out prsd);
            if (prsd)
            {
                Clear();
                counter = 0;
                return;
            }

            ++counter;
        }