Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Tecture loading doesn't work ?

Threaded View

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2012
    Posts
    4

    Tecture loading doesn't work ?

    Hello Every one,

    Am new to OpenGL and i need help in the following code,


    #include<gl\gl.h>
    #include<gl\glu.h>
    #include<SDL/SDL.h>
    #include"stopwatch.cpp"
    //#include"textureloader.cpp"
    #include"cube.cpp"
    #include"gl_3D_Object/objectloader.h"
    //#include"gl_3D_Camera/SDL_OpenGL_3DCamera.h"
    #include"gl_3D_Camera/3D_Camera.cpp"
    #include"gl_3D_Skybox/SDL_openGL_3D_Skybox.h"
    #include "SDL/SDL_opengl.h"

    unsigned int loadTexture(std::string filename){
    SDL_Surface* img=SDL_LoadBMP(filename.c_str());
    if(img==NULL)return 0;
    unsigned int id;
    glGenTextures(1,&id);
    glBindTexture(GL_TEXTURE_2D,id);
    glTexImage2D(GL_TEXTURE_2D,0,GL_RGB,img->w, img->h,0,GL_RGB,GL_UNSIGNED_SHORT_5_6_5, img->pixels);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTE R,GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTE R,GL_LINEAR);
    SDL_FreeSurface(img);
    return id;
    }

    the problem is that this code used to once -_-, but now the image never gets loaded... Can anyone plz point out what i have done wrong?
    Last edited by _Steam; 07-06-2012 at 04:51 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •