コード例 #1
0
 static Texture Make2DTexture(Bitmap bmp, float x1, float y1)
 {
     using ( bmp ) {
         int textureID = GLUtils.LoadTexture(bmp);
         return(new Texture(textureID, x1, y1, bmp.Width, bmp.Height));
     }
 }
コード例 #2
0
ファイル: GuiRenderer.cs プロジェクト: Wandalen/AOEUtils
 static Element Make2DTexture(Bitmap bmp, float x1, float y1, float width, float height)
 {
     using ( bmp ) {
         int textureID = GLUtils.LoadTexture(bmp);
         return(new Element(textureID, x1, y1, width, height));
     }
 }
コード例 #3
0
ファイル: GuiRenderer.cs プロジェクト: Wandalen/AOEUtils
        static TextElement MakeTextElement(string text, float fontSize, int x1, int y1)
        {
            Font  font        = new Font("Times New Roman", fontSize);
            float totalwidth  = 0;
            float totalheight = 0;

            using (Bitmap measuringBmp = new Bitmap(1, 1)) {
                using (Graphics g = Graphics.FromImage(measuringBmp)) {
                    SizeF size = g.MeasureString(text, font);
                    totalwidth  = size.Width;
                    totalheight = size.Height;
                }
            }
            Brush  textBrush = new SolidBrush(Color.White);
            Bitmap bmp       = new Bitmap((int)totalwidth, (int)totalheight);

            using (Graphics g2 = Graphics.FromImage(bmp)) {
                g2.DrawString(text, font, textBrush, 0, 0);
            }
            textBrush.Dispose();
            font.Dispose();
            using ( bmp ) {
                int textureID = GLUtils.LoadTexture(bmp);
                return(new TextElement(textureID, x1, y1, bmp.Width, bmp.Height, text));
            }
        }
コード例 #4
0
 public int Make2DTexture(Bitmap bmp, float x1, float y1, float width, float height)
 {
     using ( bmp ) {
         int     textureID = GLUtils.LoadTexture(bmp);
         Texture texture   = new Texture(textureID, x1, y1, width, height);
         textures.Add(textureID, texture);
         return(textureID);
     }
 }
コード例 #5
0
ファイル: TerrainHelper.cs プロジェクト: Wandalen/AOEUtils
        public static int MakeTerrainTexture()
        {
            // 28 images
            // 4 x 7
            const int horElements = 28;
            const int verElements = 1;

            Console.WriteLine("MAX:" + GLUtils.MaxTextureDimensions);

            Bitmap textureAtlas = new Bitmap(xWidth * horElements, yWidth * verElements);

            using (Graphics g = Graphics.FromImage(textureAtlas)) {
                //DrawPart( g, "5555.png", xWidth * 0, 0 );
                DrawPart(g, "grass1.gif", xWidth * 0, 0);
                DrawPart(g, "watershallow.gif", xWidth * 1, 0);
                DrawPart(g, "beach.gif", xWidth * 2, 0);
                DrawPart(g, "dirt3.gif", xWidth * 3, 0);

                DrawPart(g, "shallows.gif", xWidth * 4, 0);
                DrawPart(g, "leaves.gif", xWidth * 5, 0);
                DrawPart(g, "dirt1.gif", xWidth * 6, 0);
                DrawPart(g, "farm.gif", xWidth * 7, 0);

                DrawPart(g, "deadfarm.gif", xWidth * 8, 0);
                DrawPart(g, "grass3.gif", xWidth * 9, 0);
                DrawPart(g, "dirt2.gif", xWidth * 10, 0);
                DrawPart(g, "grass2.gif", xWidth * 11, 0);

                DrawPart(g, "desert.gif", xWidth * 12, 0);
                DrawPart(g, "deepwater.gif", xWidth * 13, 0);
                DrawPart(g, "mediumwater.gif", xWidth * 14, 0);
                DrawPart(g, "road.gif", xWidth * 15, 0);

                DrawPart(g, "roadbroken.gif", xWidth * 16, 0);
                DrawPart(g, "newfarm.gif", xWidth * 17, 0);
                DrawPart(g, "farmsmallplants.gif", xWidth * 18, 0);
                DrawPart(g, "farmlargeplants.gif", xWidth * 19, 0);

                DrawPart(g, "snow.gif", xWidth * 20, 0);
                DrawPart(g, "snowdirt.gif", xWidth * 21, 0);
                DrawPart(g, "snowgrass.gif", xWidth * 22, 0);
                DrawPart(g, "ice.gif", xWidth * 23, 0);

                DrawPart(g, "snowroad.gif", xWidth * 24, 0);
                DrawPart(g, "roadfungus.gif", xWidth * 25, 0);

                //DrawPart( g, "shallows.gif", 0, 49 );
                //DrawPart( g, "leaves.gif", 97, 49 );
                //DrawPart( g, "dirt1.gif", 194, 49 );
                //DrawPart( g, "farm.gif", 291, 49 );
            }

            Bitmap bmp = textureAtlas;

            /*for( int i = 0; i < bmp.Width; i++ ) {
             *      for( int j = 0; j < bmp.Height; j++ ) {
             *              if( bmp.GetPixel( i, j ) == Color.FromArgb( 255, 0, 0, 0 ) ) {
             *                      Console.WriteLine( "GGGG" );
             *                      bmp.SetPixel( i, j, Color.FromArgb( 0, 0, 0, 0 ) );
             *              }
             *      }
             * }*/

            AokTerrainLocations = new RectangleF[41];
            //for( int i = 0; i < AokTerrainLocations.Length; i++ ) {
            //	AokTerrainLocations[i] = TextureCoords2d( 0, horElements, verElements );
            //}
            AokTerrainLocations[0]  = TextureCoords2d(0, horElements, verElements);
            AokTerrainLocations[1]  = TextureCoords2d(1, horElements, verElements);
            AokTerrainLocations[2]  = TextureCoords2d(2, horElements, verElements);
            AokTerrainLocations[3]  = TextureCoords2d(3, horElements, verElements);
            AokTerrainLocations[4]  = TextureCoords2d(4, horElements, verElements);
            AokTerrainLocations[5]  = TextureCoords2d(5, horElements, verElements);
            AokTerrainLocations[6]  = TextureCoords2d(6, horElements, verElements);
            AokTerrainLocations[7]  = TextureCoords2d(7, horElements, verElements);
            AokTerrainLocations[8]  = TextureCoords2d(8, horElements, verElements);
            AokTerrainLocations[9]  = TextureCoords2d(9, horElements, verElements);
            AokTerrainLocations[10] = TextureCoords2d(5, horElements, verElements);
            AokTerrainLocations[11] = TextureCoords2d(10, horElements, verElements);
            AokTerrainLocations[12] = TextureCoords2d(11, horElements, verElements);
            AokTerrainLocations[13] = TextureCoords2d(5, horElements, verElements);
            AokTerrainLocations[14] = TextureCoords2d(12, horElements, verElements);
            AokTerrainLocations[15] = TextureCoords2d(14, horElements, verElements);
            AokTerrainLocations[16] = TextureCoords2d(0, horElements, verElements);
            AokTerrainLocations[17] = TextureCoords2d(5, horElements, verElements);
            AokTerrainLocations[18] = TextureCoords2d(5, horElements, verElements);
            AokTerrainLocations[19] = TextureCoords2d(5, horElements, verElements);
            AokTerrainLocations[20] = TextureCoords2d(5, horElements, verElements);
            AokTerrainLocations[21] = TextureCoords2d(22, horElements, verElements);
            AokTerrainLocations[22] = TextureCoords2d(13, horElements, verElements);
            AokTerrainLocations[23] = TextureCoords2d(14, horElements, verElements);
            AokTerrainLocations[24] = TextureCoords2d(15, horElements, verElements);
            AokTerrainLocations[25] = TextureCoords2d(16, horElements, verElements);
            AokTerrainLocations[26] = TextureCoords2d(23, horElements, verElements);
            AokTerrainLocations[27] = TextureCoords2d(10, horElements, verElements);
            AokTerrainLocations[28] = TextureCoords2d(14, horElements, verElements);
            AokTerrainLocations[29] = TextureCoords2d(17, horElements, verElements);
            AokTerrainLocations[30] = TextureCoords2d(18, horElements, verElements);
            AokTerrainLocations[31] = TextureCoords2d(19, horElements, verElements);
            AokTerrainLocations[32] = TextureCoords2d(20, horElements, verElements);
            AokTerrainLocations[33] = TextureCoords2d(21, horElements, verElements);
            AokTerrainLocations[34] = TextureCoords2d(22, horElements, verElements);
            AokTerrainLocations[35] = TextureCoords2d(23, horElements, verElements);
            AokTerrainLocations[36] = TextureCoords2d(21, horElements, verElements);
            AokTerrainLocations[37] = TextureCoords2d(23, horElements, verElements);
            AokTerrainLocations[38] = TextureCoords2d(24, horElements, verElements);
            AokTerrainLocations[39] = TextureCoords2d(25, horElements, verElements);
            AokTerrainLocations[20] = TextureCoords2d(15, horElements, verElements);
            invalidTerrainTexRec    = TextureCoords2d(27, horElements, verElements);

            //Bitmap bmp = new Bitmap( bmpWidth, bmpHeight );
            //using( Graphics g = Graphics.FromImage( bmp ) ) {
            //}
            return(GLUtils.LoadTexture(textureAtlas));
        }