private void InitializeTextures() { // Init DevIl Il.ilInit(); Ilu.iluInit(); Ilut.ilutInit(); Ilut.ilutRenderer(Ilut.ILUT_OPENGL); // Fonts // _textureManager.LoadTexture("font", "Assets/Textures/Fonts/font.tga"); _textureManager.LoadTexture("title_font", "Assets/Textures/Fonts/title_font_0.tga"); _textureManager.LoadTexture("general_font", "Assets/Textures/Fonts/general_font_0.tga"); // Entities // _textureManager.LoadTexture("player_ship", "Assets/Textures/Entities/spacecraft.png"); _textureManager.LoadTexture("enemy_ship", "Assets/Textures/Entities/ospaceship-main.png"); _textureManager.LoadTexture("boss", "Assets/Textures/Entities/alien_boss_300x300.png"); _textureManager.LoadTexture("enemy_heavy", "Assets/Textures/Entities/alien_spacecraft_200x275.png"); _textureManager.LoadTexture("bullet", "Assets/Textures/Entities/bullet.tga"); // Backgrounds// _textureManager.LoadTexture("background", "Assets/Textures/Backgrounds/background.tga"); _textureManager.LoadTexture("background_layer_1", "Assets/Textures/Backgrounds/background_p.tga"); _textureManager.LoadTexture("background_supernova", "Assets/Textures/Backgrounds/supernova.jpg"); _textureManager.LoadTexture("planet_28", "Assets/Textures/Backgrounds/planet_28.png"); //_textureManager.LoadTexture("background", "Assets/Textures/Backgrounds/space_background.png"); //_textureManager.LoadTexture("background_layer_1", "Assets/Textures/Backgrounds/Starfield.png"); // Animations // _textureManager.LoadTexture("explosion", "Assets/Textures/Animations/explode.tga"); _textureManager.LoadTexture("asteroid", "Assets/Textures/Animations/800x600-asteroid_01_no_moblur.png"); }
public void LoadTexture(string textureId, int ImageType, byte[] imageData, int size = 0) { if (imageData == null) { throw new Exception(textureId + "提供的数据为无效数据"); } int devilId = 0; Il.ilGenImages(1, out devilId); Il.ilBindImage(devilId); //作为使用的纹理 if (!Il.ilLoadL(ImageType, imageData, size)) { System.Diagnostics.Debug.Assert(false, "给予的图像数据存在问题,请核对是否给予正确的图像数组和格式,以及大小"); } //The files we'll be using need to be flipped before passing to OpenGL Ilu.iluFlipImage(); int width = Il.ilGetInteger(Il.IL_IMAGE_WIDTH); int height = Il.ilGetInteger(Il.IL_IMAGE_HEIGHT); int openGLId = Ilut.ilutGLBindTexImage(); System.Diagnostics.Debug.Assert(openGLId != 0); Il.ilDeleteImages(1, ref devilId); try { _textureDatabase.Add(textureId, new Texture(openGLId, width, height)); } catch (Exception e) { string s = e.ToString(); } }
static Image() { Il.ilInit(); Ilu.iluInit(); Il.ilEnable(Il.IL_FILE_OVERWRITE); }
public Form1() { InitializeComponent(); this.simpleOpenGlControl1.InitializeContexts(); Il.ilInit(); //Devil的初始化 Ilu.iluInit(); }
// TODO: Fix this to be like Ogre public override void EncodeToFile(Stream input, string fileName, object codecData) { int imageID; // create and bind a new image Il.ilGenImages(1, out imageID); Il.ilBindImage(imageID); byte[] buffer = new byte[input.Length]; input.Read(buffer, 0, buffer.Length); ImageData data = (ImageData)codecData; ILFormat ilfmt = ILUtil.ConvertToILFormat(data.format); // stuff the data into the image Il.ilTexImage(data.width, data.height, 1, (byte)ilfmt.channels, ilfmt.format, ilfmt.type, buffer); if (data.flip) { // flip the image Ilu.iluFlipImage(); } // save the image to file Il.ilSaveImage(fileName); // delete the image Il.ilDeleteImages(1, ref imageID); }
public Form1() { _fastLoop = new FastLoop(GameLoop); InitializeComponent(); _openGLControl.InitializeContexts(); // Initialize DevIL Il.ilInit(); Ilu.iluInit(); Ilut.ilutInit(); Ilut.ilutRenderer(Ilut.ILUT_OPENGL); // Load textures _textureManager.LoadTexture("font", "font.tga"); if (_fullscreen) { FormBorderStyle = FormBorderStyle.None; WindowState = FormWindowState.Maximized; } else { ClientSize = new Size(1280, 720); } // Initialize states _system.AddState("text_state", new TextTestState(_textureManager)); _system.AddState("text_render_state", new TextRenderState(_textureManager)); _system.AddState("fps_state", new FPSTestState(_textureManager)); _system.ChangeState("fps_state"); }
public void Save(string savename) { int imageID; // create and bind a new image Il.ilGenImages(1, out imageID); Il.ilBindImage(imageID); Il.ilSetString(Il.IL_PNG_AUTHNAME_STRING, "Multiverse Network"); // stuff the data into the image if (bytesPerPixel == 2 && format == Il.IL_LUMINANCE) { // special case for 16 bit greyscale Il.ilTexImage(Width, Height, depth, 1, format, Il.IL_UNSIGNED_SHORT, buffer); } else { Il.ilTexImage(Width, Height, depth, (byte)bytesPerPixel, format, Il.IL_UNSIGNED_BYTE, buffer); } // flip the image so that the mosaics produced match what L3DT produces Ilu.iluFlipImage(); // save the image to file Il.ilEnable(Il.IL_FILE_OVERWRITE); Il.ilSaveImage(savename); // delete the image Il.ilDeleteImages(1, ref imageID); }
public Form1() { _fastLoop = new FastLoop(GameLoop); InitializeComponent(); _openGLControl.InitializeContexts(); // Initialize DevIL Il.ilInit(); Ilu.iluInit(); Ilut.ilutInit(); Ilut.ilutRenderer(Ilut.ILUT_OPENGL); // Load textures _textureManager.LoadTexture("face", "face.tif"); if (_fullscreen) { FormBorderStyle = FormBorderStyle.None; WindowState = FormWindowState.Maximized; } else { ClientSize = new Size(1280, 720); } // Initialize states _system.AddState("splash", new SplashScreenState(_system)); _system.AddState("title_menu", new TitleMenuState()); _system.AddState("sprite_test", new DrawSpriteState(_textureManager)); _system.ChangeState("sprite_test"); }
private void LoadTexture(string filename, uint texture) { if (Il.ilLoadImage(filename)) //載入影像檔 { int BitsPerPixel = Il.ilGetInteger(Il.IL_IMAGE_BITS_PER_PIXEL); //取得儲存每個像素的位元數 int Depth = Il.ilGetInteger(Il.IL_IMAGE_DEPTH); //取得影像的深度值 Ilu.iluScale(512, 512, Depth); //將影像大小縮放為2的指數次方 Ilu.iluFlipImage(); //顛倒影像 Gl.glBindTexture(Gl.GL_TEXTURE_2D, texture); //連結紋理物件 //設定紋理參數 Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_S, Gl.GL_REPEAT); Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_T, Gl.GL_REPEAT); Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAG_FILTER, Gl.GL_LINEAR); Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_LINEAR); //建立紋理物件 if (BitsPerPixel == 24) { Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGB, 512, 512, 0, Il.ilGetInteger(Il.IL_IMAGE_FORMAT), Il.ilGetInteger(Il.IL_IMAGE_TYPE), Il.ilGetData()); } if (BitsPerPixel == 32) { Gl.glTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGBA, 512, 512, 0, Il.ilGetInteger(Il.IL_IMAGE_FORMAT), Il.ilGetInteger(Il.IL_IMAGE_TYPE), Il.ilGetData()); } } else { // 若檔案無法開啟,顯示錯誤訊息 string message = "Cannot open file " + filename + "."; MessageBox.Show(message, "Image file open error!!!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
public void LoadTexture(string textureId, string path) { Random rand = new Random(); int devilId = 0; Il.ilGenImages(1, out devilId); Il.ilBindImage(devilId); // set as the active texture. if (!Il.ilLoadImage(path)) { System.Diagnostics.Debug.Assert(false, "Could not open file, [" + path + "]."); } Ilu.iluFlipImage(); int width = Il.ilGetInteger(Il.IL_IMAGE_WIDTH); int height = Il.ilGetInteger(Il.IL_IMAGE_HEIGHT); int openGLId = Ilut.ilutGLBindTexImage(); System.Console.WriteLine(width); System.Console.WriteLine(height); System.Console.WriteLine(openGLId); System.Console.WriteLine(devilId); System.Diagnostics.Debug.Assert(openGLId != 0); Il.ilDeleteImages(1, ref devilId); _textureDatabase.Add(textureId, new Texture(openGLId, width, height)); }
public Form1() { _system.AddState("Splash", new SplashScreenState(_system)); _system.AddState("title_menu", new TitleMenuState()); _system.AddState("sprite_test", new DrawSpriteState(_textureManger)); _system.ChangeState("sprite_test"); // Init DevIl Il.ilInit(); Ilu.iluInit(); Ilut.ilutInit(); Ilut.ilutRenderer(Ilut.ILUT_OPENGL); InitializeComponent(); _openGLControl.InitializeContexts(); if (_fullscreen) { FormBorderStyle = FormBorderStyle.None; WindowState = FormWindowState.Maximized; } else { ClientSize = new Size(800, 600); } Setup2DGraphics(ClientSize.Width, ClientSize.Height); _fastloop = new FastLoop(GameLoop); _textureManger.LoadTexture("flower", "flower.jpg"); }
public Form1() { _fastLoop = new FastLoop(GameLoop); InitializeComponent(); _openGLControl.InitializeContexts(); // Initialize DevIL Il.ilInit(); Ilu.iluInit(); Ilut.ilutInit(); Ilut.ilutRenderer(Ilut.ILUT_OPENGL); // Load textures _textureManager.LoadTexture("font", "font.tga"); if (_fullscreen) { FormBorderStyle = FormBorderStyle.None; WindowState = FormWindowState.Maximized; } else { ClientSize = new Size(1280, 720); } // Initialize states _system.AddState("graph_state", new WaveformGraphState()); _system.AddState("special_effect_state", new SpecialEffectState(_textureManager)); _system.AddState("swirl_effect_state", new SwirlEffectState(_textureManager)); _system.AddState("bounce_state", new CharacterBounceState(_textureManager)); _system.AddState("circle_intersect_state", new CircleIntersectionState(_input)); _system.AddState("rectangle_intersect_state", new RectangleIntersectionState(_input)); _system.ChangeState("rectangle_intersect_state"); }
public Form1() { //Initialize DeviL Il.ilInit(); Ilu.iluInit(); Ilut.ilutInit(); Ilut.ilutRenderer(Ilut.ILUT_OPENGL); FastLoop _fastLoop = new FastLoop(GameLoop); InitializeComponent(); if (_fullscreen) { FormBorderStyle = FormBorderStyle.None; WindowState = FormWindowState.Maximized; } else { ClientSize = new Size(1280, 720); } // Add all the states that will be used. _system.AddState("splash", new SplashScreenState(_system)); _system.AddState("title_menu", new TitleMenuState()); _system.AddState("sprite_test", new DrawSpriteState()); // Select the start state _system.ChangeState("sprite_test"); }
private void InitializeTextures() { Il.ilInit(); Ilu.iluInit(); Ilut.ilutInit(); Ilut.ilutRenderer(Ilut.ILUT_OPENGL); //Load Texutures _textureManager.LoadTexture("title_font", "Assets/title_font.tga"); _textureManager.LoadTexture("general_font", "Assets/general_font.tga"); _textureManager.LoadTexture("computer_font2", "Assets/computer_font2.tga"); _textureManager.LoadTexture("player_ship", "Assets/spaceship.tga"); _textureManager.LoadTexture("player", "Assets/player.tga"); _textureManager.LoadTexture("test", "Assets/test_ship.tga"); _textureManager.LoadTexture("enemy_ship", "Assets/spaceship2.tga"); _textureManager.LoadTexture("enemy1", "Assets/enemy1.tga"); _textureManager.LoadTexture("fish_ship", "Assets/fish_ship.tga"); _textureManager.LoadTexture("player_lazer", "Assets/player_lazer2.tga"); _textureManager.LoadTexture("enemy_lazer", "Assets/enemy_lazer.tga"); _textureManager.LoadTexture("alt_bullet", "Assets/alt_bullet.tga"); _textureManager.LoadTexture("missle", "Assets/missle.tga"); _textureManager.LoadTexture("background", "Assets/space_back.tga"); _textureManager.LoadTexture("background_layer_1", "Assets/background_p.tga"); _textureManager.LoadTexture("cave_background1", "Assets/cave_background1.tga"); _textureManager.LoadTexture("cave_background_layer1", "Assets/cave_background_layer1.tga"); _textureManager.LoadTexture("earth", "Assets/earth.tga"); _textureManager.LoadTexture("explosion", "Assets/explode.tga"); }
uint[] texName = new uint[5]; //建立儲存紋理編號的陣列 uint 表示是符號 public Form1() { InitializeComponent(); this.simpleOpenGlControl1.InitializeContexts(); Glut.glutInit(); Il.ilInit(); //因為要用到Tao.DevIl Ilu.iluInit(); }
public static void InitializeILU() { if (!isILUInitialized) { // init Il utils Ilu.iluInit(); isILUInitialized = true; } }
public void DumpErrors(string title) { int error = Il.ilGetError(); while (error != 0) { Console.WriteLine(title + ": Error #" + error + " Message: " + Ilu.iluErrorString(error)); error = Il.ilGetError(); } }
private void InitializeTextures() { // Init DevIl Il.ilInit(); Ilu.iluInit(); Ilut.ilutInit(); Ilut.ilutRenderer(Ilut.ILUT_OPENGL); // Textures are loaded here. }
private void InitializeTextures() { // Init DevIl Il.ilInit(); Ilu.iluInit(); Ilut.ilutInit(); Ilut.ilutRenderer(Ilut.ILUT_OPENGL); // Load textures here using the texture manager. }
public Form1() { //initialize windows stuff InitializeComponent(); //initialize OpenGL _openGLControl.InitializeContexts(); //Initialize DevIl Il.ilInit(); Ilu.iluInit(); Ilut.ilutInit(); Ilut.ilutRenderer(Ilut.ILUT_OPENGL); //Load Textures _textureManager.LoadTexture("face", "face_alpha.tif"); _textureManager.LoadTexture("face_alpha", "face.tif"); _textureManager.LoadTexture("font", "font.tga"); //Adding States to system _system.AddState("splash", new SplashScreenState(_system)); _system.AddState("title", new TitleMenuState(_system)); _system.AddState("sprite", new DrawSpriteState(_textureManager)); _system.AddState("sprite_test", new TestSpriteClassState(_textureManager)); _system.AddState("text_test", new TextTestState(_textureManager)); _system.AddState("FPS_test", new FPSTestState(_textureManager)); _system.AddState("waveform", new WaveformGraphState()); _system.AddState("effect_test_state", new SpecialEffectsState(_textureManager)); _system.AddState("circle_test_state", new CircleIntersectionState(_input)); _system.AddState("rectang_test_state", new RectangleIntersectionState(_input)); _system.AddState("tween_test_state", new TweenTestState(_textureManager)); _system.AddState("matrix_test_state", new MatrixTestState(_textureManager)); //INitilize splash state _system.ChangeState("FPS_test"); if (_fullscreen) { FormBorderStyle = FormBorderStyle.None; WindowState = FormWindowState.Maximized; } else { ClientSize = new Size(1280, 720); } //2D grahpics setup Setup2DGrahpics(ClientSize.Width, ClientSize.Height); //Initiate Fastloop _fastLoop = new FastLoop(GameLoop); }
private void InitializeTextures() { // Init DevIl Il.ilInit(); Ilu.iluInit(); Ilut.ilutInit(); Ilut.ilutRenderer(Ilut.ILUT_OPENGL); // Textures are loaded here. _textureManager.LoadTexture("title_font", "title_font.tga"); }
private void InitializeTextures() { // Init DevIl Il.ilInit(); Ilu.iluInit(); Ilut.ilutInit(); Ilut.ilutRenderer(Ilut.ILUT_OPENGL); // Load textures here using the texture manager. _textureManager.LoadTexture("spaceship", "spaceship.tga"); _textureManager.LoadTexture("spaceship2", "spaceship2.tga"); }
public TaoImage(string filename) { FileStream s = new FileStream(filename, FileMode.Open); int imageID; // create and bind a new image Il.ilGenImages(1, out imageID); Il.ilBindImage(imageID); // create a temp buffer and write the stream into it byte[] tmpBuffer = new byte[s.Length]; s.Read(tmpBuffer, 0, tmpBuffer.Length); // load the data into DevIL Il.ilLoadL(Il.IL_PNG, tmpBuffer, tmpBuffer.Length); // check for an error int ilError = Il.ilGetError(); if (ilError != Il.IL_NO_ERROR) { throw new Exception(string.Format("Error while decoding image data: '{0}'", Ilu.iluErrorString(ilError))); } // flip the image so that the mosaics produced match what L3DT produces Ilu.iluFlipImage(); format = Il.ilGetInteger(Il.IL_IMAGE_FORMAT); bytesPerPixel = Math.Max(Il.ilGetInteger(Il.IL_IMAGE_BPC), Il.ilGetInteger(Il.IL_IMAGE_BYTES_PER_PIXEL)); Width = Il.ilGetInteger(Il.IL_IMAGE_WIDTH); Height = Il.ilGetInteger(Il.IL_IMAGE_HEIGHT); depth = Il.ilGetInteger(Il.IL_IMAGE_DEPTH); // get the decoded data buffer = new byte[Width * Height * bytesPerPixel]; IntPtr ptr = Il.ilGetData(); // copy the data into the byte array unsafe { byte *pBuffer = (byte *)ptr; for (int i = 0; i < buffer.Length; i++) { buffer[i] = pBuffer[i]; } } // we won't be needing this anymore Il.ilDeleteImages(1, ref imageID); }
public static bool ReshapeToPowersOf2AndSave(Stream input, int size, string outputFileName) { InitializeIL(); InitializeILU(); // load the image ImageData data = new ImageData(); int imageID; // create and bind a new image Il.ilGenImages(1, out imageID); Il.ilBindImage(imageID); // create a temp buffer and copy the stream into it byte[] buffer = new byte[size]; int bytesRead = 0, byteOffset = 0, bytes = buffer.Length; do { bytesRead = input.Read(buffer, byteOffset, bytes); bytes -= bytesRead; byteOffset += bytesRead; } while (bytes > 0 && bytesRead > 0); Il.ilLoadL(Il.IL_TYPE_UNKNOWN, buffer, buffer.Length); // check errors int ilError = Il.ilGetError(); if (ilError != Il.IL_NO_ERROR) { throw new AxiomException("Error while loading image data: '{0}'", Ilu.iluErrorString(ilError)); } // determine dimensions & compute powers-of-2 reshape if needed int width = Il.ilGetInteger(Il.IL_IMAGE_WIDTH); int height = Il.ilGetInteger(Il.IL_IMAGE_HEIGHT); int newWidth = (int)Math.Pow(2, Math.Floor(Math.Log(width, 2))); int newHeight = (int)Math.Pow(2, Math.Floor(Math.Log(height, 2))); if (width != newWidth || height != newHeight) { // reshape // set the scale function filter & scale Ilu.iluImageParameter(Ilu.ILU_FILTER, Ilu.ILU_BILINEAR); // .ILU_SCALE_BSPLINE); Ilu.iluScale(newWidth, newHeight, 1); } // save Il.ilSetInteger(Il.IL_JPG_QUALITY, 50); Il.ilSaveImage(outputFileName); // drop image Il.ilDeleteImages(1, ref imageID); return(true); }
private void InitializeTextures() { // Init DevIl Il.ilInit(); Ilu.iluInit(); Ilut.ilutInit(); Ilut.ilutRenderer(Ilut.ILUT_OPENGL); // Textures are loaded here. _textureManager.LoadTexture("moveChessR_CAR", "./Chess/RR.GIF"); _textureManager.LoadTexture("selectedChessR_CAR", "./Chess/RRS.GIF"); _textureManager.LoadTexture("moveChessR_HORSE", "./Chess/RN.GIF"); _textureManager.LoadTexture("selectedChessR_HORSE", "./Chess/RNS.GIF"); _textureManager.LoadTexture("moveChessR_CANON", "./Chess/RC.GIF"); _textureManager.LoadTexture("selectedChessR_CANON", "./Chess/RCS.GIF"); _textureManager.LoadTexture("moveChessR_ELEPHANT", "./Chess/RB.GIF"); _textureManager.LoadTexture("selectedChessR_ELEPHANT", "./Chess/RBS.GIF"); _textureManager.LoadTexture("moveChessR_BISHOP", "./Chess/RA.GIF"); _textureManager.LoadTexture("selectedChessR_BISHOP", "./Chess/RAS.GIF"); _textureManager.LoadTexture("moveChessR_KING", "./Chess/RK.GIF"); _textureManager.LoadTexture("selectedChessR_KING", "./Chess/RKS.GIF"); _textureManager.LoadTexture("moveChessR_PAWN", "./Chess/RP.GIF"); _textureManager.LoadTexture("selectedChessR_PAWN", "./Chess/RPS.GIF"); _textureManager.LoadTexture("moveChessB_CAR", "./Chess/BR.GIF"); _textureManager.LoadTexture("selectedChessB_CAR", "./Chess/BRS.GIF"); _textureManager.LoadTexture("moveChessB_HORSE", "./Chess/BN.GIF"); _textureManager.LoadTexture("selectedChessB_HORSE", "./Chess/BNS.GIF"); _textureManager.LoadTexture("moveChessB_CANON", "./Chess/BC.GIF"); _textureManager.LoadTexture("selectedChessB_CANON", "./Chess/BCS.GIF"); _textureManager.LoadTexture("moveChessB_ELEPHANT", "./Chess/BB.GIF"); _textureManager.LoadTexture("selectedChessB_ELEPHANT", "./Chess/BBS.GIF"); _textureManager.LoadTexture("moveChessB_BISHOP", "./Chess/BA.GIF"); _textureManager.LoadTexture("selectedChessB_BISHOP", "./Chess/BAS.GIF"); _textureManager.LoadTexture("moveChessB_KING", "./Chess/BK.GIF"); _textureManager.LoadTexture("selectedChessB_KING", "./Chess/BKS.GIF"); _textureManager.LoadTexture("moveChessB_PAWN", "./Chess/BP.GIF"); _textureManager.LoadTexture("selectedChessB_PAWN", "./Chess/BPS.GIF"); _textureManager.LoadTexture("moveChessNOCHESS", "./Chess/OO.GIF"); _textureManager.LoadTexture("selectedChessNOCHESS", "./Chess/OOS.GIF"); //_textureManager.LoadTexture("moveChessR_CAR", "./Chess/RR.GIF"); //_textureManager.LoadTexture("selectedChessR_CAR", "./Chess/RR.GIF"); //_textureManager.LoadTexture("font", "font.tga"); _textureManager.LoadTexture("enemy_ship", "spaceship2.tga"); _textureManager.LoadTexture("chinese_font", "chinese_font_0.tga", "chinese_font_1.tga"); _textureManager.LoadTexture("chinese_yy", "chinese_yy_0.tga"); _textureManager.LoadTexture("chessboard", "CHESSBOARD.JPG"); _textureManager.LoadTexture("background", "background.png"); _textureManager.LoadTexture("background_layer_1", "windowBkg.jpg"); _textureManager.LoadTexture("explosion", "explode.tga"); }
private void InitializeTextures() { // Init DevIl Il.ilInit(); Ilu.iluInit(); Ilut.ilutInit(); Ilut.ilutRenderer(Ilut.ILUT_OPENGL); // Load textures here using the texture manager. _textureManager.LoadTexture("start", "start.tga"); _textureManager.LoadTexture("finish", "finish.tga"); _textureManager.LoadTexture("sky", "sky.tga"); _textureManager.LoadTexture("wall", "wall.tga"); }
public void LoadTexture(string textureId, string path, string path2 = null) { int devilId = 0; Il.ilGenImages(1, out devilId); Il.ilBindImage(devilId); // set as the active texture. if (!Il.ilLoadImage(path)) { System.Diagnostics.Debug.Assert(false, "Could not open file, [" + path + "]."); } Ilu.iluFlipImage(); int width = Il.ilGetInteger(Il.IL_IMAGE_WIDTH); int height = Il.ilGetInteger(Il.IL_IMAGE_HEIGHT); int openGLId = Ilut.ilutGLBindTexImage(); System.Diagnostics.Debug.Assert(openGLId != 0); Il.ilDeleteImages(1, ref devilId); int?width2 = null; int?height2 = null; int?openGLId2 = null; //int devilId = 0; Il.ilGenImages(1, out devilId); Il.ilBindImage(devilId); // set as the active texture. if (path2 != null) { if (!Il.ilLoadImage(path2)) { System.Diagnostics.Debug.Assert(false, "Could not open file, [" + path2 + "]."); } Ilu.iluFlipImage(); width2 = Il.ilGetInteger(Il.IL_IMAGE_WIDTH); height2 = Il.ilGetInteger(Il.IL_IMAGE_HEIGHT); openGLId2 = Ilut.ilutGLBindTexImage(); System.Diagnostics.Debug.Assert(openGLId2 != 0); Il.ilDeleteImages(1, ref devilId); } _textureDatabase.Add(textureId, new Texture(openGLId, width, height, openGLId2, width2, height2)); }
private void InitializeTextures() { // Init DevIl Il.ilInit(); Ilu.iluInit(); Ilut.ilutInit(); Ilut.ilutRenderer(Ilut.ILUT_OPENGL); // Textures are loaded here. _textureManager.LoadTexture("player_ship", "spaceship.tga"); _textureManager.LoadTexture("title_font", "title_font.tga"); _textureManager.LoadTexture("general_font", "general_font.tga"); _textureManager.LoadTexture("background", "background.tga"); _textureManager.LoadTexture("background_layer_1", "background_p.tga"); }
//需要把alut.dll, ILU.dll,OpenAL32.dll 复制到debug和release目录里 void InitializeDisplay() { this.ClientSizeChanged += (s, e) => { int dw = (int)(this.ClientSize.Height * (4 / 3.0f)); Gl.glViewport((this.ClientSize.Width - dw) / 2, 0, dw, this.ClientSize.Height); //使OpenGL窗体与winform保持一致,坐标原点在左下角 Setup2DGraphics(640, 480); //游戏场景的大小 }; // 游戏是640*480 this.ClientSize = new Size(640, 480); //800 600(4:3) 1280 720(16:9) //资源初始化 Il.ilInit(); Ilu.iluInit(); Ilut.ilutInit(); Ilut.ilutRenderer(Ilut.ILUT_OPENGL); }
public override void EncodeToFile(Stream input, string outFileName, Codec.CodecData codecData) { int imageID; // create and bind a new image Il.ilGenImages(1, out imageID); Il.ilBindImage(imageID); var buffer = new byte[input.Length]; input.Read(buffer, 0, buffer.Length); var imgData = (ImageData)codecData; PixelBox src; using (var bufHandle = BufferBase.Wrap(buffer)) { src = new PixelBox(imgData.width, imgData.height, imgData.depth, imgData.format, bufHandle); } try { // Convert image from Axiom to current IL image ILUtil.ConvertToIL(src); } catch (Exception ex) { LogManager.Instance.Write("IL Failed image conversion :", ex.Message); } // flip the image Ilu.iluFlipImage(); // save the image to file Il.ilSaveImage(outFileName); var error = Il.ilGetError(); if (error != Il.IL_NO_ERROR) { LogManager.Instance.Write("IL Error, could not save file: {0} : {1}", outFileName, Ilu.iluErrorString(error)); } Il.ilDeleteImages(1, ref imageID); }