22 Texture2DRenderShader::Texture2DRenderShader(
Renderer* renderer)
43 "shader/" + shaderVersion +
"/texture2D",
44 "render_vertexshader.vert"
50 "shader/" + shaderVersion +
"/texture2D",
51 "render_fragmentshader.frag"
104 float textureLeft = position.
getX();
105 float textureTop = position.
getY();
106 float textureWidth = dimension.
getX();
107 float textureHeight = dimension.
getY();
110 auto x0 = ((textureLeft) / (screenWidth / 2.0f)) - 1.0f;
111 auto y0 = ((screenHeight - textureTop) / (screenHeight / 2.0f)) - 1.0f;
112 auto x1 = ((textureLeft + textureWidth) / (screenWidth / 2.0f)) - 1.0f;
113 auto y1 = ((screenHeight - textureTop) / (screenHeight / 2.0f)) - 1.0f;
114 auto x2 = ((textureLeft + textureWidth) / (screenWidth / 2.0f)) - 1.0f;
115 auto y2 = ((screenHeight - textureTop - textureHeight) / (screenHeight / 2.0f)) - 1.0f;
116 auto x3 = ((textureLeft) / (screenWidth / 2.0f)) - 1.0f;
117 auto y3 = ((screenHeight - textureTop - textureHeight) / (screenHeight / 2.0f)) - 1.0f;
121 auto fbTextureCoordinates = ObjectBuffer::getByteBuffer(contextIdx, 6 * 2 *
sizeof(
float))->asFloatBuffer();
124 fbTextureCoordinates.put(+0.0f); fbTextureCoordinates.put(0.0f);
125 fbTextureCoordinates.put(+1.0f); fbTextureCoordinates.put(0.0f);
126 fbTextureCoordinates.put(+1.0f); fbTextureCoordinates.put(1.0f);
128 fbTextureCoordinates.put(+1.0f); fbTextureCoordinates.put(1.0f);
129 fbTextureCoordinates.put(+0.0f); fbTextureCoordinates.put(1.0f);
130 fbTextureCoordinates.put(+0.0f); fbTextureCoordinates.put(0.0f);
132 fbTextureCoordinates.put(+0.0f); fbTextureCoordinates.put(+1.0f);
133 fbTextureCoordinates.put(+1.0f); fbTextureCoordinates.put(+1.0f);
134 fbTextureCoordinates.put(+1.0f); fbTextureCoordinates.put(0.0f);
136 fbTextureCoordinates.put(+1.0f); fbTextureCoordinates.put(0.0f);
137 fbTextureCoordinates.put(+0.0f); fbTextureCoordinates.put(0.0f);
138 fbTextureCoordinates.put(+0.0f); fbTextureCoordinates.put(+1.0f);
146 auto fbVertices = ObjectBuffer::getByteBuffer(contextIdx, 6 * 3 *
sizeof(
float))->asFloatBuffer();
148 fbVertices.put(x0); fbVertices.put(y0); fbVertices.put(0.0f);
149 fbVertices.put(x1); fbVertices.put(y1); fbVertices.put(0.0f);
150 fbVertices.put(x2); fbVertices.put(y2); fbVertices.put(0.0f);
152 fbVertices.put(x2); fbVertices.put(y2); fbVertices.put(0.0f);
153 fbVertices.put(x3); fbVertices.put(y3); fbVertices.put(0.0f);
154 fbVertices.put(x0); fbVertices.put(y0); fbVertices.put(0.0f);
static Engine * getInstance()
Returns engine instance.
static VBOManager * getVBOManager()
int32_t getScaledHeight()
VBOManager_VBOManaged * addVBO(const string &vboId, int32_t ids, bool useGPUMemory, bool shared, bool &created)
Adds a VBO to manager or retrieve VBO if existing.
void removeVBO(const string &vboId)
Removes a VBO from manager.
virtual void setTextureUnit(int contextIdx, int32_t textureUnit)=0
Sets up texture unit.
virtual int32_t loadShader(int32_t type, const string &pathName, const string &fileName, const string &definitions=string(), const string &functions=string())=0
Loads a shader.
int32_t SHADER_FRAGMENT_SHADER
virtual void enableCulling(int contextIdx)=0
Enable culling.
virtual void unbindBufferObjects(int contextIdx)=0
Unbind buffer objects.
int32_t SHADER_VERTEX_SHADER
virtual int32_t createProgram(int type)=0
Creates a shader program.
virtual bool isUsingProgramAttributeLocation()=0
virtual void setProgramAttributeLocation(int32_t programId, int32_t location, const string &name)=0
Bind attribute to a input location.
virtual void enableBlending()=0
Enables blending.
virtual void disableBlending()=0
Disables blending.
virtual void setProgramUniformInteger(int contextIdx, int32_t uniformId, int32_t value)=0
Set up a integer uniform value.
RendererType getRendererType()
virtual bool linkProgram(int32_t programId)=0
Links attached shaders to a program.
virtual void bindTexture(int contextIdx, int32_t textureId)=0
Binds a texture with given id or unbinds when using ID_NONE.
void setLighting(int contextIdx, int32_t lighting)
Set current lighting model.
virtual void attachShaderToProgram(int32_t programId, int32_t shaderId)=0
Attaches a shader to a program.
virtual int32_t getProgramUniformLocation(int32_t programId, const string &name)=0
Returns location of given uniform variable.
virtual void drawTrianglesFromBufferObjects(int contextIdx, int32_t triangles, int32_t trianglesOffset)=0
Draw triangles from buffer objects.
virtual void disableCulling(int contextIdx)=0
Disable culling.
int32_t CONTEXTINDEX_DEFAULT
virtual void uploadBufferObject(int contextIdx, int32_t bufferObjectId, int32_t size, FloatBuffer *data)=0
Uploads buffer data to buffer object.
virtual void bindTextureCoordinatesBufferObject(int contextIdx, int32_t bufferObjectId)=0
Bind texture coordinates buffer object.
virtual void useProgram(int contextIdx, int32_t programId)=0
Use shader program.
virtual void bindVerticesBufferObject(int contextIdx, int32_t bufferObjectId)=0
Bind vertices buffer object.
virtual const string getShaderVersion()=0
Buffers used to transfer data between main memory to graphics board memory.
Texture 2D render shader.
int32_t vboTextureCoordinates
int32_t uniformTextureUnit
void initialize()
Initialize.
void renderTexture(Engine *engine, const Vector2 &position, const Vector2 &dimension, int textureId, int width=-1, int height=-1)
Render texture.
void useProgram()
Use render program.
~Texture2DRenderShader()
Public destructor.
void unUseProgram()
Un use render program.
Vector2 class representing vector2 mathematical structure and operations with x, y components.