• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

shinypixel

Members
  • Content count

    141
  • Joined

  • Last visited

Community Reputation

226 Neutral

About shinypixel

  • Rank
    Member
  1. Hello   I've been working on an Eye of the Beholder kind of game. For a good idea, I attached a few screenshots. Some of the art is temporary.   I have the following algorithm that checks what is in the actor's current sight. It somewhat takes an extreme approach that gets everything around the player, and then you can make calls on the current direction he is facing.   I reduced the code for readability. int Actor::view(Map &map) {     // Sight area with a depth of 3. The actor is always at the center.     char sight[] = {         0, 0,  0,  0,  0, 0, 0,    // 0-6          0, 0,  0,  0,  0, 0, 0,    // 7-13         0, 0,  0,  0,  0, 0, 0,    // 14-20         0, 0,  0, 'A', 0, 0, 0,    // 21-27         0, 0,  0,  0,  0, 0, 0,    // 28-34         0, 0,  0,  0,  0, 0, 0,    // 35-41         0, 0,  0,  0,  0, 0, 0    // 42-48     };     char c;       int x_center = 3;     int y_center = 3;     // Build the actor's sight table     for (int y = 0; y < 7; y++) {         for (int x = 0; x < 7; x++) {             sight[y * 7 + x] = map.peek(m_x, m_y, x - x_center, y - y_center);         }     }     // Check the actor's facing direction     switch (m_dir)         {         case EDir_N:             {                   /*                 WWW                 W*W (North-facing)                 */                 if (sight[N] == WALL && sight[E] == WALL && sight[W] == WALL)                     return WALL_UP_CLOSE;             }             break;         case EDir_E:             {                    /*                 WW                 *W (East-facing)                 WW                 */                 if (sight[E] == WALL && sight[N] == WALL && sight[S] == WALL)                     return WALL_UP_CLOSE;             }             break;         case EDir_W:             {                   /*                 WW                 W* (West-facing)                 WW                 */                 if (sight[W] == WALL && sight[N] == WALL && sight[S] == WALL)                     return WALL_UP_CLOSE;             }                 break;         case EDir_S:             {                 /*                 W*W                 WWW (South facing)                 */                 if (sight[S] == WALL && sight[E] == WALL && sight[W] == WALL)                     return WALL_UP_CLOSE;             }             break;         }     return -1; } As you can see, each direction has about the same check and the same returning ID. The returning ID draws the correct batch of images to the screen.   Although I reduced the code a few times, I feel I can reduce it even more. My question is, well, how can I reduce it? The player is facing a dead end on all four directions, so I feel I could just check it once somehow. I'm always tracking the player's position, so it helps me know what to draw.   I guess right now it just bugs me that there's 4 conditions to return the same ID based on direction. Can it be possible to have only one condition and not loose focus of the current facing direction?
  2. I'm the same way and prefer using C++ for mobile. This is my perspective on it: In iOS, you can use C++ with Obj-C. You can either create .cpp files or .mm files (Obj-C++). A basic understanding of Obj-C will get your program up and running (the groundwork), and then you can almost program the rest in C++. You can mix .cpp files with .mm. Likewise, in C, you can mix it with .m files. To get the full power of developing in iOS, it is recommended to learn their archetecture, native language, and APIs. Otherwise, you may be limiting yourself depending on what you use, and the third-party tools may take longer to update to Apple's current version. At the end, it depends on what your design documentation requires.   Edit: If it's worth anything, I hated the idea of learning Obj-C, and then I realized how easy it was to learn with my prior C and C++ experience. It took me about a weekend with a book for syntax. So you're literally just quickly scanning pages after the first few 40+ pages.
  3. This was solved by looking at the rest of the available tiles. Also it was helpful looking into the Painters Algorithm. https://en.wikipedia.org/wiki/Painter%27s_algorithm
  4. "spotlight is a directional light that has direction you are not setting"   Are you referring to spotDir? How would this be set?
  5. Edit: Solved issue with looking at additional tiles.   I'm using artwork from the following page: http://opengameart.org/content/first-person-dungeon-crawl-art-pack   Demo of ground: http://heroinedusk.com/demo/   As you can see with the first artwork, the grass field is long. The pathway also goes into the distance. I'm most interested in the path.   However, The floor is really small tile-wise. Look at the attachment. It's 118x22 pixels.   I'm supposing that the artwork is layered on top of each other. Is that true?    Is the method similar to this? set x to 0, y -= 22 draw path set x to 20, y -= 22 draw path ...   But as you can see, the tile isn't square, so I don't think this is correct. Any thoughts would be great. Thank you.
  6. Well, I'm trying to add a small yellow spotlight to my torch. I'm a little lost on how to do it.   Basically, what I'm trying to do is add a yellow "ball of light" at the center of the torch flames (left image).   This is the code that produced the image on the right, but it's not giving the right result. Any thoughts on the code? If it matters, my gluOrtho2D function is set as (0,w,h,0). Thanks.     GLfloat lightPos[] = { 640.0f, 640.0f, 400.0f, 1.0f }; // 1280x800 screen resolution     GLfloat specular[] = { 1.0f, 1.0f, 1.0f, 1.0f};     GLfloat specref[] = { 1.0f, 1.0f, 1.0f, 1.0f };     GLfloat ambientLight[] = { 0.5f, 0.5f, 0.5f, 1.0f};     GLfloat spotDir[] = { 0.0f, 0.0f, -1.0f };     glEnable(GL_LIGHTING);          glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambientLight);     glLightfv(GL_LIGHT0,GL_DIFFUSE,ambientLight);     glLightfv(GL_LIGHT0,GL_SPECULAR,specular);     glLightfv(GL_LIGHT0,GL_POSITION,lightPos);     glLightf(GL_LIGHT0,GL_SPOT_CUTOFF,60.0f);     glEnable(GL_LIGHT0);     glEnable(GL_COLOR_MATERIAL);     glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);     glMaterialfv(GL_FRONT, GL_SPECULAR,specref);     glMateriali(GL_FRONT, GL_SHININESS,128);
  7. Well, I went with the counter method. Seems to be working good.     // Play a random atmosphere sound     randomSoundCounter++;     if (randomSoundCounter > randomSoundCounterMax)     {         // Play approx 30% of the time         if (r.next(0, 10) >= 7)              atm_snds.playRandomSound();         randomSoundCounter = 0;     }
  8. I tried the following, but not too sure about it.      // Play a random atmosphere sound     if (rand.next(0, 1000) > 995)         atm_snds.playRandomSound(); The problem is that sounds play too frequently, though I just want it every once in a while. Right now I have it set to play one random sound at a time.   It's a 2d game, so performance isn't much of a concern. There's a Timer class, and it can be called with an ellapsed time, though resources are slow, and then check with a random number condition. That's my new idea. Another idea is to use a counter. If it's past the max, do a condition with a random number. If it passes, then play a random atmosphere sound.   But I'm curious: Is there a preferred way of playing random atmosphere sounds? Thanks.
  9. I created a C++ library called the X2D Game Library. It contains native OpenGL for 2D, OpenAL/DSound/DMusic, a basic Win32 API GUI with a C# feel, local SQL, and some other odds and ends.   My first demo: https://www.youtube.com/watch?v=nppEEf-6NBY   Another early one (watch for the pink monster, he's frightening!) https://www.youtube.com/watch?v=cBaBiT_R_gg   While this new library has becoming a bit more mature, I always wanted to explore how to make an "Eye of the Beholder" type of game, and I feel I'm getting to that point. I hope to make my own unique dungeon game, but the progress has been fascinating. I thought I'd share a few videos to get your opinions or feedback. Thanks!   Disclaimer: Graphics are not the greatest at the moment... ;)   Brief Dungeon Walk: https://www.youtube.com/watch?v=xiAuNfAsGGA&feature=youtu.be   Commentary of the overall design and a brief demo. https://www.youtube.com/watch?v=M3nkdCsCaVo
  10. SOLVED!!! :)   Okay, apparently the issue was the DevIL Image library's ilutGLLoadImage(). I heard some people had problems with ilutGLLoadImage(), so they recommended ilLoadImage() or ilLoad(). It did the trick. Thank you NumberXaero for your help, too. I found I set that bound issue wrong, too, so that was a good catch.       // load the image     //if (ilutGLLoadImage((char *)filename.c_str()) == NULL)     //    return false;     ilLoadImage(filename.c_str());
  11. After some tinkering, I got the following image:   So, the second image (left-most, 50x50 pixels) is somehow retaining the third image's texture data (right-most). What are some reasons the second image is keeping the old texture?   Screenshot: http://postimg.org/image/arawxmn95/
  12. I tried to simplify the issue by avoiding the use of the Sprite class for now, since it derives from class Image.   I loaded the first image, loaded and showed fine. I loaded asecond image, loaded and showed fine. I loaded a third image, the first and third showed up.     // Load in the background image     if (!img.init("res/art/grass.jpg"))         return false;     img.setPos(0, 0);     img.stretch(SCREEN_WIDTH, SCREEN_HEIGHT);      // this one doesn't show when three are loaded in     if (!img2.init("res/art/C1_Stand.png"))         return false;     img2.setPos(50, 50);     if (!img3.init("res/art/druid.png"))         return false;     img3.setPos(150, 50); So, the two major functions are init() and gl.draw() where the bug must be in. bool Image::init(const string &filename) {     // Check if this is the first time initializing an image     if (refCount == 0)     {         // Init DevIL         ilInit();         iluInit();         ilutRenderer(ILUT_OPENGL);         // Will be using GL_TEXTURE_RECTANGLE_ARB for image coordinates.         glEnable(GL_TEXTURE_RECTANGLE_ARB);         // Set origin for all images         ilEnable(IL_ORIGIN_SET);            ilOriginFunc(IL_ORIGIN_UPPER_LEFT);     }        // Generate the image     ilGenImages(1, &m_handle);          // Bind the current image     glBindTexture(GL_TEXTURE_RECTANGLE_ARB, m_handle);     // load the image     if (ilutGLLoadImage((char *)filename.c_str()) == NULL)         return false;       // Check if image is backwards     if (ilGetInteger(IL_IMAGE_ORIGIN) == IL_ORIGIN_LOWER_LEFT) {         m_flipped = true;         iluFlipImage();     }                // Convert to IL_RGBA     ilConvertImage(IL_RGBA, IL_UNSIGNED_BYTE);       // get the image's width and height     m_width = ilGetInteger(IL_IMAGE_WIDTH);     m_height = ilGetInteger(IL_IMAGE_HEIGHT);     m_size = ilGetInteger(IL_IMAGE_SIZE_OF_DATA);     m_imageType = ilGetInteger(IL_IMAGE_TYPE);     m_imageFormat = ilGetInteger(IL_IMAGE_FORMAT);     m_channels = ilGetInteger(IL_IMAGE_CHANNELS);     // Generate texture for mapping       glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, m_imageFormat, m_width,         m_height, 0, m_imageFormat, m_imageType, ilGetData());              // Set texture parameters     glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);     glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);     glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);     glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);     glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);       // Set initial color components     m_red = 1.0f;     m_green = 1.0f;     m_blue = 1.0f;     m_alpha = 1.0f;          // Increase the reference count     refCount++;     m_show = true;                    // Default show state     m_angle = 0.0f;                    // Rotation angle     m_scale_x = 1.0f;                // Default X scale value     m_scale_y = 1.0f;                // Default Y scale value     m_stretch_width = 0.0f;            // Default Stretch Width     m_stretch_height = 0.0f;        // Default Stretch Height            return true; } For the image class, the opengl engine just draws it: void GLEngine::draw(const Image &img) {     if (!img.getShow())         return;          glPushMatrix();     glLoadIdentity();            // bind texture     glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint*)&m_boundTexture);     glBindTexture(GL_TEXTURE_RECTANGLE_ARB, img.getHandle());     glBindTexture(GL_TEXTURE_RECTANGLE_ARB, m_boundTexture);     // Set color tent     glColor4f(img.getRed(), img.getGreen(), img.getBlue(), img.getAlpha());            // Draw the texture     glBegin(GL_QUADS);                      // bottom left         glTexCoord2f(0.0f, (GLfloat)img.getHeight());         glVertex2f(img.getX(), (img.getY() + (GLfloat)img.getHeight() * img.getScaleY()));              // bottom right           glTexCoord2f((GLfloat)img.getWidth(), (GLfloat)img.getHeight());         glVertex2f((img.getX() + img.getWidth() * img.getScaleX()), (img.getY() + (GLfloat)img.getHeight() * img.getScaleY()));         // upper right           glTexCoord2f((GLfloat)img.getWidth(), 0.0f);           glVertex2f((img.getX() + (GLfloat)img.getWidth() * img.getScaleX()), img.getY());         // upper left            glTexCoord2f(0.0f, 0.0f);         glVertex2f((img.getX()), img.getY());     glEnd();                glPopMatrix();       m_boundTexture = -1; } I also tried just... glBindTexture(GL_TEXTURE_RECTANGLE_ARB, m_handle); but I get the same result.   Anyway, nothing new, but looking more closely at the Image class.
  13. Unfortunately, nothing new on the screen. I got that binding code from the following site:   Topic: "The Object Oriented Language Problem" https://www.opengl.org/wiki/Common_Mistakes   But with it replaced to  glBindTexture(GL_TEXTURE_RECTANGLE_ARB, m_handle); I still get the grass and the druid sprite, while the first sprite isn't showing.
  14. EDIT: Issue is solved.   Being new to OpenGL, I'm figuring the problem is due to binding an image, but I'm not exactly sure where.   I loaded in my first sprite, and it animates fine. I loaded in the second sprite, and now the second sprite only shows, and the first loaded sprite will not show.   Higher level code:     // Load in the background image     if (!img.init("res/art/grass.jpg"))         return false;     img.setPos(0, 0);     img.stretch(SCREEN_WIDTH, SCREEN_HEIGHT);     // Load alien sprite     if (!alien.init("res/art/sprite.png")) {         return false;     } else {         alien.setCounterLimit(2);         Sequence s(WALK_RIGHT);         s.addCell(10, 169, 23, 203);         s.addCell(26, 169, 42, 203);         s.addCell(45, 169, 59, 203);         s.addCell(60, 169, 72, 203);         s.addCell(75, 169, 88, 203);         s.addCell(90, 169, 106, 203);         s.addCell(108, 169, 122, 203);         s.addCell(124, 169, 139, 203);         alien.addAnimSequence(s);         Sequence s2;         s2.setID(FIRE);         s2.addCell(216, 6, 246, 40);          alien.addAnimSequence(s2);         alien.setAnimSequenceID(WALK_RIGHT);                    alien.setPos(0.0f, 20.0f);         alien.setVel(10.0f);         alien.scale(2.0f);       }     // Load druid sprite     if (!spr.init("res/art/druid.png")) {         return false;     } else {         spr.setCounterLimit(2);         Sequence s3;         s3.setID(STILL);         s3.addCell(0, 0, 160, 120);            spr.addAnimSequence(s3);         spr.setAnimSequenceID(STILL);                    spr.setPos(400.0f, 20.0f);         spr.scale(1.0f);              }       // ... later in the rendering method     gl.draw(img);     alien.draw();     spr.draw(); Likewise, if I reverse the order of loading, the last sprite loaded will only show. So, I've been able to pinpoint that this could be a binding issue either in the init() or draw() function members. Can you spot it?   My class hiarchy is... class Sprite : public Image - Sprite does the drawing via draw(), initialization with init(), which calls class Image's init() to load in the texture.   Here's the initialization function in Image. Is it binding each new texture correctly? bool Image::init(const string &filename) {     // Check if this is the first time initializing an image     if (refCount == 0)     {         // Init DevIL         ilInit();         iluInit();         ilutRenderer(ILUT_OPENGL);         // Will be using GL_TEXTURE_RECTANGLE_ARB for image coordinates.         glEnable(GL_TEXTURE_RECTANGLE_ARB);         // Set origin for all images         ilEnable(IL_ORIGIN_SET);            ilOriginFunc(IL_ORIGIN_UPPER_LEFT);     }        // Generate the image     ilGenImages(1, &m_handle);          // Bind the current image     glBindTexture(GL_TEXTURE_RECTANGLE_ARB, m_handle);     // load the image     if (ilutGLLoadImage((char *)filename.c_str()) == NULL)         return false;       // Check if image is backwards     if (ilGetInteger(IL_IMAGE_ORIGIN) == IL_ORIGIN_LOWER_LEFT) {         m_flipped = true;         iluFlipImage();     }                // Convert to IL_RGBA     ilConvertImage(IL_RGBA, IL_UNSIGNED_BYTE);       // get the image's width and height     m_width = ilGetInteger(IL_IMAGE_WIDTH);     m_height = ilGetInteger(IL_IMAGE_HEIGHT);     m_size = ilGetInteger(IL_IMAGE_SIZE_OF_DATA);     m_imageType = ilGetInteger(IL_IMAGE_TYPE);     m_imageFormat = ilGetInteger(IL_IMAGE_FORMAT);     m_channels = ilGetInteger(IL_IMAGE_CHANNELS);     // Generate texture for mapping       glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, m_imageFormat, m_width,         m_height, 0, m_imageFormat, m_imageType, ilGetData());              // Set texture parameters     glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);     glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);     glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);     glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);     glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);       // Set initial color components     m_red = 1.0f;     m_green = 1.0f;     m_blue = 1.0f;     m_alpha = 1.0f;          // Increase the reference count     refCount++;     m_show = true;                    // Default show state     m_angle = 0.0f;                    // Rotation angle     m_scale_x = 1.0f;                // Default X scale value     m_scale_y = 1.0f;                // Default Y scale value     m_stretch_width = 0.0f;            // Default Stretch Width     m_stretch_height = 0.0f;        // Default Stretch Height            return true; } If that looks fine, perhaps it's a drawing issue on binding. I put that code below for viewing. Oddly enough, if I create just an Image object and display it with one Sprite object, it shows the two textures just fine. If I create two Sprite objects, I only get one sprite displaying. See attached image.   [attachment=25342:image texture with one sprite.png] void Sprite::draw() {     // Check if the sprite is visible     if (!m_show)         return;     // Check if any cells are available for rendering     if (m_cells.empty())         return;          glPushMatrix();     glLoadIdentity();            // bind texture     glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint*)&m_boundTexture);     glBindTexture(GL_TEXTURE_RECTANGLE_ARB, m_handle);     glBindTexture(GL_TEXTURE_RECTANGLE_ARB, m_boundTexture);     // Set color tint     glColor4f(m_red, m_green, m_blue, m_alpha);          // Draw the texture     glBegin(GL_QUADS);                      // bottom left          glTexCoord2f(m_cells[m_currentFrame].x + 1, m_cells[m_currentFrame].height);         glVertex2f(m_x, m_y + (m_cells[m_currentFrame].height - m_cells[m_currentFrame].y) * m_scale_y);              // bottom right           glTexCoord2f(m_cells[m_currentFrame].width, m_cells[m_currentFrame].height);         glVertex2f(m_x + (m_cells[m_currentFrame].width - m_cells[m_currentFrame].x)*m_scale_x,             m_y + (m_cells[m_currentFrame].height - m_cells[m_currentFrame].y) * m_scale_y);         // upper right           glTexCoord2f(m_cells[m_currentFrame].width, m_cells[m_currentFrame].y);           glVertex2f(m_x + (m_cells[m_currentFrame].width - m_cells[m_currentFrame].x)*m_scale_x, m_y);         // upper left            glTexCoord2f(m_cells[m_currentFrame].x + 1, m_cells[m_currentFrame].y);         glVertex2f(m_x, m_y);     glEnd();                  glPopMatrix();       m_boundTexture = -1; }
  15. I previously drew my image to the color buffer. It worked fine. Now I'm trying to render it to a GL_QUAD. The image is 1280x800, which is the same as my screen resolution, and on execution I'm getting a light-gray screen. Likewise, if I have a 64x64 image on the screen, I get a gray 64x64 box. Is there anything below that might suggest why the image is not displaying appropriately? Also please note I'm using GL_TEXTURE_RECTANGLE_ARB. Thanks in advanced. bool Image::init(const string &filename) {     // Check if this is the first time initializing an image     if (refCount == 0)     {         // Init DevIL         ilInit();         iluInit();         ilutRenderer(ILUT_OPENGL);     }     // Generate the image     ilGenImages(1, &m_handle);            // Bind the current image     ilBindImage(m_handle);     glEnable(GL_TEXTURE_RECTANGLE_ARB);     glBindTexture(GL_TEXTURE_RECTANGLE_ARB, m_handle);     glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);     glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR);     glTexImage2D(GL_TEXTURE_RECTANGLE_ARB,0,ilGetInteger(IL_IMAGE_BPP),ilGetInteger(IL_IMAGE_WIDTH),ilGetInteger(IL_IMAGE_HEIGHT),0, ilGetInteger(IL_IMAGE_FORMAT), GL_UNSIGNED_BYTE,ilGetData());     // load the image     if (!ilLoadImage(filename.c_str())) {         ilDeleteImages(1, &m_handle);           return false;     }              // Check if image is backwards     if (ilGetInteger(IL_IMAGE_ORIGIN) != IL_ORIGIN_LOWER_LEFT) {         m_flipped = true;         iluFlipImage();     }     ilOriginFunc(IL_ORIGIN_UPPER_LEFT);        ilEnable(IL_ORIGIN_SET);        // convert to IL_RGBA     ilConvertImage(IL_RGBA, IL_UNSIGNED_BYTE);       // get the image's width and height     m_width = ilGetInteger(IL_IMAGE_WIDTH);     m_height = ilGetInteger(IL_IMAGE_HEIGHT);     m_size = ilGetInteger(IL_IMAGE_SIZE_OF_DATA);     m_imageType = ilGetInteger(IL_IMAGE_TYPE);     // Set initial color components     m_red = 1.0f;     m_green = 1.0f;     m_blue = 1.0f;     m_alpha = 1.0f;          // Increase the reference count     refCount++;     // Show state     m_show = true;          GLfloat m_lights[4];     m_lights[0] = 1.0f;     m_lights[1] = 1.0f;     m_lights[2] = 1.0f;     m_lights[3] = 1.0f;     glEnable(GL_LIGHTING);     glLightfv(GL_LIGHT0,GL_DIFFUSE,m_lights);     glEnable(GL_LIGHT0);     return true; } void Image::draw() {     if (!m_show)         return;     //ilBindImage(m_handle);     glBindTexture(GL_TEXTURE_RECTANGLE_ARB, m_handle);            // Set color scale     glPixelTransferf(GL_RED_SCALE, m_red);     glPixelTransferf(GL_GREEN_SCALE, m_green);     glPixelTransferf(GL_BLUE_SCALE, m_blue);     glPixelTransferf(GL_ALPHA_SCALE, m_alpha);     // Draw to color buffer     //glRasterPos2f(m_x, m_y + m_height);       //glDrawPixels(ilGetInteger(IL_IMAGE_WIDTH), ilGetInteger(IL_IMAGE_HEIGHT),     //    ilGetInteger(IL_IMAGE_FORMAT), GL_UNSIGNED_BYTE, ilGetData());     glPushMatrix();     glTranslatef(m_x, m_y, 0.0f);     glBegin(GL_QUADS);         glTexCoord2f(0,0);         glVertex2f(0, m_height);         glTexCoord2f(m_width, 0);         glVertex2i(m_width, m_height);                  glTexCoord2f(m_width, m_height);         glVertex2i(m_width, 0);                  glTexCoord2i(0, m_height);         glVertex2i(0,0);     glEnd();     glPopMatrix(); } Ortho: void Game_Resize(int width, int height) {     // Prevent divide by zero     if (height == 0)         height = 1;     // Set viewport     glViewport(0, 0, width, height);     // Reset coordinate system     glMatrixMode(GL_PROJECTION);     glLoadIdentity();          gluOrtho2D(0.0, win.getInitialWidth(), win.getInitialHeight(), 0.0);     // Model view     glMatrixMode(GL_MODELVIEW);     glLoadIdentity(); }