コード例 #1
0
 public static extern IntPtr TTF_RenderUTF8_BlendedNative(IntPtr font, IntPtr text, SDL.SDL_Color fg);
コード例 #2
0
 public SDLSurface RenderGlyph_Shaded(char Ch, SDL.SDL_Color Fg, SDL.SDL_Color Bg)
 {
     return(new SDLSurface(SDL_ttf.TTF_RenderGlyph_Shaded(myPtr, Ch, Fg, Bg)));
 }
コード例 #3
0
ファイル: SDL_ttf.cs プロジェクト: rkhapov/simple3d
 private static extern IntPtr INTERNAL_TTF_RenderUTF8_Solid(
     IntPtr font,
     byte[] text,
     SDL.SDL_Color fg
     );
コード例 #4
0
 public IntPtr RenderUNICODE_SolidPtr(string Text, SDL.SDL_Color Fg)
 {
     return(SDL_ttf.TTF_RenderUNICODE_Solid(myPtr, Text, Fg));
 }
コード例 #5
0
        //Render_UNICODE_Shaded

        public SDLSurface RenderUNICODE_Shaded(string Text, SDL.SDL_Color Fg, SDL.SDL_Color Bg)
        {
            return(new SDLSurface(SDL_ttf.TTF_RenderUNICODE_Shaded(myPtr, Text, Fg, Bg)));
        }
コード例 #6
0
 public static extern IntPtr TTF_RenderGlyph_Shaded(
     IntPtr font,
     ushort ch,
     SDL.SDL_Color fg,
     SDL.SDL_Color bg
     );
コード例 #7
0
 private static extern unsafe IntPtr INTERNAL_TTF_RenderUTF8_Blended_Wrapped(
     IntPtr font,
     byte *text,
     SDL.SDL_Color fg,
     uint wrapped
     );
コード例 #8
0
ファイル: NFont.cs プロジェクト: masonwheeler/SDL2-CS
 public bool load(string filename_ttf, UInt32 pointSize, SDL.SDL_Color color, int style = SDL_ttf.TTF_STYLE_NORMAL)
 {
     SDL_FontCache.FC_ClearFont(font);
     return(SDL_FontCache.FC_LoadFont(font, filename_ttf, (int)pointSize, color, style) != 0);
 }
コード例 #9
0
ファイル: NFont.cs プロジェクト: masonwheeler/SDL2-CS
        public SDL2_GPU.GPU_Rect draw(SDL2_GPU.GPU_Target_PTR dest, float x, float y, ref SDL.SDL_Color color, string formatted_text)
        {
            if (formatted_text == null)
            {
                return(SDL2_GPU.GPU_MakeRect(x, y, 0, 0));
            }

            return(SDL_FontCache.FC_DrawColor(font, dest, x, y, color, formatted_text, __arglist()));
        }
コード例 #10
0
ファイル: NFont.cs プロジェクト: masonwheeler/SDL2-CS
 public NFont(IntPtr ttf, ref SDL.SDL_Color color)
 {
     init();
     load(ttf, color);
 }
コード例 #11
0
ファイル: NFont.cs プロジェクト: masonwheeler/SDL2-CS
 public NFont(string filename_ttf, UInt32 pointSize, ref SDL.SDL_Color color, int style = SDL_ttf.TTF_STYLE_NORMAL)
 {
     init();
     load(filename_ttf, pointSize, color, style);
 }
コード例 #12
0
        static int Main(string[] args)
        {
            SDL.SDL_SetHint(SDL.SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING, "1");
            Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture;
            Thread.CurrentThread.CurrentCulture   = CultureInfo.InvariantCulture;

            //Start up SDL and create window
            var success = init();

            if (success == false)
            {
                Console.WriteLine("Failed to initialize!");
            }
            else
            {
                //Load media
                success = loadMedia();
                if (success == false)
                {
                    Console.WriteLine("Failed to load media!");
                }
                else
                {
                    //Main loop flag
                    bool quit = false;

                    //Event handler
                    SDL.SDL_Event e;

                    //Set text color as black
                    SDL.SDL_Color textColor = new SDL.SDL_Color {
                        a = 255
                    };

                    //The frames per second timer
                    LTimer fpsTimer = new LTimer();

                    //In memory text stream
                    string timeText;

                    //Start counting frames per second
                    int countedFrames = 0;
                    fpsTimer.start();

                    //While application is running
                    while (!quit)
                    {
                        //Handle events on queue
                        while (SDL.SDL_PollEvent(out e) != 0)
                        {
                            //User requests quit
                            if (e.type == SDL.SDL_EventType.SDL_QUIT)
                            {
                                quit = true;
                            }
                        }

                        //Calculate and correct fps
                        float avgFPS = countedFrames / (fpsTimer.getTicks() / 1000f);
                        if (avgFPS > 2000000)
                        {
                            avgFPS = 0;
                        }

                        //Set text to be rendered
                        timeText  = "";
                        timeText += "Average Frames Per Second " + string.Format("{0:.0000}", avgFPS);

                        //Render text
                        if (!gFPSTextTexture.loadFromRenderedText(timeText, textColor))
                        {
                            Console.WriteLine("Unable to render FPS texture!");
                        }

                        //Clear screen
                        SDL.SDL_SetRenderDrawColor(gRenderer, 0xFF, 0xFF, 0xFF, 0xFF);
                        SDL.SDL_RenderClear(gRenderer);

                        //Render textures
                        gFPSTextTexture.render((SCREEN_WIDTH - gFPSTextTexture.getWidth()) / 2, (SCREEN_HEIGHT - gFPSTextTexture.getHeight()) / 2);
                        //gFPSTextTexture.render(50, (SCREEN_HEIGHT - gFPSTextTexture.getHeight()) / 2);

                        //Update screen
                        SDL.SDL_RenderPresent(gRenderer);
                        ++countedFrames;
                    }
                }
            }


            //Free resources and close SDL
            close();

            if (success == false)
            {
                Console.ReadLine();
            }

            return(0);
        }
コード例 #13
0
 public static extern IntPtr TTF_RenderUTF8_Blended_WrappedNative(IntPtr font, IntPtr text, SDL.SDL_Color fg, uint wrapped);
コード例 #14
0
        /* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
        public static IntPtr TTF_RenderUTF8_Blended_Wrapped(IntPtr font, string text, SDL.SDL_Color fg, uint wrapped)
        {
            var textUTF8 = Utf8String.ReusableBufferPtr(text);

            return(TTF_RenderUTF8_Blended_WrappedNative(font, textUTF8, fg, wrapped));
        }
コード例 #15
0
 public static extern unsafe IntPtr INTERNAL_TTF_RenderUTF8_Solid_Wrapped(
     IntPtr font,
     byte *text,
     SDL.SDL_Color fg,
     uint wrapLength
     );
コード例 #16
0
ファイル: NFont.cs プロジェクト: masonwheeler/SDL2-CS
 public void setDefaultColor(ref SDL.SDL_Color color)
 {
     SDL_FontCache.FC_SetDefaultColor(font, color);
 }
コード例 #17
0
 private static extern unsafe IntPtr INTERNAL_TTF_RenderUTF8_Shaded(
     IntPtr font,
     byte *text,
     SDL.SDL_Color fg,
     SDL.SDL_Color bg
     );
コード例 #18
0
ファイル: NFont.cs プロジェクト: masonwheeler/SDL2-CS
 public Effect(ref Scale scale, ref SDL.SDL_Color color)
 {
     alignment = AlignEnum.LEFT; this.scale = scale; use_color = true; this.color = color;
 }
コード例 #19
0
 public static extern IntPtr TTF_RenderText_Blended(
     IntPtr font,
     [In()][MarshalAs(UnmanagedType.LPStr)]
     string text,
     SDL.SDL_Color fg
     );
コード例 #20
0
ファイル: NFont.cs プロジェクト: masonwheeler/SDL2-CS
 public Effect(AlignEnum alignment, ref Scale scale, ref SDL.SDL_Color color)
 {
     this.alignment = alignment; this.scale = scale; use_color = true; this.color = color;
 }
コード例 #21
0
 public static extern IntPtr TTF_RenderGlyph32_Blended(
     IntPtr font,
     uint ch,
     SDL.SDL_Color fg
     );
コード例 #22
0
ファイル: ShipIcon.cs プロジェクト: mqrause/Pulsar4x
        void Wings(int width, int height, int frontWidth, int backWidth, int offsetX, int offsetY)//FTL & guns
        {
            byte r = 84;
            byte g = 84;
            byte b = 84;
            byte a = 255;

            SDL.SDL_Color colour = new SDL.SDL_Color()
            {
                r = r, g = g, b = b, a = a
            };


            PointD p0 = new PointD()
            {
                X = offsetX, Y = (int)(offsetY - height * 0.5)
            };
            PointD p1 = new PointD()
            {
                X = offsetX + frontWidth, Y = (int)(offsetY - height * 0.5)
            };
            PointD p2 = new PointD()
            {
                X = (int)(offsetX + width * 0.5), Y = (int)(offsetY - height * 0.3)
            };
            PointD p3 = new PointD()
            {
                X = (int)(offsetX + width * 0.5), Y = -(int)(offsetY - height * 0.25)
            };
            PointD p4 = new PointD()
            {
                X = offsetX + backWidth, Y = -(int)(offsetY - height * 0.5)
            };
            PointD p5 = new PointD()
            {
                X = offsetX, Y = -(int)(offsetY - height * 0.5)
            };
            PointD p6 = new PointD()
            {
                X = offsetX - backWidth, Y = (int)(offsetY + height * 0.5)
            };
            PointD p7 = new PointD()
            {
                X = (int)(offsetX + -width * 0.5), Y = (int)(offsetY + height * 0.25)
            };
            PointD p8 = new PointD()
            {
                X = (int)(offsetX + -width * 0.5), Y = -(int)(offsetY + height * 0.3)
            };
            PointD p9 = new PointD()
            {
                X = offsetX - frontWidth, Y = -(int)(offsetY + height * 0.5)
            };
            PointD p10 = new PointD()
            {
                X = offsetX, Y = -(int)(offsetY + height * 0.5)
            };
            var shape = new Shape()
            {
                Color = colour, Points = new PointD[] { p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10 }
            };

            Shapes.Add(shape);
        }
コード例 #23
0
        //RenderGlyph_Solid

        public SDLSurface RenderGlyph_Solid(ushort Ch, SDL.SDL_Color Fg)
        {
            return(new SDLSurface(SDL_ttf.TTF_RenderGlyph_Solid(myPtr, Ch, Fg)));
        }
コード例 #24
0
ファイル: CardGame.cs プロジェクト: JavierMCS/UTC-Poker-Club
 public void generateNameSurface(IntPtr font, SDL.SDL_Color color)
 {
     nameSurface = SDL_ttf.TTF_RenderText_Solid(font, name, color);
 }
コード例 #25
0
        public SDLTexture RenderUNICODE_Shaded_Texture(string Text, SDL.SDL_Color Fg, SDL.SDL_Color Bg, IntPtr Renderer)
        {
            IntPtr Result = SDL_ttf.TTF_RenderUNICODE_Shaded(myPtr, Text, Fg, Bg);

            try
            {
                return(new SDLTexture(SDL.SDL_CreateTextureFromSurface(Renderer, Result)));
            }
            finally
            {
                SDL.SDL_FreeSurface(Result);
            }
        }
コード例 #26
0
ファイル: SDLPalette.cs プロジェクト: coruscateor/SDL2-CS-OO
 public void SetPaletteColor(SDL.SDL_Color Color)
 {
     Util.ThrowIfResultIsError(SDL.SDL_SetPaletteColors(myPtr, new SDL.SDL_Color[] { Color }, 0, 1));
 }
コード例 #27
0
        //RenderUTF8_Blended

        public SDLSurface RenderUTF8_Blended(string Text, SDL.SDL_Color Fg)
        {
            return(new SDLSurface(SDL_ttf.TTF_RenderUTF8_Blended(myPtr, Text, Fg)));
        }
コード例 #28
0
        private static void Setup(List <Icon> icons)
        {
            List <Shape> shapes = new List <Shape>();

            PointD[] lpoints1 = new PointD[] {
                new PointD {
                    X = 0, Y = -160
                },
                new PointD {
                    X = 0, Y = 160
                },
            };
            PointD[] lpoints2 = new PointD[] {
                new PointD {
                    X = -25, Y = 0
                },
                new PointD {
                    X = 25, Y = 0
                }
            };
            SDL.SDL_Color lcolor = new SDL.SDL_Color()
            {
                r = 0, g = 255, b = 0, a = 255
            };
            shapes.Add(new Shape()
            {
                Points = lpoints1, Color = lcolor
            });
            shapes.Add(new Shape()
            {
                Points = lpoints2, Color = lcolor
            });
            PositionDB lpos = new PositionDB(new Vector3(0, 0, 0), new Guid());

            icons.Add(new Icon(lpos)
            {
                Shapes = shapes
            });

            for (int i = 0; i < 4; i++)
            {
                PointD[]      points = CreatePrimitiveShapes.CreateArc(50 + 50 * i, 400, 100, 100, 0, 4.71, 160);
                SDL.SDL_Color color  = new SDL.SDL_Color()
                {
                    r = (byte)(i * 60), g = 100, b = 100, a = 255
                };
                Shape shape = new Shape()
                {
                    Points = points, Color = color
                };
                PositionDB pos1 = new PositionDB(new Vector3(0, 0, 0), new Guid());

                icons.Add(new Icon(pos1)
                {
                    Shapes = new List <Shape> {
                        shape
                    }
                });
            }

            /*
             * PositionDB pos2 = new PositionDB(new Vector4(0, -0, 0, 0), new ID());
             * var shape2 = new Shape() { Color = new SDL.SDL_Color() { r = 255, g = 0, b = 0, a = 255 }, Points = CreatePrimitiveShapes.RoundedCylinder(50, 100, 0, 0) };
             * var shapes2 = new List<Shape>() { shape2 };
             *
             * icons.Add(new Icon(pos2) { Shapes = shapes2 });
             */

            PositionDB pos3 = new PositionDB(new Vector3(100, 0, 0), new Guid());

            icons.Add(new ShipIcon(pos3));
        }
コード例 #29
0
ファイル: SDL_ttf.cs プロジェクト: rkhapov/simple3d
 public static extern IntPtr TTF_RenderUNICODE_Solid(
     IntPtr font,
     [In()][MarshalAs(UnmanagedType.LPWStr)]
     string text,
     SDL.SDL_Color fg
     );
コード例 #30
0
        /* IntPtr refers to an SDL_Surface*, font to a TTF_Font* */
        public static IntPtr TTF_RenderUTF8_Shaded(IntPtr font, string text, SDL.SDL_Color fg, SDL.SDL_Color bg)
        {
            var textUTF8 = Utf8String.ReusableBufferPtr(text);

            return(TTF_RenderUTF8_ShadedNative(font, textUTF8, fg, bg));
        }