Hello everyone, I recently took a look at SDL 2.0 and it is undoubtedly a really good improvement from the last version but I got a problem, i can’t seem to properly use SDL_GL_BindTexture with glBegin(GL_QUADS). I initialize opengl as it should.
OpenGL Initialization
bool SDLWindow::InitOpenGL()
{
this->glcontext = SDL_GL_CreateContext(this->window);
int w, h;
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
SDL_GetWindowSize(this->window, &w, &h);
glViewport(0, 0, w, h);
glOrtho(0.0f, w, h, 0.0f, -1.0f, 1.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
GLenum error = glGetError();
if(error != GL_NO_ERROR)
{
return false;
}
return true;
}
Drawing function
void Graphics::Draw(Vector2* position, Texture2D* texture)
{
SDL_GL_BindTexture(texture->texture, (float*)texture->GetWidth(), (float*)texture->GetHeight());
glBegin(GL_QUADS);
glTexCoord2f(0, 0);
glVertex2f(position->x, position->y);
glTexCoord2f(1, 0);
glVertex2f(position->x + texture->GetWidth(), position->y);
glTexCoord2f(1, 1);
glVertex2f(position->x + texture->GetWidth(), position->y + texture->GetHeight());
glTexCoord2f(0, 1);
glVertex2f(position->x, position->y + texture->GetHeight());
glEnd();
}
This is my new function for drawing textures to the screen but it is drawing a blank rectangle -_-’ can anyone tell me what is wrong?