Hello There,
I am trying to create a level editor for my game using a QGLWidget but I have run into a slight problem. When I use the standard paintGL() function like this:
void GLWidget::paintGL()
{
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_TRIANGLES);
glVertex2f(0,0);
glVertex2f(0,50);
glVertex2f(50,0);
glEnd();
}
void GLWidget::paintGL()
{
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_TRIANGLES);
glVertex2f(0,0);
glVertex2f(0,50);
glVertex2f(50,0);
glEnd();
}
To copy to clipboard, switch view to plain text mode
everything works fine. However, if I try and use my own function to draw a triangle:
void GLWidget::DrawAlphaTile(int x, int y)
{
glColor3f(1,0,0);
glBegin(GL_TRIANGLES);
glVertex2f(x,y);
glVertex2f(x + 32, y);
glVertex2f(x + 32,y - 32);
glVertex2f(x,y - 32);
glEnd();
}
void GLWidget::DrawAlphaTile(int x, int y)
{
glColor3f(1,0,0);
glBegin(GL_TRIANGLES);
glVertex2f(x,y);
glVertex2f(x + 32, y);
glVertex2f(x + 32,y - 32);
glVertex2f(x,y - 32);
glEnd();
}
To copy to clipboard, switch view to plain text mode
It does not work. Is there a way around this because there is a lot of user input involved with the integer parameters?
Thanks,
Matt
Bookmarks