Menu Home

opengl

MAC OS下编译OPENGL

MAC OS下编译OPENGL 包含头文件 #include <gl.h> –> #include <OpenGL/gl.h> #include <glu.h> –> #include <OpenGL/glu.h> #include <glut.h> –> #include <GLUT/glut.h> 编译命令 gcc -framework GLUT -framework OpenGL -framework Cocoa test.c -o test XCode下导人 /System/Library/Frameworks/OpenGL.framework /Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/GLUT.framework

jpeg转换OpenGL Texture

jpeg转换OpenGL Texture #include <stdio.h> #include <unistd.h> #include <jpeglib.h> #include <stdlib.h> #include <GL/gl.h> #include <GL/glut.h> void LoadJpgTextureGL(char *file) { FILE *jpegFile; int sizebuf; unsigned char* buffer; unsigned char* texturebuf; struct jpeg_decompress_struct cinfo; struct jpeg_error_mgr jerr; cinfo.err = jpeg_std_error(&jerr); jpeg_create_decompress(&cinfo); if((jpegfile = fopen(file,”rb”))==NULL) { perror(“fopen jpeg”); return; } jpeg_stdio_src(&cinfo,jpefile); jpeg_read_header(&cinfo,TRUE); jpeg_start_decompress(&cinfo); sizebuf […]

png转换OpenGL Texture

bool loadPngImage(char *name, int *outWidth, int *outHeight, bool *outHasAlpha, GLubyte **outData) { png_structp png_ptr; png_infop info_ptr; unsigned int sig_read = false; int color_type, interlace_type; FILE *fp; printf(“png file : %s\n”, name); if((fp = fopen(name, “rb”)) == NULL) { printf(“%s: open png file error: \n”, __FILE__); perror(“open filed:\n”); return false; } […]