El mapeo de texturas OpenGL se niega obstinadamente a trabajar

Estoy escribiendo un juego 2D usando SDL y OpenGL en el lenguaje de programación D. Por el momento, simplemente trata de representar un quad mapeado de textura en la pantalla. El problema es que toda la parte del mapeo de texturas no parece funcionar. A pesar de que la textura aparentemente carga bien (se le asigna un número de textura distinto de cero, no hace que glGetError devuelva valores distintos de cero), el quad se representa con el último color establecido en glColor, ignorando por completo la textura.

He buscado razones comunes para que el mapeo de texturas falle, incluyendoesta pregunta, en vano. El archivo de imagen que se está cargando es 64x64, un tamaño válido de potencia de 2.

Por favor, no se asuste porque esto está en D, es casi completamente llamadas SDL y OpenGL de estilo C.

Código de inicialización de SDL:

if (SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1) == -1 ||
    SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0) == -1)
    throw new Exception("An OpenGL attribute could not be set!");

uint videoFlags = SDL_OPENGL | SDL_HWSURFACE | SDL_ANYFORMAT;

if (threadsPerCPU() > 1)
    videoFlags |= SDL_ASYNCBLIT;

SDL_Surface* screen = SDL_SetVideoMode(800, 600, 32, videoFlags);

if (screen == null)
    throw new Exception("SDL_SetVideoMode failed!");

Código de inicialización de OpenGL:

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0., 800, 600, 0., 0., 1.);
glMatrixMode(GL_MODELVIEW);

glDisable(GL_DEPTH_TEST);
glDisable(GL_LIGHTING);

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

glEnable(GL_TEXTURE_2D);

glClearColor(0.f, 0.f, 0.f, 0.f);

Código de carga de textura:

SDL_Surface* s = IMG_Load(toStringz("hello.png"));

if (s == null)
    throw new Exception("Image file could not be loaded!");

uint texFormat;

switch (s.format.BytesPerPixel)
{
case 4:
    texFormat = (s.format.Rmask == 0x000000ff ? GL_RGBA : GL_BGRA);
    break;
case 3:
    texFormat = (s.format.Rmask == 0x000000ff ? GL_RGB : GL_BGR);
    break;
default:
    throw new Exception("Bad pixel format!");
    break;
}

if ((s.w & (s.w - 1)) != 0)
    throw new Exception("Width must be a power of 2!");
if ((s.h & (s.h - 1)) != 0)
    throw new Exception("Height must be a power of 2!");

uint glName;

glGenTextures(1, &glName);

glBindTexture(GL_TEXTURE_2D, glName);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexImage2D(GL_TEXTURE_2D, 0, s.format.BytesPerPixel, s.w, s.h, 0,
    texFormat, GL_UNSIGNED_BYTE, s.pixels);

SDL_FreeSurface(s);

Código de renderizado:

glClear(GL_COLOR_BUFFER_BIT);

glBegin(GL_QUADS);
    glColor4ub(255, 255, 255, 255);
    glBindTexture(GL_TEXTURE_2D, glName);
    glTexCoord2i(0, 0); glVertex2i(0, 0);
    glTexCoord2i(1, 0); glVertex2i(64, 0);
    glTexCoord2i(1, 1); glVertex2i(64, 64);
    glTexCoord2i(0, 1); glVertex2i(0, 64);
glEnd();

SDL_GL_SwapBuffers();

Mi programa usa Derelict2, una biblioteca que proporciona enlaces SDL y OpenGL para D.

¿Alguna idea de lo que está pasando mal aquí?

Editar: Para referencia futura, aquí está la solución a mi problema:

http://www.opengl.org/wiki/Common_Mistakes#Creating_a_Texture

Necesitaba establecer un par de parámetros antes de llamarglTexImage2D o de lo contrario mi textura era técnicamente incompleta. Agregar las siguientes cuatro líneas justo antes de esa llamada hizo el truco:

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

Respuestas a la pregunta(4)

Su respuesta a la pregunta