   Splitting image into multiple textures displaying onscreen as one image
  Hi,I'm quite new to OpenGL, and my current SDL/OpenGL (also compiles for normal SDL, but I'm keeping an OpenGL version in case I can use advanced GL effects later, plus my friend uses OpenGL a lot and I'd like him to be able to help) game project has a simple image loading and displaying system - it loads an entire image (each image having padding to raise it to powers of two) into a texture (each texture index, its image width and height are stored in a struct GLImage which is then stored in a slot in the core->gfx struct), then an area on the texture is displayed on screen using standard OpenGL logic. The current image display code is below (the IFX_NONE case blits using the current colour in the background, the IFX_UIGRAD case blits a standard gradient):/* Display an image file. */bool draw_image(GCore *core, uint8_t slot_id, uint16_t image_x, uint16_t image_y, uint16_t screen_x, uint16_t screen_y, uint16_t width, uint16_t height, uint8_t effect){  GLfloat t_x1, t_y1, t_x2, t_y2;  struct GLImage *ptex = core->gfx->images[slot_id];  if (ptex == NULL) {    return false;  } else {    t_x1 = image_x / (GLfloat) ptex->width;    t_y1 = image_y / (GLfloat) ptex->height;    t_x2 = t_x1 + ((GLfloat) width / (GLfloat)ptex->width);    t_y2 = t_y1 + ((GLfloat) height / (GLfloat)ptex->height);    glBindTexture(GL_TEXTURE_2D, ptex->index);    switch (effect) { case IFX_NONE: default:   glBegin(GL_QUADS);/* Don't assume a colour here - the code may have already    changed the colour, eg font writing routines. */glTexCoord2f(t_x1, t_y1);glVertex2f(screen_x, screen_y);glTexCoord2f(t_x2, t_y1);glVertex2f(screen_x + width, screen_y);glTexCoord2f(t_x2, t_y2);glVertex2f(screen_x + width, screen_y + height);glTexCoord2f(t_x1, t_y2);glVertex2f(screen_x, screen_y + height);   glEnd();   break; case IFX_UIGRAD:   glBegin(GL_QUADS);glColor3f(core->gfx->palette[COL_WHITE][0],core->gfx->palette[COL_WHITE][1],core->gfx->palette[COL_WHITE][2]);glTexCoord2f(t_x1, t_y1);glVertex2f(screen_x, screen_y);glTexCoord2f(t_x2, t_y1);glVertex2f(screen_x + width, screen_y);glColor3f(core->gfx->palette[COL_SYSBORDER][0] / 2,core->gfx->palette[COL_SYSBORDER][1] / 2,core->gfx->palette[COL_SYSBORDER][2] / 2);glTexCoord2f(t_x2, t_y2);glVertex2f(screen_x + width, screen_y + height);glTexCoord2f(t_x1, t_y2);glVertex2f(screen_x, screen_y + height);   glEnd();   break;    }    return true;  }}However, these images are generally full-screen size (640x400) and as such won't fit into the texture memory of, say, my 3DFX Voodoo on my legacy PC (which can only store up to 256x256).An idea I had was to partition the images into 256x256 texture chunks, arranged into a grid, and then display the relevant chunks on-screen. However, in trying to code this I realised that it would be a nightmare to adapt the above code (which allows using only a small bit of the main texture) to work with this system.Could anyone help, or advise as to other ways of getting large textures to fit in limited texture spaces?Thanks, Matt.PS: The current image-loading code isbool load_image(GCore *core, uint8_t slot_id, uint8_t file_id, bool is_alpha, uint8_t minpen, uint8_t maxpen){  GLint format = (is_alpha) ? GL_RGBA : GL_RGB;  GLuint texture;  SDL_Surface *surface;  char filename[255] = "\0";    if (core->gfx->images[slot_id] != NULL) {    free(core->gfx->images[slot_id]);  }    core->gfx->images[slot_id] = NULL;  get_filename(filename, file_id, IMAGE_FILE);    if((surface = IMG_Load((char*)filename))) {    core->gfx->images[slot_id] = malloc(sizeof(struct GLImage));    texture = 0;    glGenTextures(1, &texture);   glBindTexture(GL_TEXTURE_2D, texture);    SDL_LockSurface(surface);   glTexImage2D(GL_TEXTURE_2D, 0, format, surface->w, surface->h, 0,  format, GL_UNSIGNED_BYTE, surface->pixels);    core->gfx->images[slot_id]->index = texture;    core->gfx->images[slot_id]->width = surface->w;    core->gfx->images[slot_id]->height = surface->h;    SDL_UnlockSurface(surface);    SDL_FreeSurface(surface);    /* Sets filters for texture (smaller, larger) */    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);    return true;  } else {    fprintf(stderr, "ERROR: Couldn't load %s!\n", filename);    return false;  }}