Starting resize support.
This commit is contained in:
parent
cea3d2c39f
commit
9ade0e2d4b
26 changed files with 197 additions and 44 deletions
|
@ -13,7 +13,7 @@ public:
|
|||
|
||||
static std::unique_ptr<DrawingSurface> Create();
|
||||
|
||||
void setSize(unsigned width, unsigned height);
|
||||
virtual void setSize(unsigned width, unsigned height);
|
||||
|
||||
unsigned getWidth() const;
|
||||
|
||||
|
|
|
@ -21,35 +21,43 @@ void OpenGlPainter::paint(DrawingContext* context)
|
|||
|
||||
const auto num_mesh = context->getScene()->getNumMeshes();
|
||||
|
||||
glClearColor(0.4, 0.4, 0.4, 0.4);
|
||||
glClearColor(1.0, 1.0, 1.0, 0.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
|
||||
//glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
|
||||
|
||||
for (std::size_t idx=0; idx<num_mesh; idx++)
|
||||
{
|
||||
auto mesh = context->getScene()->getMesh(idx);
|
||||
const auto faces = mesh->getFaceVertices();
|
||||
const auto colors = mesh->getFaceVectorAttributes("Color");
|
||||
|
||||
glColor3f(1.0, 0.0, 1.0);
|
||||
|
||||
std::size_t counter{0};
|
||||
for (const auto& face : faces)
|
||||
{
|
||||
const auto r = colors[counter][0];
|
||||
const auto g = colors[counter][1];
|
||||
const auto b = colors[counter][2];
|
||||
|
||||
glColor3f(r, g, b);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
double x0 = 2.0*face[0].getX() / width - 1.0;
|
||||
double y0 = 2.0*face[0].getY() / height - 1.0;
|
||||
double y0 = 1.0 - 2.0*face[0].getY() / height;
|
||||
|
||||
double x1 = 2.0*face[1].getX() / width - 1.0;
|
||||
double y1 = 2.0*face[1].getY() / height - 1.0;
|
||||
double y1 = 1.0 - 2.0*face[1].getY() / height;
|
||||
|
||||
double x2 = 2.0*face[2].getX() / width - 1.0;
|
||||
double y2 = 2.0*face[2].getY() / height - 1.0;
|
||||
double y2 = 1.0 - 2.0*face[2].getY() / height;
|
||||
|
||||
glVertex3f(x0, y0, 0);
|
||||
glVertex3f(x1, y1, 0);
|
||||
glVertex3f(x2, y2, 0);
|
||||
|
||||
glEnd();
|
||||
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue