This is a code I use to draw rectangle in my program:
glBegin(GL_QUADS);
glTexCoord2f(0.0f, maxTexCoordHeight); glVertex2i(pos.x, pos.y + height);
glTexCoord2f(0.0f, 0.0f); glVertex2i(pos.x, pos.y);
glTexCoord2f(maxTexCoordWidth, 0.0f); glVertex2i(pos.x + width, pos.y);
glTexCoord2f(maxTexCoordWidth, maxTexCoordHeight); glVertex2i(pos.x + width, pos.y + height);
glEnd();
It draws just a simple rectangle with specified texture, e.g. like this:
I'd like to ask if it's possible in OpenGL to achieve border effect like this:
As you see inside this tile there's just a plain blue background which could be handled separately - just automatically resized texture. This can be achieved easily with a code snippet I gave, but the problem is with border.
If the border was supposed to be one color, I could try drawing empty, not-filled rectangle by using GL_LINES
around my texture, but it's not.
Also if tiles were always with a fixed size, I could prepare a texure that would match it, but they HAVE TO be easily resizable without changing a bitmap file I use as texture.
So if it's not possible with basic OpenGL functions, what are the approaches to achieve this effect that would be most efficient and/or easy?
EDIT: It has to be 2D.
glVertex
), it will probably take you a while to catch up to the wonderful world of OpenGL 2.0 and beyond. – Holbrook