Yes and it loads it on an entire qube and that's not what I'm looking for?! |
It shows you the concept. It's up to you how to apply it to your particular problem.
1) Create a texture
2) bind it
3) use glTexCoord before you use glVertex to plot the text coords to use
4) when the quad is rendered, it will be textured
Basically glTexCoord is the points for the source rectangle, and glVertex is the points for the dest rectangle. Since you can set points independently, you can flip/stretch/rotate/whathaveyou.
You just have to play around with it.
There's also an easy way which doesn't involve having to rewrite my whole game onto a 3D engine I don't want to use. As I wrote in my first post Flash has a class for it there's multiple filters for Java |
Flash is 3D vectoring image software. It basically
is a 3D library.
Java has 3D functionality built in as well, which is undoubtedly uses to do stretching/rotating.
There probably are libs for C++, but they all wrap around other 3D libs (everything is 3D these days). There's really no practical way to do it otherwise, as all other ways are too computationally expensive to do in realtime, whereas 3D rendering is done by the video hardware and is very fast.
If you're looking for a "training wheels" lib that is aimed at making 2D features easier, I don't have any recommendations. Sorry. I'd say just bite the bullet and tinker around with OpenGL until you understand it. It really isn't all that difficult -- it's just very different from traditional 2D.
Maybe someone else has a lib recommendation.
EDIT:
Blah -- give me a bit -- maybe I'll whip something up you can use or at least learn from.
EDIT AGAIN:
Here. I didn't test this but it should be good:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
//--------------------------------------
// when the program first starts up and you're setting up your display
glMatrixMode( GL_PROJECTION ); // we want a 2D ortagonal matrix for the projection
glLoadIdentity();
glOrtho(0, width, 0, height, 0, 1); // this is width/height of the display window in pixels
// note that in 3D graphics, positive Y is up, but in 2D graphics, positive Y is down
// if you want to make the image upside-down so it's more like 2D, you can do this instead:
// glOrtho(0, width, height-1, -1, 0, 1);
//--- do all the other stuff the NeHe tutorial told you to do, like
// enabling 2D texturing, and all that stuff
//-------------------------------------
//-------------------------------------
//-------------------------------------
// here's a simple struct to represent a texture:
struct Texture
{
GLuint id; // the ID of the texture (as given to you by glGenTextures)
double invw; // set this to "1.0 / image_width" when you load your bitmap
double invh; // set this to "1.0 / image_height"
};
//-------------------------------------
// here's a simple function to prepare a texture for drawing
void PrepareTexture(const Texture& tx) // pass this the Texture you want to draw with
{
glBindTexture( GL_TEXTURE_2D, tx.id );
glMatrixMode( GL_TEXTURE );
glLoadIdentity();
glScaled(tx.invw,tx.invh,1.0);
}
//-------------------------------------
//-------------------------------------
//-------------------------------------
// Then when you want to draw a quad, you'd do this:
// This example draws a 'wd' by 'ht' square from coords 'srcx','srcy' on the texture
// and draws them to coords 'dstx','dsty' on the screen
//
// Note this assumes that positive Y = up
PrepareTexture( whatever_texture_you_want_to_draw_with );
glBegin( GL_QUADS );
// upper left corner
glTexCoord2i( srcx, srcy ); glVertex2i( dstx, dsty - ht );
// upper right corner
glTexCoord2i( srcx + wd, srcy ); glVertex2i( dstx + wd, dsty - ht );
// lower right corner
glTexCoord2i( srcx + wd, srcy + ht ); glVertex2i( dstx + wd, dsty );
// lower left corner
glTexCoord2i( srcx, srcy + ht ); glVertex2i( dstx, dsty );
glEnd();
|
Note that one of the caveats with OpenGL is that textures
MUST have power of 2 dimensions. That is, a texture that's 256x128 is fine because those are both powers of 2. However 256x200 is no good.