OpenGL + Allegro. Moving from software drawing X Y to openGL is confusing

Posted by Aaron on Game Development See other posts from Game Development or by Aaron
Published on 2012-03-24T02:22:43Z Indexed on 2012/03/24 5:40 UTC
Read the original article Hit count: 234

Filed under:

Having a fair bit of trouble. I'm used to Allegro and drawing sprites on a bitmap buffer at X Y coords. Now I've started a test project with OpenGL and its weird.

Basically, as far as I know, theirs many ways to draw stuff in OpenGL. At the moment, I think I'm creating a Quad? Whatever that is, and I think Ive given it a texture of a bitmap and them im drawing that:

GLuint gl_image;

bitmap = load_bitmap("cat.bmp", NULL);

gl_image = allegro_gl_make_texture_ex(AGL_TEXTURE_MASKED, bitmap, GL_RGBA);

glBindTexture(GL_TEXTURE_2D, gl_image);

glBegin(GL_QUADS);
    glColor4ub(255, 255, 255, 255);

    glTexCoord2f(0, 0); glVertex3f(-0.5, 0.5, 0);
    glTexCoord2f(1, 0); glVertex3f(0.5, 0.5, 0);
    glTexCoord2f(1, 1); glVertex3f(0.5, -0.5, 0);
    glTexCoord2f(0, 1); glVertex3f(-0.5, -0.5, 0);

glEnd();

So yeah. So I got a few questions:

Is this the best way of drawing a sprite? Is it suitable?

The big question: Can anyone help / Does anyone know any tutorials on this weird coordinate thing? If it even is that. It's vastly different from XY, but I want to learn it. I was thinking maybe I could learn how this weird positioning stuff works, and then write a function to try and translate it to X and Y coords.

Thats about it. I'm still trying to figure it all out on my own but any contributions you guys can make would be greatly appreciated =D

Thanks!

© Game Development or respective owner

Related posts about allegro