Hello everyone,
thanks in advance for the answers.
Use Visual Express 2013 on W7.
Libraries: SDL, OpenGL.
So this is the problem, if I load a texture in OpenGL I use SDL_GL_BindTexture which in turn needs a SDL_texture.
To load SDL_texture I have to use this function SDL_CreateTextureFromSurface.
SDL_CreateTextureFromSurface needs a render that I do not use because I do have to render OpenGL instead of SDL!
myTexture.cpp
bool myTexture::loadTextureFromFile(std::string path)
{
bool success = true;
SDL_Texture* newTexture = NULL;
//Load image at specified path
SDL_Surface* loadedSurface = IMG_Load(path.c_str());
if (loadedSurface == NULL)
{
printf("Unable to load image %s! SDL_image Error: %s
", path.c_str(), IMG_GetError());
}
else
{
//Create texture from surface pixels
//newTexture = SDL_CreateTextureFromSurface(gRenderer, loadedSurface);//<######################problem!
if (newTexture == NULL)
{
printf("Unable to create texture from %s! SDL Error: %s
", path.c_str(), SDL_GetError());
}
//Get rid of old loaded surface
SDL_FreeSurface(loadedSurface);
}
mTexture = newTexture;
return success;
}
myWindow.cpp
bool myWindow::init()
{
printf("
InitWindowSDL________________
");
//Create window
mWindow = SDL_CreateWindow("window", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_OPENGL | SDL_WINDOW_HIDDEN | SDL_WINDOW_RESIZABLE);
if (mWindow != NULL)
{
mMouseFocus = true;
mKeyboardFocus = true;
mWidth = SCREEN_WIDTH;
mHeight = SCREEN_HEIGHT;
//Create renderer for window
mContext = SDL_GL_CreateContext(mWindow);
if (mContext == NULL)
{
printf("Errore SDL_GL_CreateContext():
%s
", SDL_GetError());
SDL_DestroyWindow(mWindow);
mWindow = NULL;
}
else
{
printf("Context creato.
");
//Grab window identifier
mWindowID = SDL_GetWindowID(mWindow);
printf("Finestra creata: %d.
", mWindowID);
//Flag as opened
mShown = false;
}
}
else
{
printf("Errore SDL_CreateWindow():
%s
", SDL_GetError());
}
printf("_____________________________
");
return mWindow != NULL && mContext != NULL;
}
The question is I have to create a dummy invisible window in the class myTexture to have the render I need or there are other features that I can use in place of SDL_CreateTextureFromSurface?
PS: Sorry for my english.