• Content count

  • Joined

  • Last visited

Community Reputation

104 Neutral

About Monkey_Missile

  • Rank
  1. OpenGL Problem loading a particular .png file

    Great feedback! Thanks I will use this.
  2. OpenGL Problem loading a particular .png file

    Ugh sorry about the delay there. Here's the image load function, which part would allow me to convert the format?   GLuint mainApp::OnLoad(const std::string &fileName){ SDL_Surface *image = IMG_Load(fileName.c_str()); SDL_DisplayFormatAlpha(image); unsigned object(0); glGenTextures(1, &object); glBindTexture(GL_TEXTURE_2D, object); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image->w, image->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, image->pixels); SDL_FreeSurface(image); return object; }
  3. OpenGL Problem loading a particular .png file

    I'm using an NVIDIA GeForce GTX560 Ti. I've changed the image to a 1024x1024 and still no dice plus other non-power-of-two images still work. Changing it to a .bmp works but only if 32 bit. 16 and 24 bit still crash. Also .png files from what I gather can only be 8 bit but that can't be it since the other smaller 48x48 texture which is a .png works fine.   I was hoping to avoid .bmp files due to their size so I'll still try fixing this before doing that. If this is a problem in the beginning where openGL is being initialized then I'm not sure where to look. The code from the init is as follows:   //Initialize SDL if(SDL_Init(SDL_INIT_EVERYTHING) < 0){ return false; } //Set OpenGL memory usage SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 32); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); //Set window caption SDL_WM_SetCaption("Test", NULL); //Size of the window if(SDL_SetVideoMode(SCREEN_WIDTH,SCREEN_HEIGHT,SCREEN_BPP,SDL_OPENGL) == NULL){ return false; } //Specify the clear color and what portion of the screen will display glClearColor(0,0,0,1); glViewport(0,0,SCREEN_WIDTH,SCREEN_HEIGHT); //Shader model glShadeModel(GL_SMOOTH); //2D rendering glMatrixMode(GL_PROJECTION); glLoadIdentity(); //Depth testing only used with 3D rendering glDisable(GL_DEPTH_TEST); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  4. I've been using SDL with openGL to create a project and for some reason using IMG_Load followed by SDL_DisplayFormatAlpha causes a crash only when I use the attached file. I'm doing this in Code::Blocks so I'm not sure if the file is just too big or what. Any guesses as to what might be doing this and how to resolve it?   [attachment=14870:background.png]
  5. Help with for loops and strings when loading files.

    Washu's suggestion worked, thanks Now to get my rendering function to work. I'll be back if I get stuck again.
  6. With C++ and SDL I'm having a bit of a brain fart remembering and finding the syntax for what I'm trying to do. I have a for loop in a function that is loading files into an array. (char* file, int number) are the two parameters of the function where file is the first part of the file name and number is the number of files. I have the files named as such: example0.png example1.png example2.png The code for the for loop is as follows: [code]for (int i = 0; i < number; i++) { Array[i] = OnLoad((file) + i + ".png") ; }[/code] OnLoad is a function I have for loading files which works independently of this. My question is when I pass the parameters "example" and "3" to the function and thus this for loop how do I have the above translate it into "example0.png" and so on.
  7. Hello I've been practicing coding on and off for awhile with C++ and SDL with the intention of making 2D games and have a fairly good grasp of it. However, SDL isn't the best for doing everything I want such as rotation so I want to move into openGL for a number of reasons. Does anyone know of some good documentation or tutorials that start with a blank project and build up to an SDL->openGL environment that includes loading images from file to be used by openGL and drawing them? This includes numerous file types like .PNG files and not just .BMP files.