Main
OpenGL for small applications (2d)

Here are functions that can be used for writing small programs in OpenGL standard with 2d graphics and fonts.

Download sources and compiled library on Windows XP, MinGW: opengl_for_2d.zip (size: 15.6 KB, last modified: 2006/10/01).

function declaration
description
void drawAlphaPixels( GLfloat xPos, GLfloat yPos, GLuint width, GLuint height, GLubyte *color, GLubyte *buf, GLfloat pixelW, GLfloat pixelH ); Draw raw alpha map from buf with specific color, pixel width and height in coordinates units must be pass.
void drawRGBAPixels( GLfloat xPos, GLfloat yPos, GLuint width, GLuint height, GLubyte *buf, GLfloat pixelW, GLfloat pixelH ); Draw raw RGBA map from buf, pixel width and height in coordinates units must be pass.
void drawRGBPixels( GLfloat xPos, GLfloat yPos, GLuint width, GLuint height, GLubyte *buf, GLfloat pixelW, GLfloat pixelH ); Draw raw RGB map from buf, pixel width and height in coordinates units must be pass.
void drawRectangle( GLfloat xPos, GLfloat yPos, GLfloat width, GLfloat height, GLubyte *color ); Draw rectangle filled with specific color.
void drawLRectangle( GLfloat xPos, GLfloat yPos, GLfloat width, GLfloat height, GLubyte *color, GLfloat lineThick ); Draw lined rectangle, line thick and color must be pass.
void buildLinearTexture( GLuint width, GLuint height, GLuint bbp, GLubyte *buf, GLuint &texId ); Build linear texture, bytes per pixel are in bbp (4: RGBA, 3: RGB, 1: Alpha), texId will contain index of texture.
void drawTexture( GLfloat xPos, GLfloat yPos, GLfloat width, GLfloat height, GLuint index ); Draw texture on specific size in coordinates units.
void RGBtoRGBA( GLuint width, GLuint height, GLubyte *buf, GLubyte *transpColor, GLubyte **newBuf ); Create RGBA map from raw RGB pixels and save it in newBuf, transparent color must be pass.
void BMtoAlpha( GLuint width, GLuint height, GLubyte *BMBuf, GLubyte **buf ); Create alpha map from raw bits map (the most significant bit is first) and save it in buf.
void alphatoBM( GLuint width, GLuint height, GLubyte *buf, GLubyte opacity, GLubyte **BMBuf ); Create bits map (the most significant bit is first) from raw alpha pixels and save it in BMBuf, opacity color must be pass, all alpha pixels with that opacity color and greater are set to 1 bit.
void setTransparencyColor( GLuint width, GLuint height, GLubyte *color, GLubyte *buf ); Set transparency color for raw RGBA map.
struct SFonts;
Fonts routines.
SFonts :: SFonts( char *file ); Constructor which require simplified fonts file
SFonts :: SFonts( fstream &f ); Constructor which require fstream object (opened simplified fonts file)
void SFonts :: print( const char *text ); Print text using drawAlphaPixels routine.


An example of using some of those functions: example.cpp (uses res_load library and GLFW too)


Hosted by www.Geocities.ws

1