protected override void OnLoad(EventArgs e) { base.OnLoad(e); current_state = 1; initMotionModel(); // StartGraphics Stream stmChecker; Stream stmGround; Stream stmSky; Stream stmWood; Stream stmGrass; try { Assembly a = Assembly.GetExecutingAssembly(); // Para ver los nombres de los recursos incrustados String[] nombres = a.GetManifestResourceNames(); stmChecker = a.GetManifestResourceStream("Jitter_OpenGL.Resources.checkered.png"); stmGround = a.GetManifestResourceStream("Jitter_OpenGL.Resources.ground.png"); stmSky = a.GetManifestResourceStream("Jitter_OpenGL.Resources.sky.png"); stmWood = a.GetManifestResourceStream("Jitter_OpenGL.Resources.wood.png"); stmGrass = a.GetManifestResourceStream("Jitter_OpenGL.Resources.grass.jpeg"); } catch { throw new Exception("Error accessing resources!"); } sky_texture = new Texture(stmSky); texture[(int)DS_TEXTURE_NUMBER.DS_SKY] = sky_texture; // strcpy (s,prefix); // strcat (s,"/ground.ppm"); ground_texture = new Texture(stmGround); texture[(int)DS_TEXTURE_NUMBER.DS_GROUND] = ground_texture; // strcpy (s,prefix); // strcat (s,"/wood.ppm"); wood_texture = new Texture(stmWood); texture[(int)DS_TEXTURE_NUMBER.DS_WOOD] = wood_texture; // strcpy (s,prefix); // strcat (s,"/checkered.ppm"); checkered_texture = new Texture(stmChecker); texture[(int)DS_TEXTURE_NUMBER.DS_CHECKERED] = checkered_texture; grass_texture = new Texture(stmGrass); texture[(int)DS_TEXTURE_NUMBER.DS_GRASS] = grass_texture; ground_texture = grass_texture; }
protected void dsSetupTextures(string texturesPath) { string checkeredName = null; string groundName = null; string skyName = null; string woodName = null; string grassName = null; if(File.Exists(texturesPath + "checkered.png")) checkeredName = texturesPath + "checkered.png"; if (File.Exists(texturesPath + "checkered.jpeg")) checkeredName = texturesPath + "checkered.jpeg"; if (File.Exists(texturesPath + "ground.png")) groundName = texturesPath + "ground.png"; if (File.Exists(texturesPath + "ground.jpeg")) groundName = texturesPath + "ground.jpeg"; if (File.Exists(texturesPath + "sky.png")) skyName = texturesPath + "sky.png"; if (File.Exists(texturesPath + "sky.jpeg")) skyName = texturesPath + "sky.jpeg"; if (File.Exists(texturesPath + "wood.png")) woodName = texturesPath + "wood.png"; if (File.Exists(texturesPath + "wood.jpeg")) woodName = texturesPath + "wood.jpeg"; if (File.Exists(texturesPath + "grass.png")) grassName = texturesPath + "grass.png"; if (File.Exists(texturesPath + "grass.jpeg")) grassName = texturesPath + "grass.jpeg"; if (checkeredName != null) { checkered_texture.finalize(); checkered_texture = new Texture(checkeredName); texture[(int)DS_TEXTURE_NUMBER.DS_CHECKERED] = checkered_texture; } if (groundName != null) { ground_texture.finalize(); ground_texture = new Texture(groundName); texture[(int)DS_TEXTURE_NUMBER.DS_GROUND] = ground_texture; } if (skyName != null) { sky_texture.finalize(); sky_texture = new Texture(skyName); texture[(int)DS_TEXTURE_NUMBER.DS_SKY] = sky_texture; } if (woodName != null) { wood_texture.finalize(); wood_texture = new Texture(woodName); texture[(int)DS_TEXTURE_NUMBER.DS_WOOD] = wood_texture; } if (grassName != null) { grass_texture.finalize(); grass_texture = new Texture(grassName); texture[(int)DS_TEXTURE_NUMBER.DS_GRASS] = grass_texture; } }