| 配列 16進数 | ピクセル |
|---|---|
| 8A 5F 6A DF 55 DF 55 5F |
■□□□■□■□ □■□■■■■■ □■■□■□■□ ■■□■■■■■ □■□■□■□■ ■■□■■■■■ □■□■□■□■ □■□■■■■■ |
void glRasterPos2d(GLdouble x , GLdouble y); void glRasterPos2f(GLfloat x , GLfloat y); void glRasterPos2i(GLint x , GLint y); void glRasterPos2s(GLshort x , GLshort y); void glRasterPos3d( GLdouble x , GLdouble y , GLdouble z ); void glRasterPos3f( GLfloat x , GLfloat y , GLfloat z ); void glRasterPos3i( GLint x , GLint y , GLint z ); void glRasterPos3s( GLshort x , GLshort y , GLshort z ); void glRasterPos4d( GLdouble x , GLdouble y , GLdouble z , GLdouble w ); void glRasterPos4f( GLfloat x , GLfloat y , GLfloat z , GLfloat w ); void glRasterPos4i( GLint x , GLint y , GLint z , GLint w ); void glRasterPos4s( GLshort x , GLshort y , GLshort z , GLshort w ); void glRasterPos2dv(const GLdouble *v); void glRasterPos2fv(const GLfloat *v); void glRasterPos2iv(const GLint *v); void glRasterPos2sv(const GLshort *v); void glRasterPos3dv(const GLdouble *v); void glRasterPos3fv(const GLfloat *v); void glRasterPos3iv(const GLint *v); void glRasterPos3sv(const GLshort *v); void glRasterPos4dv(const GLdouble *v); void glRasterPos4fv(const GLfloat *v); void glRasterPos4iv(const GLint *v); void glRasterPos4sv(const GLshort *v);x、y、z、w には、ラスタ位置の新しい座標を指定します
void glBitmap( GLsizei width , GLsizei height , GLfloat xorig , GLfloat yorig , GLfloat xmove , GLfloat ymove , const GLubyte * bitmap );width にはビットマップの幅、height には高さをピクセル単位で指定します
#include <windows.h>
#include <GL/gl.h>
#include <GL/glut.h>
const GLubyte bits[] = {
0xFF , 0xFF , 0xFF , 0xFF , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0xFF , 0xFF , 0xFF , 0xFF ,
0xFF , 0xFF , 0xFF , 0xFF , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0xFF , 0xFF , 0xFF , 0xFF ,
0xFF , 0xFF , 0xFF , 0xFF , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0xFF , 0xFF , 0xFF , 0xFF ,
0xFF , 0xFF , 0xFF , 0xFF , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0xFF , 0xFF , 0xFF , 0xFF ,
0xFF , 0xFF , 0xFF , 0xFF , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0xFF , 0xFF , 0xFF , 0xFF ,
0xFF , 0xFF , 0xFF , 0xFF , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0xFF , 0xFF , 0xFF , 0xFF ,
0xFF , 0xFF , 0xFF , 0xFF , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0xFF , 0xFF , 0xFF , 0xFF ,
0xFF , 0xFF , 0xFF , 0xFF , 0 , 0 , 0 , 0 ,
0 , 0 , 0 , 0 , 0xFF , 0xFF , 0xFF , 0xFF ,
};
void disp( void ) {
glClear(GL_COLOR_BUFFER_BIT);
glRasterPos2i(-1 , -1);
glBitmap(64 , 16 , 0 , 0 , 0 , 0 , bits);
glFlush();
}
int main(int argc , char ** argv) {
glutInit(&argc , argv);
glutInitWindowSize(400 , 300);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA | GLUT_DEPTH);
glutCreateWindow("Kitty on your lap");
glutDisplayFunc(disp);
glClearColor(1 , 1 , 1 , 0);
glColor3f(0 , 0 , 0);
glutMainLoop();
return 0;
}

#include <windows.h>
#include <stdio.h>
#include <GL/gl.h>
#include <GL/glut.h>
GLubyte * bits;
GLuint width , height;
void disp( void ) {
glClear(GL_COLOR_BUFFER_BIT);
glRasterPos2i(-1 , -1);
glBitmap(width , height , 0 , 0 , 0 , 0 , bits);
glFlush();
}
int main(int argc , char ** argv) {
FILE *stream;
if (argc < 2) {
printf("exeFileName bitmap\n");
return 0;
}
stream = fopen(argv[1] , "rb");
if (stream == NULL) {
printf("stream did not open.\n");
return 0;
}
fseek(stream , 0x12 , SEEK_SET);
fread(&width , 4 , 1 , stream);
fread(&height , 4 , 1 , stream);
bits = malloc(width * height);
fseek(stream , 0x3E , SEEK_SET);
fread(bits , 1 , width * height , stream);
fclose(stream);
glutInit(&argc , argv);
glutInitWindowSize(width , height);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA | GLUT_DEPTH);
glutCreateWindow("Kitty on your lap");
glutDisplayFunc(disp);
glClearColor(1 , 1 , 1 , 0);
glColor3f(0 , 0 , 0);
glutMainLoop();
free(bits);
return 0;
}
