- 数据定义
static Color4F white_color = {1.0f,1.0f,1.0f,1.0f}; static Vertex2F rect_vertexes [4] = { {100,50},{400,50}, {100,280},{400,280} }; static Vertex2F texture_coords [4] = { {0,1},{1,1}, {0,0},{1,0}, }; static GLuint texture_id = 0 ;
- 加载png文件(加载png图片文件到内存,当前默认认为图片是32位的色彩,长宽都是2的n次方)
unsigned char* read_png(const char* path,int& width,int& height){ FILE* file = fopen(path, "rb"); if (!file){ return NULL; } png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0); png_infop info_ptr = png_create_info_struct(png_ptr); setjmp(png_jmpbuf(png_ptr)); png_init_io(png_ptr, file); png_read_png(png_ptr, info_ptr, PNG_TRANSFORM_EXPAND, 0); width = png_get_image_width(png_ptr,info_ptr); height = png_get_image_height(png_ptr,info_ptr);
opengl 开发笔记-绘制纹理
最新推荐文章于 2023-12-23 18:38:44 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)