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 7412983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:37:33+00:00 2026-05-29T06:37:33+00:00

Im trying to display a simple immediate mode sets of textured polygons with pyOpenGL

  • 0

Im trying to display a simple immediate mode sets of textured polygons with pyOpenGL with no luck. I have lashed together some code that loads a some geometry data and that all works fine and as far as I can tell I have all the code to add a texture to it but just getting white polys.

Here’s the important bits of the code:

self.img = PIL.Image.open('/projects/openGL_robot_face/facemap.png')
self.image_data = numpy.array(list(self.img.getdata()), numpy.uint8)

def paintGL(self):
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)


    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_RGB, self.img.size[0], self.img.size[1], 0, GL_RGB, GL_UNSIGNED_BYTE, self.image_data)

    glMatrixMode(GL_MODELVIEW)
    glLoadIdentity()
    glTranslate(0.0, 0.0, -50.0)
    glScale(20.0, 20.0, 20.0)
    glRotate(self.yRotDeg, 0.2, 1.0, 0.3)
    glTranslate(-0.5, -0.5, -0.5)

    glBegin(GL_TRIANGLES)
    for vert in self.poly_verts:
        glTexCoord2f(vert[6], vert[7])
        glVertex3f(vert[0], vert[1], vert[2])

    glEnd()
  • 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-29T06:37:34+00:00Added an answer on May 29, 2026 at 6:37 am

    Have you enabled textures in OpenGL, using :

    glEnable(GL_TEXTURE_2D)
    

    Also, you should not create the texture on each Paint call, you should create it once and for all (with glGenTextures, and glTex*), then store the texture ID, and do the strict minimum during Paint, which is binding with the texture.

    def paintGL(self):
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
    
        glEnable(GL_TEXTURE_2D)
        glBindTexture(GL_TEXTURE_2D, texture)
    
        glMatrixMode(GL_MODELVIEW)
        glLoadIdentity()
        glTranslate(0.0, 0.0, -50.0)
        glScale(20.0, 20.0, 20.0)
        glRotate(self.yRotDeg, 0.2, 1.0, 0.3)
        glTranslate(-0.5, -0.5, -0.5)
    
        glBegin(GL_TRIANGLES)
        for vert in self.poly_verts:
            glTexCoord2f (vert[6], vert[7]);
            glVertex3f(vert[0], vert[1], vert[2])
    
        glEnd()
        glDisable(GL_TEXTURE_2D)
    

    Unfortunately I cannot try the answer right now so this is purely from the top of my head.
    You could probably benefit from this previous post :
    Render a textured rectangle with PyOpenGL

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

Sidebar

Related Questions

I was just trying to display a progress bar. I found some reference code
I'm trying to display some simple object with texture and enable spot light in
I have a form which is a simple CRUD. I am trying to display
I am trying to display some simple info from SQLite database into QTableView. I
I use JFreeChart to display some simple data in a column chart. I have
I'm trying to display some simple computer game results and make it easy to
I'm trying to display a simple notification when a C2DM message is received. Services
I am trying to write a simple macro to display a pop-up (vbOKOnly) if
I am trying to write a very simple RSS channel which would display the
I'm trying to display a date. Sample of my viewmodel code is below: [Display(Name

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.