Note that there are some explanatory texts on larger screens.

plurals
  1. POProblems with glDrawTex_OES
    text
    copied!<p>I'm not sure I'm using glDrawTex_OES correctly. In fact, I'm sure I'm not because I'm getting a black rectangle on the screen rather than the intended texture.</p> <p>To get the silly points out of the way: Yes, the GL Extension string contains the OES_draw_texture token. Yes, the texture is loaded into memory/etc. correctly: it displays just fine if I map it to a polygon.</p> <p>From reading the various bits of <a href="http://www.khronos.org/registry/gles/extensions/OES/OES_draw_texture.txt" rel="nofollow noreferrer">documentation I can find</a> for it, it looks like I need to "configur[e] the texture crop rectangle ... via TexParameteriv() with pname equal to TEXTURE_CROP_RECT_OES". According to <a href="http://www.khronos.org/message_boards/viewtopic.php?p=2450&amp;sid=5242c63d39af53a2c39769bc0b04ffbf" rel="nofollow noreferrer">this post</a> in the khronos forums (best documentation google can find for me), the values for that are "Ucr, Vcr, Wcr, Hcr. That is, left/bottom/width/height"</p> <p>Here's the render code:</p> <pre><code>void SetUpCamera( int windowWidth, int windowHeight, bool ortho ) // only called once { glViewport( 0, 0, windowWidth, windowHeight ); glMatrixMode( GL_PROJECTION ); glLoadIdentity(); if( ortho ) { float aspect = (float)windowWidth / (float)windowHeight; float halfHeight = 32; glOrthof( -halfHeight*aspect, halfHeight*aspect, -halfHeight, halfHeight, 1.0f, 100.0f ); } else { mygluPerspective( 45.0f, (float)windowWidth / (float)windowHeight, 1.0f, 100.0f ); // I don't _actually_ have glu, but that's irrelevant--this does what you'd expect. } } void DrawTexture( int windowWidth, int windowHeight, int texID ) { // Clear back/depth buffer glClearColor( 1, 1, 1, 1 ); glClearDepth( 1.0f ); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); // Next 2 lines probably not necessary, but, you know, sanity check: glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); // set up texture glBindTexture( GL_TEXTURE_2D, texID ); // texID is the glGenTexture result for a 64x64 2D RGB_8 texture - nothing crazy. GLint coords [] = {0, 0, 64, 64}; glTexParameteriv( GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, coords ); // blit? =( glDrawTexiOES( windowWidth / 2 - 32, windowHeight - 70, 10, 64, 64 ); } </code></pre> <p>Am I missing something obvious? Doing anything just plain dumb?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload