Jump to content

  • Log In with Google      Sign In   
  • Create Account


Monkey_Missile

Member Since 13 Feb 2012
Offline Last Active Apr 24 2013 04:54 PM

Posts I've Made

In Topic: Problem loading a particular .png file

24 April 2013 - 04:53 PM

Great feedback! Thanks I will use this.


In Topic: Problem loading a particular .png file

19 April 2013 - 07:47 PM

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;
}

In Topic: Problem loading a particular .png file

15 April 2013 - 08:44 PM

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);

In Topic: Help with for loops and strings when loading files.

20 February 2012 - 08:33 PM

Washu's suggestion worked, thanks :) Now to get my rendering function to work. I'll be back if I get stuck again.

PARTNERS