summaryrefslogtreecommitdiffstats
path: root/matchblox/bitmap.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'matchblox/bitmap.cpp')
-rw-r--r--matchblox/bitmap.cpp98
1 files changed, 0 insertions, 98 deletions
diff --git a/matchblox/bitmap.cpp b/matchblox/bitmap.cpp
deleted file mode 100644
index 243952a..0000000
--- a/matchblox/bitmap.cpp
+++ /dev/null
@@ -1,98 +0,0 @@
-#ifdef G_OS_WIN32
- #define WIN32_LEAN_AND_MEAN 1
- #include <windows.h>
- #define GL_BGR 0x80E0
- #define GL_BGRA 0x80E1
-#endif
-
-#include <GL/gl.h>
-#include <GL/glu.h>
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "bitmap.h"
-
-#define BITMAP_FILESIZE 0x02
-#define BITMAP_OFFSET 0x0a
-#define BITMAP_HEADERSIZE 0x0e
-#define BITMAP_WIDTH 0x12
-#define BITMAP_HEIGHT 0x16
-#define BITMAP_DEPTH 0x1c
-#define BITMAP_IMAGE_SIZE 0x22
-
-
-struct BitmapStruct BitmapLoad(char *filename)
-{
- struct BitmapStruct l_sImage;
- GLuint texture;
- FILE *bitmap;
-
- // try to open the file
- bitmap = fopen(filename, "r");
-
- // does the bitmap exist?
- if (bitmap > 0)
- {
- unsigned int dataoffset, filesize, imagesize;
- short depth;
- GLsizei width, height;
- unsigned char *imagedata;
-
- fseek(bitmap, BITMAP_FILESIZE, SEEK_SET);
- fread(&filesize, 4, 1, bitmap);
- fseek(bitmap, BITMAP_OFFSET, SEEK_SET);
- fread(&dataoffset, 4, 1, bitmap);
- fseek(bitmap, BITMAP_WIDTH, SEEK_SET);
- fread(&width, 4, 1, bitmap);
- fread(&height, 4, 1, bitmap);
- fseek(bitmap, BITMAP_DEPTH, SEEK_SET);
- fread(&depth, 2, 1, bitmap);
- fseek(bitmap, BITMAP_IMAGE_SIZE, SEEK_SET);
- fread(&imagesize, 4, 1, bitmap);
-
- imagedata = (unsigned char *)malloc((size_t)imagesize);
-
- fseek(bitmap, dataoffset, SEEK_SET);
- fread(imagedata, (size_t)imagesize, 1, bitmap);
-
- glGenTextures(1, &texture);
- glBindTexture(GL_TEXTURE_2D, texture);
-
- if (depth == 24) // 24 bits
- {
- gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, width, height, GL_BGR, GL_UNSIGNED_BYTE, imagedata);
- }
- else // depth == 32 bits
- {
- gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, width, height, GL_BGRA, GL_UNSIGNED_BYTE, imagedata);;
- }
-
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-
- l_sImage.m_iImageId = texture;
- l_sImage.m_iWidth = width;
- l_sImage.m_iHeight = height;
-
- free(imagedata);
- fclose(bitmap);
-
- return l_sImage;
- }
- else
- {
- // couldn't find bitmap
- exit(0);
- }
-}
-
-
-
-void BitmapConvertWidth(struct BitmapStruct *f_sImage, double f_dHeight)
-{
- double l_dRatio;
-
- l_dRatio = (double)f_sImage->m_iHeight / f_dHeight;
- f_sImage->m_iWidth = (int)(f_sImage->m_iWidth / l_dRatio);
-
-} // ConvertButton