Results 1 to 4 of 4

Thread: loading & applying texture

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2002
    Posts
    6

    loading & applying texture

    I am writing a small program which uses 35 Bitmap images as texturs at appropriate place
    but since one can't call methods related to texture once entered in glBegin() I have to load all of them at start and which obviously causes my program to run at slowest speed. Instead is it possible to use
    one common image and apply its parts as textures? If it is Possible please tell me how?(or link me to solution)

  2. #2
    Senior Member Regular Contributor
    Join Date
    May 2002
    Location
    York, UK
    Posts
    128

    Re: loading & applying texture

    Hi,

    glTexSubImage2D


    Is your friend!!!!!

    Rob.

  3. #3
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Location
    Gastonia, NC, USA
    Posts
    2,068

    Re: loading & applying texture

    The are a few examples of multiple textures in one texture file.

    Try nehe.gamedev.net for staters.


    Originally posted by OgliX:
    I am writing a small program which uses 35 Bitmap images as texturs at appropriate place
    but since one can't call methods related to texture once entered in glBegin() I have to load all of them at start and which obviously causes my program to run at slowest speed. Instead is it possible to use
    one common image and apply its parts as textures? If it is Possible please tell me how?(or link me to solution)

  4. #4
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,450

    Re: loading & applying texture

    Yes, glTexSubImage2D allows you to download them piecewise, selection of them is done with the appropriate glTexCoord values.
    Let's say they are packed in a 6x6 grid (i x j)in your case, texture coordinates go from i/6 to (i+1)/6 in u for 0 <= i <= 5, same for j and v.
    Now for the tricky part. This works nicely with neqarest filtering, but if you want to filter linearly or, even worse, mipmapped, you get in trouble. Edges can only be clamped at the real texture dimension and not in the middle of a texture. You either need to put a border around each sub-texture and/or adjust the texture coordinates a little to the inside.

    Do a search on "lightmaps" in the forum, this has been discussed before.

Similar Threads

  1. applying texture to a quad
    By minidrive in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 04-01-2013, 06:59 AM
  2. Applying texture coordinates with shaders
    By JimJones in forum OpenGL: GLSL
    Replies: 14
    Last Post: 04-29-2011, 07:14 AM
  3. Applying Texture To Cone Shape
    By glSnake in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 12-04-2009, 08:29 PM
  4. Applying texture
    By Cockney in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 01-04-2005, 10:55 AM
  5. loading textures and applying to cylinder
    By pmr2004pmr in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 12-14-2004, 01:12 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean