随笔分类 - opengl2.x
摘要:1. 必须GLThread线程里调用 fun saveFrame(filename: String, width: Int, height: Int) { val startTime = System.currentTimeMillis() //1.glReadPixels返回的是大端的RGBA B
阅读全文
摘要:Primitive Processing:原始处理 Vertex Shader:顶点着色器 Primitive Assembly:原始组装 Rasterizer:光栅化 Fragment Shader:片段着色器 Depth Stencil:深度模板 Color Buffer Blend:色彩缓冲区
阅读全文
摘要:From LTexture.cpp #include "LTexture.h" #include <IL/il.h> #include <IL/ilu.h> GLenum DEFAULT_TEXTURE_WRAP = GL_REPEAT; bool LTexture::loadTextureFrom
阅读全文
摘要:LTexture.cpp void LTexture::render( GLfloat x, GLfloat y, LFRect* clip ){ if( mTextureID != 0 ) { GLfloat texTop = 0.f; GLfloat texBottom = (GLfloat)m
阅读全文
摘要:LTexture.cpp void LTexture::render( GLfloat x, GLfloat y, LFRect* clip, LFRect* stretch, GLfloat degrees ){ if( mTextureID != 0 ) { glLoadIdentity();
阅读全文
摘要:LTexture.hvoid render( GLfloat x, GLfloat y, LFRect* clip = NULL, LFRect* stretch = NULL ); LTexture.cpp void LTexture::render( GLfloat x, GLfloat y,
阅读全文
摘要:LTexture.h bool loadPixelsFromFile( std::string path );bool loadTextureFromFileWithColorKey( std::string path, GLubyte r, GLubyte g, GLubyte b, GLubyt
阅读全文
摘要:LTexture.h bool lock(); bool unlock(); GLuint* getPixelData32();//获取像素 GLuint getPixel32( GLuint x, GLuint y );//获取x,y位置对应的像素点 void setPixel32( GLuint
阅读全文
摘要:纹理渲染的图片的宽度和高度需要是二次幂的,如果不是二次幂的,需要通过填充的方式(就是添加边距),填充到二次幂。 LTexture.h bool loadTextureFromPixels32( GLuint* pixels, GLuint imgWidth, GLuint imgHeight, GL
阅读全文
摘要:LFRect.h//定义一个结构体,表示裁剪的区域 #ifndef LFRECT_H#define LFRECT_H #include "LOpenGL.h" struct LFRect{ GLfloat x;//x GLfloat y;//y GLfloat w;//宽 GLfloat h;//高
阅读全文
摘要:OpenGL本身没有文件操作有关的接口,需要使用第三方库。这里使用DevIL库。 下载连接:http://openil.sourceforge.net/download.php 下载DevIL-Windows-SDK,解压后在Visual Studio配置头文件位置、lib库位置、lib库名称,拷贝
阅读全文
摘要:LOpengGL.h不变 LTexture.h #include "LOpenGL.h"#include <stdio.h> class LTexture{ public: LTexture(); ~LTexture(); bool loadTextureFromPixels32( GLuint*
阅读全文
摘要:LOpengGL.h头文件不变 LUtil.h GLfloat gCameraX = 0.f, gCameraY = 0.f;//相机位置 bool initGL(){ glViewport( 0.f, 0.f, SCREEN_WIDTH, SCREEN_HEIGHT ); glMatrixMode
阅读全文
摘要:LOpengGL.h://不变 LUtil.h //添加枚举 enum ViewPortMode{ VIEWPORT_MODE_FULL, //全屏 VIEWPORT_MODE_HALF_CENTER, //中间 VIEWPORT_MODE_HALF_TOP,//中间上 VIEWPORT_MODE_
阅读全文
摘要:LOpengGL.h://和前一节一样。 LUtil.h://添加 const int COLOR_MODE_CYAN = 0;//定义两个颜色选择const int COLOR_MODE_MULTI = 1; void handleKeys( unsigned char key, int x, i
阅读全文
摘要:LOpengGL.h://导入头文件,注意:先导入freeglut.h #include <GL/freeglut.h>#include <GL/gl.h>#include <GL/glu.h>#include <stdio.h> LUtil.h: #include "MyOpenGL.h"#inc
阅读全文
摘要:OpenGL本身并不提供GUI操作,不过有很多开源的库提供了支持。在学习OpenGL时,我选择window上的freeGLUT库作为辅助,用于GUI操作。下面说一下Visual Studio下的OpenGL和freeGLUT环境的搭建。 1. 下载freeGLUT 下载链接:http://freeg
阅读全文