Hey, i have a Brick struct with some simple getters/setter of x,y/width,height.
the brick struct also have a float 4x4matrix which contains the matrix that i sent to the vertexshader.
what i want is:
- when i create a Brick object it should be initialized in the bottom left corner i.e x, y, width and height is all initilized to -1.0f.
Problem: However, the object is dependent on the generic vertexBuffer position values. So i tried to set all Vertexposition values to -1.0f. But then the setters (x, y, widht, height) doesn’t work (i.e if i increase the width and height the image don’t scale and get visible).
However it does work if some value are ALMOST set to -1.0f.
Here’s the Brick struct
struct Brick
{
float matrix[4][4];
float x = matrix[0][0];
float y = matrix[1][0];
float width = matrix[0][3];
float height = matrix[1][3];
float getX()
{
return matrix[0][3] - matrix[0][0];
}
float getY()
{
return matrix[1][3] - matrix[1][1];
}
float getWidth()
{
return matrix[0][0];
}
float getHeight()
{
return matrix[1][1];
}
void setX(float value)
{
matrix[0][3] += value;
}
void setY(float value)
{
matrix[1][3] += value;
}
void setWidth(float value)
{
matrix[0][0] += value;
matrix[0][3] += value;
}
void setHeight(float value)
{
matrix[1][1] += value;
matrix[1][3] += value;
}
};
Vertices that work
float vertices[] =
{
-1.0f, -1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
-1.0f, -0.9f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f,
-0.9f, -0.9f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f,
-0.9f, -1.0f, 0.0f, 0.8f, 0.3f, 1.0f, 1.0f, 1.0f, 0.0f
};
Vertices that doesn’t work
float vertices[] =
{
-1.0f, -1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
-1.0f, -1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f,
-1.0f, -1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f,
-1.0f, -1.0f, 0.0f, 0.8f, 0.3f, 1.0f, 1.0f, 1.0f, 0.0f
};