Example #1
0
        private static void generateBuffers()
        {
            if (Chat.fb != null)
            {
                return;
            }
            Chat.fb = new ThreadSafeFrameBuffer();

            Chat.db = new ThreadSafeDepthBuffer(150, 150);
            DisplayManager.getDisplayManager().addThreadSafeDepthBufferToMake(Chat.db);
            while (Chat.db.getDepthBuffer() == null)
            {
                continue;
            }

            Chat.bufferTexture = new LoadableTexture(Chat.db.getWidth(), Chat.db.getHeight());
            bufferTexture.loadNow();

            Chat.fb.setLoadableTextureToBind(Chat.bufferTexture);
            Chat.fb.setThreadSafeDepthBufferToBind(Chat.db);

            DisplayManager.getDisplayManager().addThreadSafeFrameBufferToMake(Chat.fb);
            while (Chat.fb.getFrameBuffer() == null)
            {
                continue;
            }
        }
Example #2
0
 private void updateSprite()
 {
     lock (this) {
         if (this.sprite == null)
         {
             if (this.getTexture() != null)
             {
                 this.sprite = new Sprite(getTexture(), "Button");
                 this.sprite.getMaterial().setColor(this.color);
             }
         }
         else
         {
             this.sprite.getMaterial().setColor(this.color);
             if (getTexture() != null && getTexture() != this.sprite.getTexture())
             {
                 lock (this.getTexture()) {
                     this.sprite.setTexture(getTexture());
                 }
             }
             else if (getTexture() != this.sprite.getTexture())
             {
                 DisplayManager.getDisplayManager().removeModel(this.sprite);
                 this.sprite.getVBO().Dispose();
                 this.sprite.Dispose();
                 this.sprite = null;
             }
         }
     }
 }
Example #3
0
 public void loadNow()
 {
     DisplayManager.getDisplayManager().addTextureToLoad(this);
     while (!this.isLoaded())
     {
         continue;
     }
 }
Example #4
0
        public void renderMesh(DrawMode drawMode)
        {
            if (!this.isOnVBO())
            {
                this.putOnVBO();
            }
            DisplayManager dm = DisplayManager.getDisplayManager();

            dm.getGraphicsContext().DrawArrays(drawMode, 0, this.vertexBuffer.getVertexSize());
        }
Example #5
0
 public override void onGUIHide()
 {
     base.onGUIHide();
     if (this.sprite != null)
     {
         DisplayManager.getDisplayManager().removeModel(this.sprite);
         this.sprite.getVBO().Dispose();
         this.sprite.Dispose();
         this.sprite = null;
     }
 }
Example #6
0
        //Main Thread Method
        public void updateTexture()
        {
            if (Chat.getFrameBuffer(false) == null)
            {
                return;
            }
            if (Chat.getFrameBuffer(false).getFrameBuffer() == null)
            {
                return;
            }
            List <Model> models = new List <Model>();

            Camera talkerCamera = new Camera();

            ChatMessage cm;

            if ((cm = getCurrentMessage()) != null)
            {
                lock (cm) {
                    Talkable talker = cm.getTalker();
                    Model    m      = talker.getModel();
                    talkerCamera.getTarget().set(m.getLocation());
                    talkerCamera.getTarget().addY(1.75);

                    Location j = talkerCamera.getTarget().getAbsoluteLocation();
                    j.addYaw(-23);
                    Location q = j.getRelativeInFacingDirection(3);
                    j.Dispose();
                    //j.addX(-1.25).addY(0).addZ(2.8);
                    talkerCamera.getLocation().set(q);
                    q.Dispose();
                    lock (m) {
                        models.Add(talker.getModel());
                    }
                }
            }

            Color oldSky = DisplayManager.getDisplayManager().getClearColor();

            lock (talkerCamera) {
                DisplayManager.getDisplayManager().setClearColor(Color.RED.clone().setAlpha(0));
                DisplayManager.getDisplayManager().renderToBuffer(Chat.getFrameBuffer().getFrameBuffer(), models, talkerCamera);
                DisplayManager.getDisplayManager().setClearColor(oldSky);
            }
            talkerCamera.Dispose();
        }
Example #7
0
        public override void Dispose()
        {
            base.Dispose();
            if (this.sprite != null)
            {
                DisplayManager.getDisplayManager().removeModel(this.sprite);
                if (this.sprite.getVBO() != null)
                {
                    this.sprite.getVBO().Dispose();
                }
                this.sprite.Dispose();
            }

            up     = null;
            hover  = null;
            down   = null;
            sprite = null;
        }
Example #8
0
 public static DisplayManager getDisplayManager()
 {
     return(DisplayManager.getDisplayManager());
 }
Example #9
0
		public static Camera getCamera() {
			if(DisplayManager.getDisplayManager().getCamera() != null) return DisplayManager.getDisplayManager().getCamera();
			Camera c = new Camera();
			DisplayManager.getDisplayManager().setCamera(c);
			return c;
		}
Example #10
0
		public DisplayManager getDisplayManager() {return DisplayManager.getDisplayManager();}
Example #11
0
        public override void tick()
        {
            base.tick();
            this.updateSprite();

            //Update Location
            if (this.sprite != null)
            {
                lock (this.sprite) {
                    this.sprite.getLocation().set(this.getLocation());
                    if (!this.getGUI().getScene().getModels().Contains(this.sprite))
                    {
                        this.getGUI().getScene().addModel(this.sprite);
                    }
                }
            }

            if (oldData != null && Game.GAME_INSTANCE.getTouchData().Equals(oldData))
            {
                return;
            }
            oldData = Game.GAME_INSTANCE.getTouchData();
            int touching = 0;

            foreach (TouchData td in Game.GAME_INSTANCE.getTouchData())
            {
                float x = td.X;
                float y = td.Y;
                x += 0.5f;
                y += 0.5f;
                x *= (float)DisplayManager.getDisplayManager().getCamera().getWidth();
                y *= (float)DisplayManager.getDisplayManager().getCamera().getHeight();
                Location l = new Location(x, y);

                if (isInButton(l))
                {
                    touching++;
                    if (td.Status.Equals(TouchStatus.Down))
                    {
                        this.onPress(td);
                    }
                    else if (td.Status.Equals(TouchStatus.Move))
                    {
                        this.onHold(td);
                    }
                    else if (td.Status.Equals(TouchStatus.Up))
                    {
                        this.onRelease(td);
                    }
                    else if (td.Status.Equals(TouchStatus.Canceled))
                    {
                        this.onCancelling(td);
                    }
                }
            }

            if (this.isDown && touching < 1)
            {
                this.isDown = false;
                this.updateSprite();
            }
        }