LFRect.h//定义一个结构体,表示裁剪的区域
#ifndef LFRECT_H
#define LFRECT_H
#include "LOpenGL.h"
struct LFRect
{
GLfloat x;//x
GLfloat y;//y
GLfloat w;//宽
GLfloat h;//高
};
#endif
LTexture.h
void render( GLfloat x, GLfloat y, LFRect* clip = NULL );//渲染方法添加第三个参数,给它一个NULL的默认值
LTexture.cpp
void LTexture::render( GLfloat x, GLfloat y, LFRect* clip )
{
if( mTextureID != 0 )
{
glLoadIdentity();//重置之前的所以变换操作
GLfloat texTop = 0.f;//下面四句是纹理的坐标,水平方向0~1表示从左到右,竖直方向0~1表示从上到下
GLfloat texBottom = 1.f;
GLfloat texLeft = 0.f;
GLfloat texRight = 1.f;
GLfloat quadWidth = mTextureWidth;//四边形的宽
GLfloat quadHeight = mTextureHeight;//高
if(