Menu Home

图形学

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

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; } […]

xlib创建一个openGL简单窗口

void CreateWindow(int width, int height) { XInitThreads(); m_scrWidth = width; m_scrHeight = height; int attr[] = { GLX_RENDER_TYPE, GLX_RGBA_BIT, GLX_DOUBLEBUFFER, True, GLX_DEPTH_SIZE, 16, None, }; m_dpy = XOpenDisplay(NULL); if (m_dpy == NULL) { cerr << “XOpenDisplay error” << endl; return; } int nelements; GLXFBConfig *fc = glXChooseFBConfig(m_dpy, 0, attr, &nelements); […]

linux下使用C语言生成bitmap

#ifndef SAVEBMP_H #define SAVEBMP_H #include <stdio.h> #include <stdlib.h> typedef long LONG; typedef unsigned char BYTE; typedef unsigned int DWORD; typedef unsigned short WORD; typedef struct { WORD bfType; DWORD bfSize; WORD bfReserved1; WORD bfReserved2; DWORD bfOffBits; } BMPFILEHEADER_T; typedef struct { DWORD biSize; DWORD biWidth; DWORD biHeight; WORD biPlanes; WORD […]