C++ (Qt)void GLView::paintGL(){ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); if (!isLoaded) return; // glMatrixMode(GL_MODELVIEW); glLoadIdentity(); renderText(0, 0, 0, "SSA");
C++ (Qt) glColor3f(0, 0, 0); glBegin(GL_LINES); glVertex3f(-1, 0, -1); glVertex3f(+1, 0, -1); glEnd(); qglColor(Qt::black); renderText(-1, 0, -1, "Hello drawing text");
C++ (Qt) glColor3f(0, 0, 0); glBegin(GL_LINES); glVertex3f(-1, 0, -1); glVertex3f(+1, 0, -1); qglColor(Qt::black); renderText(-1, 0, -1, "Hello drawing text"); glEnd();
void CastleFight::paintGL(){ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); draw(); glFlush();}void CastleFight::draw(){ moveCamera(); drawScene(); drawReflection(); drawText(); drawShadow();}void CastleFight::drawText(){ renderText(4.0, 1.5, 0.0, QString().sprintf("Castle right\nHit-Points: %d", hitPoints[0])); renderText(-4.0, 1.5, 0.0, QString().sprintf("Castle left\nHit-Points: %d", hitPoints[1])); renderText(1100, 20, QString().sprintf("%s Castle:", currentPlayer==0?"Right":"Left")); renderText(1100, 50, QString().sprintf("y angle = %f", -cannons[currentPlayer].getXAngle())); renderText(1100, 80, QString().sprintf("x angle = %f", 90 + cannons[currentPlayer].getYAngle())); renderText(1100, 110, QString().sprintf("speed = %f", 100*cannons[currentPlayer].ball.speed));}
void CastleFight::resizeGL(int w, int h){ glViewport(0, 0, w, h); if(h > 0) { glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(60.0, w/(GLfloat)h, 0.1, 1000); }}
C++ (Qt) glGenBuffers(1, &idVertex); glBindBuffer(GL_ARRAY_BUFFER, idVertex); glGenBuffers(1, &idIndice); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, idIndice);