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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:41:03+00:00 2026-06-10T00:41:03+00:00

I’m writing a plugin for an application called Autodesk MotionBuilder, which has an OpenGL

  • 0

I’m writing a plugin for an application called Autodesk MotionBuilder, which has an OpenGL renderer, and I’m trying to render textured geometry into the scene. I have a window with a 3D View embedded in it, and every time my window is rendered, this is (in a nutshell) what happens:

  1. I tell the renderer that I’m about to draw into a region with a given size
  2. I tell the renderer to draw the MotionBuilder scene in that region
  3. I draw some additional stuff into and/or on top of the scene

The challenge here is that I’m inheriting some arbitrary OpenGL state from MotionBuilder’s renderer, which varies depending on what it’s drawing and what’s present in the scene. I’ve been dealing with this fine so far, but there’s one thing I can’t figure out. The way that OpenGL interprets my UV coordinates seems to change based on whatever MotionBuilder is doing behind my back.

Here’s my rendering code. If there’s no textured geometry in the scene, meaning MotionBuilder hasn’t yet fiddled with any texture-related attributes, it works as expected.

// Tell MotionBuilder's renderer to draw the scene
RenderScene();

// Clear whatever arbitrary state MotionBuilder left for us
InitializeAttributes(); // includes glPushAttrib(GL_ALL_ATTRIB_BITS)
InitializePerspective(); // projects into the scene / loads matrices

// Enable texturing, bind to our texture, and draw a triangle into the scene
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, mTexture);

glBegin(GL_TRIANGLES);
glColor4f(1.0, 1.0, 1.0, 0.5f);
    glTexCoord2f(1.0, 0.0); glVertex3f(128.0,   0.0, 0.0);
    glTexCoord2f(0.0, 1.0); glVertex3f(  0.0, 128.0, 0.0);
    glTexCoord2f(0.0, 0.0); glVertex3f(  0.0,   0.0, 0.0);
glEnd();

// Clean up so we don't confound MotionBuilder's initial expectations
RestoreState(); // includes glPopAttrib()

Now, if I bring in some meshes with textures, something odd happens. My texture coordinates get scaled way up. Here’s a before and after:

mbtexture.jpg
(source: awforsythe.com)

As you can see from the close-up on the right, when MotionBuilder is asked to render a texture whose file it can’t find, it instead loads this small question mark texture and tiles it across the geometry. My only hypothesis is that MotionBuilder is changing some global texture coordinate scalar so that, for example, glTexCoord2f(0.5, 1.0) will instead be interpreted as if it were (50.0, 100.0). Is there such a feature in OpenGL? Any idea what I need to modify in order to preserve my texture coordinates as I’ve entered them?


Since typing the above and after doing a bit of research, I have discovered that there’s a GL_TEXTURE matrix that’s used to this effect. Neat! And indeed, when I get the value of this matrix initially, it’s the good ol’ identity matrix:

 1  0  0  0
 0  1  0  0
 0  0  1  0
 0  0  0  1

When I check it again after MotionBuilder fudges up my texture coordinates:

16  0  0  0
 0 16  0  0
 0  0  1  0
 0  0  0  1

How telling! But here’s a slight problem: if I try to explicitly set the texture matrix before doing my own drawing, regardless of what MotionBuilder is doing, it seems like my texture coordinates have no effect and it simply samples the lower-left corner of the texture (0.0, 0.0) for every vertex.

Here’s the attempted fix, placed after RenderScene in the code posted above:

glMatrixMode(GL_TEXTURE);
glLoadIdentity();

I can verify that the value of GL_TEXTURE_MATRIX is now the identity matrix, but no matter what coordinates I specify in glTexCoord2f, it’s always drawn as if the coordinates for each vertex were (0.0, 0.0):

mbtexturematrix.jpg
(source: awforsythe.com)

Any idea what else could be affecting how OpenGL interprets my texture coordinates?

  • 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-06-10T00:41:05+00:00Added an answer on June 10, 2026 at 12:41 am

    Aha! These calls:

    glMatrixMode(GL_TEXTURE);
    glLoadIdentity();
    

    …have to be made after GL_TEXTURE_2D is enabled.

    …should be followed up by setting the matrix mode back to GL_MODELVIEW. It turns out, apparently, that some functions I was calling immediately after resetting the texture matrix (glViewport and/or gluPerspective?) affect the current matrix stack. So those calls were affecting the texture matrix, causing my texture coordinates to be transformed in unexpected ways.

    I think I’ve got it now.

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to select an H1 element which is the second-child in its group
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function

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.