Inconsistent full screen quad

Inconsistent full screen quad

Post by k3 » Thu, 26 Jun 2003 23:37:30



Hi,

I'm trying to render a full screen quad in ortho mode. My code works in a
tiny test program, but when I use it my main program the texture no longer
shows... only the quad's color fills the screen.  So I'm wondering what can
affect it after I loaded and binded the texture before use with proper
texture coordinates?

Thanks in advance

Here's some code:

// Go in 2D mode
glPushAttrib(GL_LIGHTING_BIT|GL_DEPTH_BUFFER_BIT);
glDisable(GL_LIGHTING);
glDisable(GL_DEPTH_TEST);
glViewport(0, 0, m_iWidth, m_iHeight);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0.0, (GLdouble)m_iWidth, 0.0, (GLdouble)m_iHeight, 1.0, -1.0);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();

// Draw the texture mapped quad
glPushMatrix();
    glColor3f(0.0, 0.0, 1.0);
    glBindTexture(GL_TEXTURE_2D, m_Texture[0].texID);
    glEnable(GL_TEXTURE_2D);
    glBegin(GL_QUADS);
        glTexCoord2i(0, 1); glVertex2i(0, m_iHeight);
        glTexCoord2i(0, 0); glVertex2i(0, 0);
        glTexCoord2i(1, 0); glVertex2i(m_iWidth, 0);
        glTexCoord2i(1, 1); glVertex2i(m_iWidth, m_iHeight);
    glEnd();
    glDisable(GL_TEXTURE_2D);
    glColor3f(0.5, 0.5, 0.5);
glPopMatrix();

// Leave 2D mode
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopAttrib();

// Texture Loading code
char* strTexNames[] = {"textures/menu.bmp",
                       "textures/setup.bmp",
                       "textures/credits.bmp"};

for (int i = 0; i < 3; i++)
{
    m_Texture[i].LoadTexture(strTexNames[i]);

Quote:}

glGenTextures(3, m_uiTexID);

for (i = 0; i < 3; i++)
{
    m_Texture[i].texID = m_uiTexID[i];

Quote:}

for (i = 0; i < 3; i++)
{
    glBindTexture(GL_TEXTURE_2D, m_Texture[i].texID);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
    gluBuild2DMipmaps(GL_TEXTURE_2D, 3, m_Texture[i].width,
m_Texture[i].height,
                      GL_RGB, GL_UNSIGNED_BYTE, m_Texture[i].data);
Quote:}

 
 
 

Inconsistent full screen quad

Post by k3 » Thu, 26 Jun 2003 23:55:04


Ok I've just noticed that glGenTextures(3, array) doesn't generate the
texture IDs... The array holding the texture ID never change after the call.
How's this possible?


| Hi,
|
| I'm trying to render a full screen quad in ortho mode. My code works in a
| tiny test program, but when I use it my main program the texture no longer
| shows... only the quad's color fills the screen.  So I'm wondering what
can
| affect it after I loaded and binded the texture before use with proper
| texture coordinates?
|
| Thanks in advance
|
| Here's some code:
|
| // Go in 2D mode
| glPushAttrib(GL_LIGHTING_BIT|GL_DEPTH_BUFFER_BIT);
| glDisable(GL_LIGHTING);
| glDisable(GL_DEPTH_TEST);
| glViewport(0, 0, m_iWidth, m_iHeight);
| glMatrixMode(GL_PROJECTION);
| glPushMatrix();
| glLoadIdentity();
| glOrtho(0.0, (GLdouble)m_iWidth, 0.0, (GLdouble)m_iHeight, 1.0, -1.0);
| glMatrixMode(GL_MODELVIEW);
| glPushMatrix();
| glLoadIdentity();
|
| // Draw the texture mapped quad
| glPushMatrix();
|     glColor3f(0.0, 0.0, 1.0);
|     glBindTexture(GL_TEXTURE_2D, m_Texture[0].texID);
|     glEnable(GL_TEXTURE_2D);
|     glBegin(GL_QUADS);
|         glTexCoord2i(0, 1); glVertex2i(0, m_iHeight);
|         glTexCoord2i(0, 0); glVertex2i(0, 0);
|         glTexCoord2i(1, 0); glVertex2i(m_iWidth, 0);
|         glTexCoord2i(1, 1); glVertex2i(m_iWidth, m_iHeight);
|     glEnd();
|     glDisable(GL_TEXTURE_2D);
|     glColor3f(0.5, 0.5, 0.5);
| glPopMatrix();
|
| // Leave 2D mode
| glMatrixMode(GL_MODELVIEW);
| glPopMatrix();
| glMatrixMode(GL_PROJECTION);
| glPopMatrix();
| glMatrixMode(GL_MODELVIEW);
| glPopAttrib();
|
|
| // Texture Loading code
| char* strTexNames[] = {"textures/menu.bmp",
|                        "textures/setup.bmp",
|                        "textures/credits.bmp"};
|
| for (int i = 0; i < 3; i++)
| {
|     m_Texture[i].LoadTexture(strTexNames[i]);
| }
|
| glGenTextures(3, m_uiTexID);
|
| for (i = 0; i < 3; i++)
| {
|     m_Texture[i].texID = m_uiTexID[i];
| }
|
| for (i = 0; i < 3; i++)
| {
|     glBindTexture(GL_TEXTURE_2D, m_Texture[i].texID);
|     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|     glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
|     gluBuild2DMipmaps(GL_TEXTURE_2D, 3, m_Texture[i].width,
| m_Texture[i].height,
|                       GL_RGB, GL_UNSIGNED_BYTE, m_Texture[i].data);
| }
|
|
|

 
 
 

Inconsistent full screen quad

Post by fungu » Thu, 26 Jun 2003 23:55:56



> Ok I've just noticed that glGenTextures(3, array) doesn't generate the
> texture IDs... The array holding the texture ID never change after the call.
> How's this possible?

Do you have aq valid rendering context?

--
<\___/>          For email, remove my socks.
/ O O \
\_____/  FTB.    Why isn't there mouse-flavored cat food?

 
 
 

Inconsistent full screen quad

Post by Roger Rowlan » Thu, 26 Jun 2003 23:57:15


You have a valid rendering context when you load the textures? I can't tell
when you call that from the code you posted.....


> Ok I've just noticed that glGenTextures(3, array) doesn't generate the
> texture IDs... The array holding the texture ID never change after the
call.
> How's this possible?



> | Hi,
> |
> | I'm trying to render a full screen quad in ortho mode. My code works in
a
> | tiny test program, but when I use it my main program the texture no
longer
> | shows... only the quad's color fills the screen.  So I'm wondering what
> can
> | affect it after I loaded and binded the texture before use with proper
> | texture coordinates?
> |
> | Thanks in advance
> |
> | Here's some code:
> |
> | // Go in 2D mode
> | glPushAttrib(GL_LIGHTING_BIT|GL_DEPTH_BUFFER_BIT);
> | glDisable(GL_LIGHTING);
> | glDisable(GL_DEPTH_TEST);
> | glViewport(0, 0, m_iWidth, m_iHeight);
> | glMatrixMode(GL_PROJECTION);
> | glPushMatrix();
> | glLoadIdentity();
> | glOrtho(0.0, (GLdouble)m_iWidth, 0.0, (GLdouble)m_iHeight, 1.0, -1.0);
> | glMatrixMode(GL_MODELVIEW);
> | glPushMatrix();
> | glLoadIdentity();
> |
> | // Draw the texture mapped quad
> | glPushMatrix();
> |     glColor3f(0.0, 0.0, 1.0);
> |     glBindTexture(GL_TEXTURE_2D, m_Texture[0].texID);
> |     glEnable(GL_TEXTURE_2D);
> |     glBegin(GL_QUADS);
> |         glTexCoord2i(0, 1); glVertex2i(0, m_iHeight);
> |         glTexCoord2i(0, 0); glVertex2i(0, 0);
> |         glTexCoord2i(1, 0); glVertex2i(m_iWidth, 0);
> |         glTexCoord2i(1, 1); glVertex2i(m_iWidth, m_iHeight);
> |     glEnd();
> |     glDisable(GL_TEXTURE_2D);
> |     glColor3f(0.5, 0.5, 0.5);
> | glPopMatrix();
> |
> | // Leave 2D mode
> | glMatrixMode(GL_MODELVIEW);
> | glPopMatrix();
> | glMatrixMode(GL_PROJECTION);
> | glPopMatrix();
> | glMatrixMode(GL_MODELVIEW);
> | glPopAttrib();
> |
> |
> | // Texture Loading code
> | char* strTexNames[] = {"textures/menu.bmp",
> |                        "textures/setup.bmp",
> |                        "textures/credits.bmp"};
> |
> | for (int i = 0; i < 3; i++)
> | {
> |     m_Texture[i].LoadTexture(strTexNames[i]);
> | }
> |
> | glGenTextures(3, m_uiTexID);
> |
> | for (i = 0; i < 3; i++)
> | {
> |     m_Texture[i].texID = m_uiTexID[i];
> | }
> |
> | for (i = 0; i < 3; i++)
> | {
> |     glBindTexture(GL_TEXTURE_2D, m_Texture[i].texID);
> |     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
> |     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
> |     glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
> |     gluBuild2DMipmaps(GL_TEXTURE_2D, 3, m_Texture[i].width,
> | m_Texture[i].height,
> |                       GL_RGB, GL_UNSIGNED_BYTE, m_Texture[i].data);
> | }
> |
> |
> |

 
 
 

1. Capture Screen in DirectX full screen application

Does anyone know a method to capture the screen or individual pictures in a
DirectX full screen application?  I put together an implementation using
GetPixel API call, which worked great in windowed mode, but fails to get
good data when the application I'm trying to screen scrape is in full screen
mode.

Any help would be appreciated.  Thanks.

2. Thinking about a dual processor?

3. Changing screen resolution in full-screen programs?

4. Spline Patching or METANurbing?

5. Converting from Wide Screen to Full Screen

6. need help files for max 2.0

7. full screen MFC application but directX on part of the screen

8. OT: Rambooster

9. Drawing to the Screen Question, and Window/Full Screen Question

10. intersection test quad-quad

11. Quad-Quad intersection area

12. Sorting triangles or quads for tri or quad meshes

13. quad -> 100 quads