12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- /**
- * Copyright (c) 2011 Nokia Corporation.
- *
- * CAUTION: This class is in early, experimental state.
- *
- */
- #ifndef __QTOPENGLSPRITEBATCH__
- #define __QTOPENGLSPRITEBATCH__
- #include <QObject>
- #include <QMatrix4x4>
- #include "SpriteBatch.h"
- #include <QtOpenGL/QGLBuffer>
- #include <QtOpenGL/QGLWidget>
- #include <QtOpenGL/qglshaderprogram.h>
- #define COSINE_TABLE_SIZE 1024
- #define COSINE_TABLE_AND 1023
- #define BATCH_SIZE 16 // NOTE, THIS CANNOT BE CHANGED UNLESS CORRESPONDING VALUES FROM THE SHADER'S ARE CHANGED ACCORDINGLY
- class QtOpenGLSpriteBatch : public QObject, public SpriteBatch
- {
- Q_OBJECT
- public:
- QtOpenGLSpriteBatch(int targetWidth, int targetHeight, QObject *parent=0);
- virtual ~QtOpenGLSpriteBatch();
- void draw ( SpriteDrawInfo *sdi, int spriteCount=1 );
- void begin( BlendMode blendMode, TransformMode dTransform = ePIXELSPACE, float *customProjectionMatrix = 0);
- void end();
- void flushSprites(bool useTable = true);
- protected:
- float cosineTable[COSINE_TABLE_SIZE];
- //float inputMatrixTemp[ BATCH_SIZE * 16 ];
- QMatrix4x4 inputMatrixtemp[ BATCH_SIZE ];
- QMatrix4x4 projectionMatrix;
- SpriteDrawInfo batchCollection[ BATCH_SIZE ];
- int batchCounter;
- // Currently active texture
- GLuint currentTexture;
- int currentTextureWidth;
- int currentTextureHeight;
- void setActiveProgram( int programIndex );
- int currentProgram;
- bool allWhite;
- // Objects for GLES2 rendering
- TransformMode currentDestinationTransform;
- int currentViewportWidth;
- int currentViewportHeight;
- QGLShaderProgram program[2];
- QGLBuffer *qtvbo;
- // Some locations to the program
- GLuint inputMatrixLocation[2];
- GLuint projmLocation[2];
- GLuint samplerLocation[2];
- };
- #endif
|