Esempio n. 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;
            }
        }
Esempio n. 2
0
        public static Texture2D createTexture(string text, Font font, uint argb)
        {
            int width  = font.GetTextWidth(text, 0, text.Length);
            int height = font.Metrics.Height;

            var image = new Image(ImageMode.Rgba,
                                  new ImageSize(width, height),
                                  new ImageColor(0, 0, 0, 0)
                                  );

            image.DrawText(text,
                           new ImageColor((int)((argb >> 16) & 0xff),
                                          (int)((argb >> 8) & 0xff),
                                          (int)((argb >> 0) & 0xff),
                                          (int)((argb >> 24) & 0xff)),
                           font, new ImagePosition(0, 0)
                           );

            Texture2D texture;

            if (Thread.CurrentThread != Game.GAME_INSTANCE.getMainThread())
            {
                LoadableTexture txt = new LoadableTexture(width, height, image);
                txt.loadNow();
                texture = txt.getTexture();
            }
            else
            {
                texture = new Texture2D(width, height, false, PixelFormat.Rgba);
                texture.SetPixels(0, image.ToBuffer(), 0, 0, width, height);
            }
            image.Dispose();

            return(texture);
        }
Esempio n. 3
0
 public void setTexture(LoadableTexture texture)
 {
     if (!texture.isLoaded())
     {
         return;
     }
     this.texture = texture.getTexture();
 }
Esempio n. 4
0
 public void set(LoadableTexture data)
 {
     this.textureName = data.textureName;
     this.texture     = data.texture;
     this.width       = data.width;
     this.height      = data.height;
     this.image       = data.image;
 }
Esempio n. 5
0
 public void setLoadableTextureToBind(LoadableTexture lt)
 {
     this.texture = lt;
 }
Esempio n. 6
0
        private void load()
        {
            //Load Resource List
            List <Model> modelsToVBO = new List <Model>();

            XmlReader reader = XmlReader.Create(Game.APPLICATION_DIRECTORY + this.thingsToLoad);

            while (reader.Read())
            {
                if (reader.Name == null || reader.Name == "" || reader.Name == "xml")
                {
                    continue;
                }
                ResourceType rt = ResourceType.getTypeByXMLValue(reader.Name);
                if (rt == null)
                {
                    continue;
                }

                String name = reader["name"];
                String file = reader["file"];

                //Load File Depending on Type
                Object data = null;
                if (rt.Equals(ResourceType.LANGUAGE))
                {
                    data = LanguageLoader.getLoader().loadLanguage(XmlReader.Create(RESOURCES_DIRECTORY + file));
                }
                else if (rt.Equals(ResourceType.MODEL))
                {
                    List <Model> m = ModelLoader.WAVEFRONT_LOADER.loadModels(FileUtilities.getResourceAsString(RESOURCES_DIRECTORY + file));
                    foreach (Model mod in m)
                    {
                        mod.addToVBOList();
                    }
                    modelsToVBO.AddRange(m);
                    data = m;
                }
                else if (rt.Equals(ResourceType.SCENE))
                {
                    //TODO: Finish
                }
                else if (rt.Equals(ResourceType.ANIMATION))
                {
                    String resource = FileUtilities.getResourceAsString(RESOURCES_DIRECTORY + file);
                    data = AnimationLoader.getLoader().loadAnimationRules(resource);
                }
                else if (rt.Equals(ResourceType.BACKGROUND_MUSIC))
                {
                }
                else if (rt.Equals(ResourceType.TEXTURE))
                {
                    data = new LoadableTexture(RESOURCES_DIRECTORY + file);
                    ((LoadableTexture)data).loadNow();
                }

                if (data == null)
                {
                    GameLogger.getLogger().log("Failed to load " + reader.Name + " (" + reader.Depth + ")");
                    continue;
                }

                if (Game.GAME_INSTANCE.getDebugMode())
                {
                    GameLogger.getLogger().log("Loaded " + rt.getName() + ": " + name + "(" + file + ")");
                }

                Resource res = new Resource(rt, name, file, data);
                this.loadedStuff.Add(res);
            }

            foreach (Model m in modelsToVBO)
            {
                while (!m.isOnVBO())
                {
                    continue;
                }
            }
            this.loaded();
        }
Esempio n. 7
0
		public void addTextureToLoad(LoadableTexture t) {lock(this.texturesToLoad) {this.texturesToLoad.Add(t);}}