#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <GL/glut.h>
#define FileName "./duke.bmp"
#define BMP_Header_Length 54
GLuint loadTexture(char *file)
{
GLint width, height, total_bytes;
GLubyte* pixels = 0;
GLuint last_texture_ID, texture_ID = 0;
//打开文件,如果失败,返回
FILE* pFile = fopen(file, "rb");
if(pFile == 0)
{
printf("Can not open file %s...", file);
return 0;
}
//读取文件中图象的宽度和高度
fseek(pFile, 0x0012, SEEK_SET);
fread(&width, 4, 1, pFile);
fread(&height, 4, 1, pFile);
fseek(pFile, BMP_Header_Length, SEEK_SET);
//计算每行像素所占字节数,并根据此数据计算总像素字节数
{
GLint line_bytes
#include <stdio.h>
#include <math.h>
#include <GL/glut.h>
#define FileName "./duke.bmp"
#define BMP_Header_Length 54
GLuint loadTexture(char *file)
{
GLint width, height, total_bytes;
GLubyte* pixels = 0;
GLuint last_texture_ID, texture_ID = 0;
//打开文件,如果失败,返回
FILE* pFile = fopen(file, "rb");
if(pFile == 0)
{
printf("Can not open file %s...", file);
return 0;
}
//读取文件中图象的宽度和高度
fseek(pFile, 0x0012, SEEK_SET);
fread(&width, 4, 1, pFile);
fread(&height, 4, 1, pFile);
fseek(pFile, BMP_Header_Length, SEEK_SET);
//计算每行像素所占字节数,并根据此数据计算总像素字节数
{
GLint line_bytes