Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7561619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:12:11+00:00 2026-05-30T13:12:11+00:00

im trying to get multi texturing working and have so far got miltiple textures

  • 0

im trying to get multi texturing working and have so far got miltiple textures to load using this function

def loadTexture(name):

    img = PIL.Image.open(name) # .jpg, .bmp, etc. also work
    img_data = numpy.array(list(img.getdata()), numpy.int8)

    id = glGenTextures(1)
    glPixelStorei(GL_UNPACK_ALIGNMENT,1)
    glBindTexture(GL_TEXTURE_2D, id)
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP)
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP)
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, img.size[0], img.size[1], 0, GL_RGB, GL_UNSIGNED_BYTE, img_data)
    return id

And I can set the texture to use with this code

glBindTexture(GL_TEXTURE_2D, 1)
glEnable(GL_TEXTURE_2D)

My first attempt has been this:

glBindTexture(GL_TEXTURE_2D, 1)
glEnable(GL_TEXTURE_2D)
glBegin(GL_TRIANGLES)
....
glEnd()

glBindTexture(GL_TEXTURE_2D, 3)
glEnable(GL_TEXTURE_2D)
glBegin(GL_TRIANGLES)
....
glEnd()

So i render the polys twice and select a different texture each time, this seems to work in as much as calling glBindTexture(GL_TEXTURE_2D, n) will select the relivant texture and it will render but there is no blending going on per se, i just see the last selected texture in the render. I’ve tried adding glEnable(GL_BLEND), but that doesn’t seem to do anything.

What I would like to do is to add pixels of the two passes together

How would I go about this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T13:12:12+00:00Added an answer on May 30, 2026 at 1:12 pm

    Are you sure that you need multiple passes? Here is an example of plain old OpenGL multitexturing:

    import pygame
    from pygame.locals import *
    
    import numpy
    import numpy.linalg
    
    from OpenGL.GL import *
    from OpenGL.GL.shaders import *
    
    RESOLUTION = (800,600)
    
    POSITIONS = numpy.array([[-1.0, -1.0], [+1.0, -1.0], [-1.0, +1.0], [+1.0, +1.0]], dtype=numpy.float32)
    TEXCOORDS = numpy.array([[0.0, 1.0], [1.0, 1.0], [0.0, 0.0], [1.0, 0.0]], dtype=numpy.float32)
    
    from PIL import Image
    
    tex0 = 0
    tex1 = 0
    
    def loadTexture(path):
        img = Image.open(path)
        img = img.convert("RGBA") 
        img_data = numpy.array(list(img.getdata()), numpy.int8)
    
        texture = glGenTextures(1)
        glPixelStorei(GL_UNPACK_ALIGNMENT,1)
        glBindTexture(GL_TEXTURE_2D, texture)
        glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP)
        glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP)
        glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
        glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, img.size[0], img.size[1], 0, GL_RGBA, GL_UNSIGNED_BYTE, img_data)
    
        return texture
    
    def init():
        global tex0
        global tex1
    
        tex0 = loadTexture("texture0.png")
        tex1 = loadTexture("texture1.png")
    
        glViewport(0, 0, *RESOLUTION)
    
        aspect = RESOLUTION[0]/float(RESOLUTION[1])
    
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glOrtho(-aspect, +aspect, -1.0, +1.0, -1.0, +1.0);
    
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
    
        glClearColor(0.0, 0.0, 0.0, 1.0);
    
        glVertexPointer(2, GL_FLOAT, 0, POSITIONS);
        glEnableClientState(GL_VERTEX_ARRAY);
    
        glClientActiveTexture(GL_TEXTURE0);
        glTexCoordPointer(2, GL_FLOAT, 0, TEXCOORDS); 
        glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    
        glClientActiveTexture(GL_TEXTURE1);
        glTexCoordPointer(2, GL_FLOAT, 0, TEXCOORDS);
        glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    
    def draw():
        glClear(GL_COLOR_BUFFER_BIT);
    
        glActiveTexture(GL_TEXTURE0);
        glEnable(GL_TEXTURE_2D);
        glBindTexture(GL_TEXTURE_2D, tex0);
        glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
    
        glActiveTexture(GL_TEXTURE1);
        glEnable(GL_TEXTURE_2D);
        glBindTexture(GL_TEXTURE_2D, tex1);
        glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
    
        glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
    
    def main():
        pygame.init()
    
        screen = pygame.display.set_mode(RESOLUTION, OPENGL | DOUBLEBUF)
    
        init()
    
        while True:
            for event in pygame.event.get():
                if event.type == QUIT: return
    
            draw()
    
            pygame.display.flip()
    
    if __name__ == "__main__":
        main()
    

    Have a look at Texture Combiners, they may enable the type of effect you are looking for. Of course, the state of the art for this kind of thing nowadays are shaders.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm trying to get multi tenancy working in my app - using nhibernate integration
Trying to get this example working from http://www.munna.shatkotha.com/blog/post/2008/10/26/Light-box-effect-with-WPF.aspx However, I can't seem to get
I am trying to get a multi-page two-dimensional lattice panel plot to have the
I'm trying to get tipfy working on Google App Engine (GAE). I'm using Windows
I am trying to create a multi dimensional array using this syntax: $x[1] =
I'm trying to get this function to display the literal expr2 and expr1 as
I am trying to parse a multi line string and get the rest of
I'm trying to make my C# application multi threaded because sometimes, I get an
I'm trying get values from a GridView using the following code: foreach (GridViewRow row
Trying to get my css / C# functions to look like this: body {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.