public Hardware(short width, short height, short depth, bool fullScreen) { screenWidth = width; screenHeight = height; colorDepth = depth; Red = new Sdl.SDL_Color(255, 0, 0); White = new Sdl.SDL_Color(255, 255, 255); TextNums = new IntPtr[10]; TextColon = new IntPtr(); TextComma = new IntPtr(); int flags = Sdl.SDL_HWSURFACE | Sdl.SDL_DOUBLEBUF | Sdl.SDL_ANYFORMAT; if (fullScreen) { flags = flags | Sdl.SDL_FULLSCREEN; } Sdl.SDL_Init(Sdl.SDL_INIT_EVERYTHING); screen = Sdl.SDL_SetVideoMode(screenWidth, screenHeight, colorDepth, flags); Sdl.SDL_Rect rect = new Sdl.SDL_Rect(0, 0, screenWidth, screenHeight); Sdl.SDL_SetClipRect(screen, ref rect); SdlTtf.TTF_Init(); }
static short startX, startY; // For Scroll public static void Init(short w, short h, int colors, bool fullScreen) { width = w; height = h; int flags = Sdl.SDL_HWSURFACE | Sdl.SDL_DOUBLEBUF | Sdl.SDL_ANYFORMAT; if (fullScreen) flags |= Sdl.SDL_FULLSCREEN; Sdl.SDL_Init(Sdl.SDL_INIT_EVERYTHING); hiddenScreen = Sdl.SDL_SetVideoMode( width, height, colors, flags); Sdl.SDL_Rect rect2 = new Sdl.SDL_Rect(0, 0, (short)width, (short)height); Sdl.SDL_SetClipRect(hiddenScreen, ref rect2); SdlTtf.TTF_Init(); // Joystick initialization isThereJoystick = true; if (Sdl.SDL_NumJoysticks() < 1) isThereJoystick = false; if (isThereJoystick) { joystick = Sdl.SDL_JoystickOpen(0); if (joystick == IntPtr.Zero) isThereJoystick = false; } }
/// <summary> /// Initialize Font subsystem. /// </summary> private static void InitializeFontSystem() { if (SdlTtf.TTF_Init() != (int)SdlFlag.Success) { FontException.Generate(); } }
// Operaciones /// Inicializa el modo grafico a un cierto ancho, alto y profundidad de color, p.ej. 640, 480, 24 bits public static void Inicializar(short an, short al, int colores, bool pantallaCompleta) { //System.Console.Write("Inicializando..."); ancho = an; alto = al; int flags = Sdl.SDL_HWSURFACE | Sdl.SDL_DOUBLEBUF | Sdl.SDL_ANYFORMAT; if (pantallaCompleta) { flags |= Sdl.SDL_FULLSCREEN; } Sdl.SDL_Init(Sdl.SDL_INIT_EVERYTHING); pantallaOculta = Sdl.SDL_SetVideoMode( ancho, alto, colores, flags); // Preparamos el rectángulo de la pantalla Sdl.SDL_Rect rect2 = new Sdl.SDL_Rect(0, 0, (short)ancho, (short)alto); Sdl.SDL_SetClipRect(pantallaOculta, ref rect2); // Soporte de tipos de letra TTF SdlTtf.TTF_Init(); // Inicialización del joystick existeJoystick = true; if (Sdl.SDL_NumJoysticks() < 1) { existeJoystick = false; } if (existeJoystick) { joystick = Sdl.SDL_JoystickOpen(0); if (joystick == IntPtr.Zero) { existeJoystick = false; } } // Inicializamos sonidos con SDL mixer if (SdlMixer.Mix_OpenAudio(22050, unchecked (Sdl.AUDIO_S16LSB), 2, 1024) == -1) { ErrorFatal("No se ha podido inicializar el Sonido"); } // Pausa entre clics, para evitar dos clic demasiado cercanos pausaClics = 10; instanteClic = Sdl.SDL_GetTicks(); }
public static void Init(short w, short h, int colorDepth, bool fullScreen) { width = w; height = h; colors = colorDepth; flags = Sdl.SDL_HWSURFACE | Sdl.SDL_DOUBLEBUF | Sdl.SDL_ANYFORMAT; if (fullScreen) { flags |= Sdl.SDL_FULLSCREEN; } Sdl.SDL_Init(Sdl.SDL_INIT_EVERYTHING); hiddenScreen = Sdl.SDL_SetVideoMode( width, height, colors, flags); Sdl.SDL_Rect rect2 = new Sdl.SDL_Rect(0, 0, (short)width, (short)height); Sdl.SDL_SetClipRect(hiddenScreen, ref rect2); SdlTtf.TTF_Init(); // Joystick initialization isThereJoystick = true; if (Sdl.SDL_NumJoysticks() < 1) { isThereJoystick = false; } if (isThereJoystick) { joystick = Sdl.SDL_JoystickOpen(0); if (joystick == IntPtr.Zero) { isThereJoystick = false; } } // Sound initialization SdlMixer.Mix_OpenAudio(22050, (short)SdlMixer.MIX_DEFAULT_FORMAT, 2, 1024); // Time lapse between two consecutive mouse clicks, // so that they are not too near mouseClickLapse = 10; lastMouseClick = Sdl.SDL_GetTicks(); }
static void Init_PreInitialize() { Sdl.SDL_Init(Sdl.SDL_INIT_VIDEO); //Set up the video display SdlTtf.TTF_Init(); //Set up the text rendering screen = Sdl.SDL_SetVideoMode(windowSizeX, windowSizeY, 8, Sdl.SDL_SWSURFACE); //Set up the screen. screenData = (Sdl.SDL_Surface)Marshal.PtrToStructure(screen, typeof(Sdl.SDL_Surface)); //Put the screen data in its place screenArea.w = target.w = (short)screenData.w; //Get width of image screenArea.h = target.h = (short)screenData.h; //Get height of image screenArea.x = 0; //Get all the image screenArea.y = 0; //Get all the image Sdl.SDL_WM_SetCaption("Adventurer", "Adventurer"); } //Stuff that goes before load content
public Hardware(short Width, short Height, short depth, bool fullScreen) { width = Width; height = Height; int flags = Sdl.SDL_HWSURFACE | Sdl.SDL_DOUBLEBUF | Sdl.SDL_ANYFORMAT; if (fullScreen) { flags = flags | Sdl.SDL_FULLSCREEN; } Sdl.SDL_Init(Sdl.SDL_INIT_EVERYTHING); hiddenScreen = Sdl.SDL_SetVideoMode(width, height, depth, flags); Sdl.SDL_Rect rect = new Sdl.SDL_Rect(0, 0, width, height); Sdl.SDL_SetClipRect(hiddenScreen, ref rect); SdlTtf.TTF_Init(); }
internal Dictionary <string, World> worlds; //Dictionary of world-keys to Worlds /** * Constructor. Sets the rootDirectory based on the current build. * Initializes the cache, the scripting engine, freetype, and the world dictionary. * * @param engine the engine */ public ResourceComponent(MirrorEngine engine) : base(engine) { // Set root directory rootDirectory = DEFAULTROOTDIRECTORY; #if ENGINEDEVELOP rootDirectory = DEVELOPROOTPREFIX + rootDirectory; #endif //Initialize cache cache = new Handle[SIZE_OF_CACHE]; cacheLookup = new Dictionary <string, int>(); for (int i = 0; i < SIZE_OF_CACHE; i++) { freeList.AddLast(i); } // Initialize Scripting Engine Dictionary <string, object> opts = new Dictionary <string, object>(); opts["Debug"] = true; ScriptEngine eng = Python.CreateEngine(opts); scriptRuntime = eng.Runtime; // Inject executing C# assembly scriptRuntime.LoadAssembly(Assembly.GetExecutingAssembly()); // Inject game C# assembly scriptRuntime.LoadAssembly(Assembly.GetEntryAssembly()); //Initialize script scopes dictionary scriptScopes = new Dictionary <ScriptScope, string>(); //Initialize Freetype if (SdlTtf.TTF_Init() == -1) { throw new Exception("Could not initialize SDL_ttf"); } //Intialize world Dictionary worlds = new Dictionary <string, World>(); }
public Hardware(short ancho, short alto, short bits, bool pantallaCompleta) { this.ancho = ancho; this.alto = alto; bitsColor = bits; int flags = Sdl.SDL_HWSURFACE | Sdl.SDL_DOUBLEBUF | Sdl.SDL_ANYFORMAT; if (pantallaCompleta) { flags = flags | Sdl.SDL_FULLSCREEN; } Sdl.SDL_Init(Sdl.SDL_INIT_EVERYTHING); pantalla = Sdl.SDL_SetVideoMode(ancho, alto, bitsColor, flags); Sdl.SDL_Rect rect = new Sdl.SDL_Rect(0, 0, ancho, alto); Sdl.SDL_SetClipRect(pantalla, ref rect); SdlTtf.TTF_Init();//texto }
public Hardware(short width, short height, short depth, bool fullScreen) { screenWidth = width; screenHeight = height; colorDepth = depth; int flags = Sdl.SDL_HWSURFACE | Sdl.SDL_DOUBLEBUF | Sdl.SDL_ANYFORMAT; if (fullScreen) { flags = flags | Sdl.SDL_FULLSCREEN; } //Initialization of sdl Joystick Sdl.SDL_Init(Sdl.SDL_INIT_JOYSTICK); // Joystick initialization isThereJoystick = true; if (Sdl.SDL_NumJoysticks() < 1) { isThereJoystick = false; } if (isThereJoystick) { joystick = Sdl.SDL_JoystickOpen(0); if (joystick == IntPtr.Zero) { isThereJoystick = false; } } Sdl.SDL_Init(Sdl.SDL_INIT_EVERYTHING); screen = Sdl.SDL_SetVideoMode(screenWidth, screenHeight, colorDepth, flags); Sdl.SDL_Rect rect = new Sdl.SDL_Rect(0, 0, screenWidth, screenHeight); Sdl.SDL_SetClipRect(screen, ref rect); SdlTtf.TTF_Init(); }
public static void Init(short w, short h, int colors, bool fullScreen) { width = w; height = h; int flags = Sdl.SDL_HWSURFACE | Sdl.SDL_DOUBLEBUF | Sdl.SDL_ANYFORMAT; if (fullScreen) { flags |= Sdl.SDL_FULLSCREEN; } Sdl.SDL_Init(Sdl.SDL_INIT_EVERYTHING); hiddenScreen = Sdl.SDL_SetVideoMode( width, height, colors, flags); Sdl.SDL_Rect rect2 = new Sdl.SDL_Rect(0, 0, (short)width, (short)height); Sdl.SDL_SetClipRect(hiddenScreen, ref rect2); SdlTtf.TTF_Init(); }
private SDLFontv2(string FontPath, int Size, FontStyle Style) { if (!File.Exists(FontPath)) { throw new FileNotFoundException("Could not find font " + FontPath); } this.FontPath = FontPath; if (SdlTtf.TTF_WasInit() != 1) { SdlTtf.TTF_Init(); } this.m_Font = SdlTtf.TTF_OpenFont(this.FontPath, Size); this.FontSize = Size; this.Style = Style; switch (Style) { case FontStyle.Bold: SdlTtf.TTF_SetFontStyle(this.m_Font, SdlTtf.TTF_STYLE_BOLD); break; case FontStyle.Italic: SdlTtf.TTF_SetFontStyle(this.m_Font, SdlTtf.TTF_STYLE_ITALIC); break; case FontStyle.Regular: SdlTtf.TTF_SetFontStyle(this.m_Font, SdlTtf.TTF_STYLE_NORMAL); break; case FontStyle.Underline: SdlTtf.TTF_SetFontStyle(this.m_Font, SdlTtf.TTF_STYLE_UNDERLINE); break; } }
// Operaciones /// Inicializa el modo grafico a un cierto ancho, alto y profundidad de color, p.ej. 640, 480, 24 bits public static void Inicializar(short an, short al, int col, bool pantallaComp) { //System.Console.Write("Inicializando..."); ancho = an; alto = al; colores = col; pantallaCompleta = pantallaComp; flags = (Sdl.SDL_HWSURFACE | Sdl.SDL_DOUBLEBUF | Sdl.SDL_ANYFORMAT); if (pantallaCompleta) { flags |= Sdl.SDL_FULLSCREEN; } Sdl.SDL_Init(Sdl.SDL_INIT_EVERYTHING); pantallaOculta = Sdl.SDL_SetVideoMode( ancho, alto, colores, flags); Sdl.SDL_Rect rect2 = new Sdl.SDL_Rect(0, 0, (short)ancho, (short)alto); Sdl.SDL_SetClipRect(pantallaOculta, ref rect2); // Inicializamos tipos de letra TTF if (SdlTtf.TTF_Init() < 0) { ErrorFatal("No se ha podido inicializar los tipos de letra TTF"); } // Inicializamos sonidos con SDL mixer if (SdlMixer.Mix_OpenAudio(22050, unchecked (Sdl.AUDIO_S16LSB), 2, 1024) == -1) { ErrorFatal("No se ha podido inicializar el Sonido"); } }
public int CreateDevice(int width, int height, int colorDepth, bool fullscreen) { this.width = width; this.height = height; this.colorDepth = colorDepth; this.fullscreen = fullscreen; videoFlags = Sdl.SDL_OPENGL | Sdl.SDL_GL_DOUBLEBUFFER | Sdl.SDL_RESIZABLE | Sdl.SDL_HWPALETTE; if (Sdl.SDL_Init(Sdl.SDL_INIT_VIDEO) < 0) { EngineLog.Get().Error("Error init SDL: " + Sdl.SDL_GetError(), "Graphics"); Sdl.SDL_Quit(); return(-1); } if (-1 == SdlTtf.TTF_Init()) { EngineLog.Get().Error("Error init SDL TTF: " + SdlTtf.TTF_GetError(), "Graphics"); return(-1); } else { EngineLog.Get().Info("SDL TTF initialized", "Graphics"); } if (this.fullscreen) { videoFlags |= Sdl.SDL_FULLSCREEN | Sdl.SDL_ANYFORMAT; EngineLog.Get().Info("Switching to Fullscreen", "Graphics"); } else { EngineLog.Get().Info("Switching to Window", "Graphics"); } IntPtr videoInfoPtr = Sdl.SDL_GetVideoInfo(); if (IntPtr.Zero == videoInfoPtr) { EngineLog.Get().Error("GetVideoInfo failed", "Graphics"); return(1); } Sdl.SDL_VideoInfo videoInfo = (Sdl.SDL_VideoInfo)Marshal.PtrToStructure( videoInfoPtr, typeof(Sdl.SDL_VideoInfo)); // This doesn't work /*if(1 == videoInfo.hw_available) * { * EngineLog.Get().Info("Hardware Surface", "Graphics"); * videoFlags |= Sdl.SDL_HWSURFACE; * } else { * EngineLog.Get().Warn("Software Surface", "Graphics"); * videoFlags |= Sdl.SDL_SWSURFACE; * }*/ videoFlags |= Sdl.SDL_HWSURFACE; if (1 == videoInfo.blit_hw) { EngineLog.Get().Info("Hardware Blitting", "Graphics"); videoFlags |= Sdl.SDL_HWACCEL; } else { EngineLog.Get().Warn("No Hardware Blitting", "Graphics"); } Sdl.SDL_GL_SetAttribute(Sdl.SDL_GL_RED_SIZE, 5); Sdl.SDL_GL_SetAttribute(Sdl.SDL_GL_GREEN_SIZE, 5); Sdl.SDL_GL_SetAttribute(Sdl.SDL_GL_BLUE_SIZE, 5); Sdl.SDL_GL_SetAttribute(Sdl.SDL_GL_DEPTH_SIZE, 16); Sdl.SDL_GL_SetAttribute(Sdl.SDL_GL_DOUBLEBUFFER, 1); sdlSurface = Sdl.SDL_SetVideoMode(width, height, colorDepth, videoFlags); if (0 == sdlSurface.ToInt32()) { EngineLog.Get().Error("Set video mode: " + Sdl.SDL_GetError(), "Graphics"); return(1); } else { EngineLog.Get().Info("Set video mode to " + width + "x" + height + "x" + colorDepth, "Graphics"); } Gl.glShadeModel(Gl.GL_SMOOTH); Gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); Gl.glClearDepth(1.0f); Gl.glEnable(Gl.GL_DEPTH_TEST); Gl.glDepthFunc(Gl.GL_LEQUAL); Gl.glHint(Gl.GL_PERSPECTIVE_CORRECTION_HINT, Gl.GL_NICEST); Gl.glEnable(Gl.GL_TEXTURE_2D); Gl.glEnable(Gl.GL_CULL_FACE); Gl.glCullFace(Gl.GL_BACK); string glVendor = Gl.glGetString(Gl.GL_VENDOR); string glVersion = Gl.glGetString(Gl.GL_VERSION); string glVideoCard = Gl.glGetString(Gl.GL_RENDERER); string glExt = Gl.glGetString(Gl.GL_EXTENSIONS); EngineLog.Get().Info("OpenGL Vendor: " + glVendor, "Graphics"); EngineLog.Get().Info("OpenGL Version " + glVersion, "Graphics"); EngineLog.Get().Info("OpenGL Renderer: " + glVideoCard, "Graphics"); EngineLog.Get().Info("OpenGL Extensions: " + glExt, "Graphics"); if (!Gl.IsExtensionSupported("GL_ARB_multitexture")) { EngineLog.Get().Error("Extension GL_ARB_multitexture not supported!", "Graphics"); return(1); } // New TAO Framwork loads all extensions on startup /*if(false == GlExtensionLoader.LoadExtension("GL_ARB_multitexture")) * { * EngineLog.Get().Error("Load OpenGL Extension: GL_ARB_multitexture", "Graphics"); * return 1; * }*/ isRunning = true; isOrtho = false; fpsTime = Sdl.SDL_GetTicks(); frameTime = Sdl.SDL_GetTicks(); ResizeWindow(width, height); return(0); }