About this Blog

This is my first blog. Ever.

It is simply going to be about my hobby; playing with computer programming. I do not know much about blogging, but I will use this one to learn a bit more about it.

Programming has always been a bit of a passion for me, as from those early days when I first tapped in a sample BASIC program on my old Sinclair Spectrum back in 1986. I have been through many platforms, languages and OS's since, but always carried the hobby with me. I am not particularly good at it; perfection requires a large time investment and continuous practice. I do not have the luxury of the amount of time required to keep the fire burning constantly, so the hobby has inevitably gone through periods of extreme withering. I have, however, finally settled for C++, as the title of this blog implies, and play around with it for some entertainment when ever I can.

This here will serve me as a written record of what I am up to, and hopefully be a reinforcement to my memory every now and then. That is all there is to it.

So, if you read this blog, please don't expect anything snazzy, but be you welcome just the same!

Wednesday 30 November 2011

Code Box Test

Just found this which might help writing blocks of code in my posts...

Let's see;

#include "allegro5/allegro.h"
#include "allegro5/allegro_opengl.h"
#include "allegro5/allegro_image.h"
#include "GL/glu.h"


int main()
{
ALLEGRO_DISPLAY *display = NULL;
ALLEGRO_BITMAP *bmp = NULL;

GLuint ogl_tex; // The OpenGL texture id.

al_init();
al_init_image_addon();

al_set_new_display_flags(ALLEGRO_OPENGL);
display = al_create_display(800, 600);

// Load a bitmap to use as a texture
bmp = al_load_bitmap("texture.jpg"); // 256 x 256 pixels
ogl_tex = al_get_opengl_texture(bmp);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(35.0, 800.0 / 600.0, 1.0, 400.0);

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0f, 0.0f, -15.0f);

glEnable(GL_DEPTH_TEST);

glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, ogl_tex);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

glBegin(GL_QUADS);

glNormal3f(0.0, 0.0, 1.0);

glTexCoord2f(0.0, 0.0); // Bottom left hand corner
glVertex3f(-1.5, -1.5, 0.0); // X,Y,Z
glTexCoord2f(2.0, 0.0); // Bottom right hand corner
glVertex3f(1.5, -1.5, 0.0); // X,Y,Z
glTexCoord2f(2.0, 2.0); // Top right hand corner
glVertex3f(1.5, 1.5, 0.0); // X,Y,Z
glTexCoord2f(0.0, 2.0); // Top left hand corner
glVertex3f(-1.5, 1.5, 0.0); // X,Y,Z

glEnd();

glDisable(GL_TEXTURE_2D);
glDisable(GL_DEPTH_TEST);

al_flip_display();

al_rest(10.0);

glDeleteTextures(1, &ogl_tex);
al_destroy_bitmap(bmp);
al_destroy_display(display);
return 0;
}


How does that look?

Yeah, not too bad. I am learning something about blogging, after all. I'll use that from now on. The font size is 80%.

<"<">

As for the listing in the test example, well, that will be the subject of my next series of posts here.