OpenGL and pixel access

Instead of trying to find those coordinates, as simpler way is to setup
an orthographics (“2D”) projection matrix:

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0,WIDTH,HEIGHT,0);

… when you want to paint your background texture, because that is what
you want to use, not glDrawPixels(). OpenGL is made for textures on modern
hardware. So, upload your background picture to some OpenGL texture,
and the first thing you do in your rendering routine, draw this texture,
then go back to 3d-projection matrix or what have you, and draw the rest
of the scene. Note that you don’t have to glClear(GL_COLOR_BUFFER_BIT|
GL_DEPTH_BUFFER_BIT) then but only glClear(GL_DEPTH_BUFFER_BIT)…
To switch between the to projection matrixes, you might want to use
the matrix stack glPushMatrix()/glPopMatrix for convenience…
Just remenber to switch back to MODELVIEW matrix, that’s a very common
bug for me :wink:

Hi,

What am i doing wrong with the next code ?

void DrawGLScene()
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho( 0, 1024, 768, 0, 1.0, -1.0 );

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

// glClear(GL_COLOR_BUFFER_BIT);
// glRasterPos2f( -1.0, -1.0 );
// glDrawPixels( bg->w, bg->h, GL_RGB, GL_UNSIGNED_BYTE, bg->pixels);

glBindTexture(GL_TEXTURE_2D, textureId);

glBegin(GL_QUADS);
glNormal3f( 0.0f, 0.0f, 1.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f);
glEnd();
}

where ‘textureId’ is a GLuint pointing to a valid texture previously
loaded with

GLvoid BindGLTexture(SDL_Surface *image)
{
glGenTextures(1, &textureId);
glBindTexture(GL_TEXTURE_2D, textureId);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, 3, image->w, image->h, 0, GL_RGB,
GL_UNSIGNED_BYTE, image->pixels);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, image->w, image->h, GL_RGB,
GL_UNSIGNED_BYTE, image->pixels);
}

Thanks,
Jorge

jorgefm at cirsa.com: “Re: [SDL] OpenGL and pixel access” (2004-05-20…#

#>Instead of trying to find those coordinates, as simpler way is to setup
#>an orthographics (“2D”) projection matrix:
#>
#> glMatrixMode(GL_PROJECTION);
#> glLoadIdentity();
#> glOrtho(0,WIDTH,HEIGHT,0);
#>
#>… when you want to paint your background texture, because that is what
#>you want to use, not glDrawPixels(). OpenGL is made for textures on modern
#>hardware. So, upload your background picture to some OpenGL texture,
#>and the first thing you do in your rendering routine, draw this texture,
#>then go back to 3d-projection matrix or what have you, and draw the rest
#>of the scene. Note that you don’t have to glClear(GL_COLOR_BUFFER_BIT|
#>GL_DEPTH_BUFFER_BIT) then but only glClear(GL_DEPTH_BUFFER_BIT)…
#>To switch between the to projection matrixes, you might want to use
#>the matrix stack glPushMatrix()/glPopMatrix for convenience…
#>Just remenber to switch back to MODELVIEW matrix, that’s a very common
#>bug for me :wink:

#Hi,

#What am i doing wrong with the next code ?

#void DrawGLScene()
#{

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

glOrtho( 0, 1024, 768, 0, 1.0, -1.0 );

Should really be -1.0, 1.0; NEAR then FAR.

glMatrixMode(GL_MODELVIEW);

glLoadIdentity();

#// glClear(GL_COLOR_BUFFER_BIT);
#// glRasterPos2f( -1.0, -1.0 );
#// glDrawPixels( bg->w, bg->h, GL_RGB, GL_UNSIGNED_BYTE, bg->pixels);

glBindTexture(GL_TEXTURE_2D, textureId);

glBegin(GL_QUADS);

glNormal3f( 0.0f, 0.0f, 1.0f);

glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f);

glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f);

glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f);

glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f);

glEnd();

#}

You might want to place the quad at z coordinate -1 which is
furthest away from the viewer. Right now your placing it at
the closest possible location - meaning in practice you can’t
draw anything ontop of it with the depth buffer on.
Or maybe you aren’t using GL_DEPTH at all?

#where ‘textureId’ is a GLuint pointing to a valid texture previously
#loaded with

#GLvoid BindGLTexture(SDL_Surface *image)
#{

glGenTextures(1, &textureId);

glBindTexture(GL_TEXTURE_2D, textureId);

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);

glTexImage2D(GL_TEXTURE_2D, 0, 3, image->w, image->h, 0, GL_RGB,

GL_UNSIGNED_BYTE, image->pixels);

gluBuild2DMipmaps(GL_TEXTURE_2D, 3, image->w, image->h, GL_RGB,

GL_UNSIGNED_BYTE, image->pixels);

#}

The texture loading should work, but the TexImage2d call is
redundant; gluBuild2DMipmaps takes care of the 0 level (default)
too. But why use mipmaps if your only going to draw your background
at one specific distance? Mipmaps are really used for minifying
textured polygons nicely. Anyway, you use the GL_NEAREST filter
which TURNS OFF mipmapping, so what is really reduntant is the
gluBuild2DMipmaps call when I come to think about it :wink:

Have you glEnable(GL_TEXTURE_2D)? Common mistake for me…

/Olof

#Thanks,
#Jorge

#_______________________________________________
#SDL mailing list
#SDL at libsdl.org
#http://www.libsdl.org/mailman/listinfo/sdl

The Z-coords for your quad are right at the near culling plane. Try
drawing the quad at a depth of 0.0. You will then probably need to
fiddle with the depth buffer a bit, or the 3d scene you’re trying to
draw might be occluded behind your backing quad.

To start, change those Z coordinates and see if that fixes it. If that
works, before you start drawing things in 3d, to ensure they are not
improperly occluded, I suggest

glDisable(GL_DEPTH_TEST);
/* draw the quad in orthographic projection /
glClear(GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
/
draw my 3d scene */

This will prevent the background from occluding anything drawn later in
3D (if that is what you want…), with pretty good performance. As
others have said, clearing the actual framebuffer isn’t necessary,
because you’re going to draw over it all anyway.

Richard SchreyerOn May 20, 2004, at 1:49 AM, jorgefm at cirsa.com wrote:

Instead of trying to find those coordinates, as simpler way is to
setup
an orthographics (“2D”) projection matrix:

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0,WIDTH,HEIGHT,0);

… when you want to paint your background texture, because that is
what
you want to use, not glDrawPixels(). OpenGL is made for textures on
modern
hardware. So, upload your background picture to some OpenGL texture,
and the first thing you do in your rendering routine, draw this
texture,
then go back to 3d-projection matrix or what have you, and draw the
rest
of the scene. Note that you don’t have to glClear(GL_COLOR_BUFFER_BIT|
GL_DEPTH_BUFFER_BIT) then but only glClear(GL_DEPTH_BUFFER_BIT)…
To switch between the to projection matrixes, you might want to use
the matrix stack glPushMatrix()/glPopMatrix for convenience…
Just remenber to switch back to MODELVIEW matrix, that’s a very common
bug for me :wink:

Hi,

What am i doing wrong with the next code ?

void DrawGLScene()
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho( 0, 1024, 768, 0, 1.0, -1.0 );

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

// glClear(GL_COLOR_BUFFER_BIT);
// glRasterPos2f( -1.0, -1.0 );
// glDrawPixels( bg->w, bg->h, GL_RGB, GL_UNSIGNED_BYTE, bg->pixels);

glBindTexture(GL_TEXTURE_2D, textureId);

glBegin(GL_QUADS);
glNormal3f( 0.0f, 0.0f, 1.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 1.0f);
glEnd();
}

where ‘textureId’ is a GLuint pointing to a valid texture previously
loaded with

GLvoid BindGLTexture(SDL_Surface *image)
{
glGenTextures(1, &textureId);
glBindTexture(GL_TEXTURE_2D, textureId);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, 3, image->w, image->h, 0, GL_RGB,
GL_UNSIGNED_BYTE, image->pixels);
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, image->w, image->h, GL_RGB,
GL_UNSIGNED_BYTE, image->pixels);
}

Thanks,
Jorge


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

The Z-coords for your quad are right at the near culling plane. Try
drawing the quad at a depth of 0.0. You will then probably need to
fiddle with the depth buffer a bit, or the 3d scene you’re trying to
draw might be occluded behind your backing quad.

To start, change those Z coordinates and see if that fixes it. If that
works, before you start drawing things in 3d, to ensure they are not
improperly occluded, I suggest

glDisable(GL_DEPTH_TEST);
/* draw the quad in orthographic projection /
glClear(GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
/
draw my 3d scene */

This will prevent the background from occluding anything drawn later in
3D (if that is what you want…), with pretty good performance. As
others have said, clearing the actual framebuffer isn’t necessary,
because you’re going to draw over it all anyway.

Hello,

After reading all the messages from this thread I have the next
code but i’m not able to display the background bitmap: A BMP,
1024x768, 24 bpp

Any comment ?? And sorry for a lengthy message.

Thanks,
Jorge

//
// This code was created by Jeff Molofee '99
// (ported to SDL by Sam Lantinga '2000)
//
// If you’ve found this code useful, please let me know.
//
// Visit me at www.demonews.com/hosted/nehe
//
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <GL/gl.h>
#include <GL/glu.h>
#include “SDL.h”

GLuint textureId;

GLvoid LoadGLTextures(GLvoid)
{
SDL_Surface *image;

image = SDL_LoadBMP( "escenari.bmp" );
if ( image == NULL ) {
    fprintf(stderr, "Unable to load background: %s\n", SDL_GetError());
    exit(1);
}

glGenTextures(1, &textureId);

glBindTexture(GL_TEXTURE_2D, textureId);

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);

glTexImage2D(GL_TEXTURE_2D, 0, 3, image->w, image->h, 0, GL_RGB,

GL_UNSIGNED_BYTE, image->pixels);

gluBuild2DMipmaps(GL_TEXTURE_2D, 3, image->w, image->h, GL_RGB,

GL_UNSIGNED_BYTE, image->pixels);
}

GLvoid InitGL( GLsizei Width, GLsizei Height )
{
glViewport(0, 0, Width, Height);

LoadGLTextures();

glEnable(GL_TEXTURE_2D);

glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

}

void DrawGLScene( GLsizei Width, GLsizei Height )
{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho( 0, Width, Height, 0, -1.0, 1.0 );

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

glDisable(GL_DEPTH_TEST);

glBindTexture(GL_TEXTURE_2D, textureId);

glBegin(GL_QUADS);
glNormal3f( 0.0f, 0.0f, 1.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 0.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 0.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 0.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 0.0f);
glEnd();

glClear(GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);

SDL_GL_SwapBuffers();
}

int main(int argc, char **argv)
{
int done;
SDL_Event event;

if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
fprintf(stderr, “Unable to initialize SDL: %s\n”, SDL_GetError());
exit(1);
}

if ( SDL_SetVideoMode(1024, 768, 0, SDL_OPENGL) == NULL ) {
fprintf(stderr, “Unable to create OpenGL screen: %s\n”, SDL_GetError
());
SDL_Quit();
exit(1);
}

InitGL(1024, 768);

/* Loop, drawing and checking events */
done = 0;
while ( !done ) {
DrawGLScene(1024, 768);

while ( SDL_PollEvent(&event) ) {
  if ( event.type == SDL_QUIT ) {
    done = 1;
  }
  else if ( event.type == SDL_KEYDOWN ) {
    switch ( event.key.keysym.sym ) {
      case SDLK_ESCAPE:
           done = 1;
           break;
        default:
             break;
    }
  }
}

}

SDL_Quit();
return 1;
}________________________________________________________________________________
Este mensaje se dirige exclusivamente a su destinatario y puede contener
informaci?n CONFIDENCIAL sometida a secreto profesional o cuya divulgaci?n
est? prohibida en virtud de la legislaci?n vigente. Si ha recibido este
mensaje por error, le rogamos que nos lo comunique inmediatamente por esta
misma v?a o por tel?fono (34 93 739 67 00) y proceda a su destrucci?n.
N?tese que el correo electr?nico v?a Internet no permite asegurar ni la
confidencialidad de los mensajes que se transmiten ni la correcta recepci?n
de los mismos. En el caso de que el destinatario de este mensaje no
consintiera la utilizaci?n del correo electr?nico v?a Internet, rogamos lo
ponga en nuestro conocimiento de manera inmediata. This message is
intended exclusively for its addressee and may contain information that is
CONFIDENTIAL and protected by a professional privilege or which disclosure
is prohibited by law. If this message has been received in error, please
immediately notify us via e-mail or by telephone (34 93 739 67 00) and
delete it. Please note that Internet e-mail does not guarantee the
confidentiality or the proper receipt of the messages sent. If the
addressee of this message does not consent to the use of Internet e-mail,
please communicate it to us immediately.


jorgefm at cirsa.com wrote:

void DrawGLScene( GLsizei Width, GLsizei Height )

{
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho( 0, Width, Height, 0, -1.0, 1.0 );

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

glDisable(GL_DEPTH_TEST);

glBindTexture(GL_TEXTURE_2D, textureId);

glBegin(GL_QUADS);
glNormal3f( 0.0f, 0.0f, 1.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 0.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 0.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f, 1.0f, 0.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f, 1.0f, 0.0f);
glEnd();

glClear(GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);

SDL_GL_SwapBuffers();
}

Well, I’m not sure exactly, but as I recall, openGL already does
backface culling on polygons formed counter-clockwise (It only shows
them from angles where the order of their vertex formation should be
clockwise, which in this case would be behind your polygon, looking
along the negative Z axis. So you’ll most likely see something if you
swap the order of the vertices.

also, it’s worth noting that when you call glOrtho(0, Width, Height, 0,
-1.0, 1.0); you’re telling it to look at all 3D unit values
perpendicular to the z axis within the range of X[0, width-1] and Y[0,
height-1]. (I may be slightly off on the “*-1” part, I’m pretty new,
too so correct me if I’m wrong.)

Here’s some rewritten code for you, assuming that you want your picture
to take up the whole screen, and not just a few pixels in one of the
corners:

glBegin(GL_QUADS);
glNormal3f( 0.0f, 0.0f, 1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.0f, Height, 0.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( Width, Height, 0.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f( Width, 0.0f, 0.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.0f, 0.0f, 0.0f);
glEnd();

here, if Width and Height aren’t floats, be sure to typecast them as
such “(float)Width” – I’ve also seen something like this “Width.f”,
does this do the same sort of thing?

Anyway, there’s at least a good place to start. Hope it helps.

–Scott

Well, I’m not sure exactly, but as I recall, openGL
already does
backface culling on polygons formed
counter-clockwise

I think you need to call:

glCullFace( GL_BACK );

To enable this. To cull the polys formed clockwise,
call glCullFace( GL_FRONT );

you may need to call glEnable( GL_CULL_FACE ); but I
froget…

also, it’s worth noting that when you call
glOrtho(0, Width, Height, 0,
-1.0, 1.0); you’re telling it to look at all 3D unit
values
perpendicular to the z axis within the range of X[0,
width-1] and Y[0,
height-1]. (I may be slightly off on the "*-1"
part, I’m pretty new,
too so correct me if I’m wrong.)

corrects

if you call glOrtho(0,1,1,0,-1,1); you’ll have 0.0 be
the left (or top if on the Y axis) part of your
screen, 1.0 will be the right (or bottom) part. If the
-1s were in effect, well, that call might crash, as
both the left and right part of the screen would be @
x = 0.

Here’s some rewritten code for you, assuming that
you want your picture
to take up the whole screen, and not just a few
pixels in one of the
corners:

glBegin(GL_QUADS);
glNormal3f( 0.0f, 0.0f, 1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.0f,
Height, 0.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( Width,
Height, 0.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f( Width,
0.0f, 0.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.0f,
0.0f, 0.0f);
glEnd();

here, if Width and Height aren’t floats, be sure to
typecast them as
such “(float)Width”

Shouldn’t be necessary, the compiler should
automatically cast them to floats for you, as
glVertex3f only takes floats. However, casting them
will eliminate some annoying compiler warnings, which
I prefer to do over disabling the warning, as they can
occasionally spot trouble for you. That’s why they’re
warnings ^_^.

– I’ve also seen something like
this “Width.f”,
does this do the same sort of thing?

I’ve seen “1.0f” and “2.0f” but not “Width.f”…
although for the longest time I hadn’t heard of
’L"…"’ or even “1.0f” so I could just be out of the
loop again on this one.__________________________________
Do you Yahoo!?
Yahoo! Domains ? Claim yours for only $14.70/year
http://smallbusiness.promotions.yahoo.com/offer

Here’s some rewritten code for you, assuming that you want your picture
to take up the whole screen, and not just a few pixels in one of the
corners:

glBegin(GL_QUADS);
glNormal3f( 0.0f, 0.0f, 1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.0f, Height, 0.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( Width, Height, 0.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f( Width, 0.0f, 0.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.0f, 0.0f, 0.0f);
glEnd();

here, if Width and Height aren’t floats, be sure to typecast them as
such “(float)Width” – I’ve also seen something like this “Width.f”,
does this do the same sort of thing?

Hi,

I have tried this modifications but now i get a white screen, no bitmap is
displayed.

Something else to try ??

Thanks for your replies!

Jorge

Here’s some rewritten code for you, assuming that you want your
picture to take up the whole screen, and not just a few pixels in
one of the corners:

glBegin(GL_QUADS);
glNormal3f( 0.0f, 0.0f, 1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.0f, ? Height, 0.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( Width, ?Height, 0.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f( Width, ?0.0f, ? 0.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.0f, ? 0.0f, ? 0.0f);
glEnd();

here, if Width and Height aren’t floats, be sure to typecast them
as such “(float)Width” – I’ve also seen something like this
"Width.f", does this do the same sort of thing?

Hi,

I have tried this modifications but now i get a white screen, no
bitmap is displayed.

Sounds like you failed to load or upload the texture, or to activate
texturing… (Most drivers give you a white default texture in such
cases.)

Something else to try ??

Check the OpenGL error status after each call, especially the ones
involved in uploading the texture, and activating texturing. Also
check that you’re actually performing all the steps necessary, of
course.

//David Olofson - Programmer, Composer, Open Source Advocate

.- Audiality -----------------------------------------------.
| Free/Open Source audio engine for games and multimedia. |
| MIDI, modular synthesis, real time effects, scripting,… |
`-----------------------------------> http://audiality.org -’
http://olofson.nethttp://www.reologica.se —On Monday 24 May 2004 12.31, jorgefm at cirsa.com wrote:

I have tried this modifications but now i get a white screen, no
bitmap is displayed.

Sounds like you failed to load or upload the texture, or to activate
texturing… (Most drivers give you a white default texture in such
cases.)

Something else to try ??

Check the OpenGL error status after each call, especially the ones
involved in uploading the texture, and activating texturing. Also
check that you’re actually performing all the steps necessary, of
course.

Yes, it’s a texture loading problem. My bmp is 1024x768. Then i have
resized it to 1024x1024 but i can’t load it. Then i have used other bmp
with a 256x256 texture and i have this texture displayed as the background.
Is there any size limit to the texture you can load ?

Thanks,
Jorge

|---------±--------------------------------------->
| | David Olofson |
| | |
| | Enviado por: |
| | sdl-bounces+jorgefm=cirsa.com|
| | @libsdl.org |
| | |
| | |
| | 24/05/2004 13:06 |
| | Por favor, responda a “A list|
| | for developers using the SDL |
| | library. (includes |
| | SDL-announce)” |
|---------±--------------------------------------->

--------------------------------------------------------------------------------------------------|
| |
| Para: “A list for developers using the SDL library. (includes SDL-announce)” |
| |
| cc: |
| Asunto: Re: [SDL] OpenGL and pixel access |
--------------------------------------------------------------------------------------------------|

Here’s some rewritten code for you, assuming that you want your
picture to take up the whole screen, and not just a few pixels in
one of the corners:

glBegin(GL_QUADS);
glNormal3f( 0.0f, 0.0f, 1.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.0f, ? Height, 0.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f( Width, ?Height, 0.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f( Width, ?0.0f, ? 0.0f);
glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.0f, ? 0.0f, ? 0.0f);
glEnd();

here, if Width and Height aren’t floats, be sure to typecast them
as such “(float)Width” – I’ve also seen something like this
"Width.f", does this do the same sort of thing?

Hi,

I have tried this modifications but now i get a white screen, no
bitmap is displayed.

Sounds like you failed to load or upload the texture, or to activate
texturing… (Most drivers give you a white default texture in such
cases.)

Something else to try ??

Check the OpenGL error status after each call, especially the ones
involved in uploading the texture, and activating texturing. Also
check that you’re actually performing all the steps necessary, of
course.

//David Olofson - Programmer, Composer, Open Source Advocate

.- Audiality -----------------------------------------------.
| Free/Open Source audio engine for games and multimedia. |
| MIDI, modular synthesis, real time effects, scripting,… |
`-----------------------------------> http://audiality.org -’
http://olofson.nethttp://www.reologica.se —On Monday 24 May 2004 12.31, @Jorge_Fernandez_Mont wrote:


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Yup, but it is driver specific. Use glGetInteger* to find out
how much your driver supports…

/Olof

jorgefm at cirsa.com: “Re: [SDL] OpenGL and pixel access” (2004-05-24…#

#>> I have tried this modifications but now i get a white screen, no
#>> bitmap is displayed.
#>
#>Sounds like you failed to load or upload the texture, or to activate
#>texturing… (Most drivers give you a white default texture in such
#>cases.)
#>
#>> Something else to try ??
#>
#>Check the OpenGL error status after each call, especially the ones
#>involved in uploading the texture, and activating texturing. Also
#>check that you’re actually performing all the steps necessary, of
#>course.
#>

#Yes, it’s a texture loading problem. My bmp is 1024x768. Then i have
#resized it to 1024x1024 but i can’t load it. Then i have used other bmp
#with a 256x256 texture and i have this texture displayed as the background.
#Is there any size limit to the texture you can load ?

#Thanks,
#Jorge

#|---------±--------------------------------------->
#| | David Olofson |
#| | |
#| | Enviado por: |
#| | sdl-bounces+jorgefm=cirsa.com|
#| | @libsdl.org |
#| | |
#| | |
#| | 24/05/2004 13:06 |
#| | Por favor, responda a “A list|
#| | for developers using the SDL |
#| | library. (includes |
#| | SDL-announce)” |
#|---------±--------------------------------------->

>--------------------------------------------------------------------------------------------------|

| |

| Para: “A list for developers using the SDL library. (includes SDL-announce)” |

| |

| cc: |

| Asunto: Re: [SDL] OpenGL and pixel access |

>--------------------------------------------------------------------------------------------------|

#On Monday 24 May 2004 12.31, jorgefm at cirsa.com wrote:
#> >Here’s some rewritten code for you, assuming that you want your
#> > picture to take up the whole screen, and not just a few pixels in
#> > one of the corners:
#> >
#> >glBegin(GL_QUADS);
#> >glNormal3f( 0.0f, 0.0f, 1.0f);
#> >glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.0f, ? Height, 0.0f);
#> >glTexCoord2f(1.0f, 1.0f); glVertex3f( Width, ?Height, 0.0f);
#> >glTexCoord2f(1.0f, 0.0f); glVertex3f( Width, ?0.0f, ? 0.0f);
#> >glTexCoord2f(0.0f, 0.0f); glVertex3f( 0.0f, ? 0.0f, ? 0.0f);
#> >glEnd();
#> >
#> >here, if Width and Height aren’t floats, be sure to typecast them
#> > as such “(float)Width” – I’ve also seen something like this
#> > “Width.f”, does this do the same sort of thing?
#>
#> Hi,
#>
#>
#> I have tried this modifications but now i get a white screen, no
#> bitmap is displayed.

#Sounds like you failed to load or upload the texture, or to activate
#texturing… (Most drivers give you a white default texture in such
#cases.)

#> Something else to try ??

#Check the OpenGL error status after each call, especially the ones
#involved in uploading the texture, and activating texturing. Also
#check that you’re actually performing all the steps necessary, of
#course.

#//David Olofson - Programmer, Composer, Open Source Advocate

#.- Audiality -----------------------------------------------.
#| Free/Open Source audio engine for games and multimedia. |
#| MIDI, modular synthesis, real time effects, scripting,… |
#`-----------------------------------> http://audiality.org -’

http://olofson.nethttp://www.reologica.se

#_______________________________________________
#SDL mailing list
#SDL at libsdl.org
#http://www.libsdl.org/mailman/listinfo/sdl

#_______________________________________________
#SDL mailing list
#SDL at libsdl.org
#http://www.libsdl.org/mailman/listinfo/sdl

Yes, the driver only supports 512x512 ! Then it

could be done mapping a 1024x768 bmp in several

512x512, and smaller, textures, isn’t it ?

Thanks you !

Jorge

Olof Bjarnason
Enviado por: sdl-bounces+jorgefm=cirsa.com@libsdl.org
24/05/2004 16:37 ZE2
Por favor, responda a "A list for developers using the SDL library.
(includesSDL-announce)"Para: "A list for developers using the SDL library. (includes
SDL-announce)"
cc:
cco:
Asunto: Re: [SDL] OpenGL and pixel access

Yup, but it is driver specific. Use glGetInteger* to find out
how much your driver supports…
/Olof

Yep.

Note that if you’re doing filtered scaling, you’ll need some overlap
around the edges for correct filtering, or the edges will become
visible. (This is where tiling in OpenGL starts to get hairy…)

(And please don’t use HTML in emails! Most mail software seems to make
a mess of it one way or another, at some point. Besides, many users
disable HTML in email, since it just opens up security holes for no
real gain.)

//David Olofson - Programmer, Composer, Open Source Advocate

.- Audiality -----------------------------------------------.
| Free/Open Source audio engine for games and multimedia. |
| MIDI, modular synthesis, real time effects, scripting,… |
`-----------------------------------> http://audiality.org -’
http://olofson.nethttp://www.reologica.se —On Monday 24 May 2004 17.17, jorgefm at cirsa.com wrote:

Yes, the driver only supports 512x512 ! Then it
could be done mapping a 1024x768 bmp in several
512x512, and smaller, textures, isn’t it ?