本文整理汇总了C++中drawRectangle函数的典型用法代码示例。如果您正苦于以下问题:C++ drawRectangle函数的具体用法?C++ drawRectangle怎么用?C++ drawRectangle使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了drawRectangle函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: glEnable
void SimpleBallGameWidget::paintGL()
{
glEnable(GL_TEXTURE_2D);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glColor3f(1, 1, 1);
// Draw background
glPushMatrix();
const float BOX_WIDTH = 130.0f;
const float BOX_HEIGHT = 84.0f;
glTranslatef(-BOX_WIDTH / 2, -BOX_HEIGHT / 2, -100.0);
glBindTexture(GL_TEXTURE_2D, m_backgroundTexture);
drawRectangle(0.0, 0.0, BOX_WIDTH, BOX_HEIGHT);
glPopMatrix();
// Draw ball
glPushMatrix();
const float RADIUS = 11.0f;
// Ball point is in logical units, let's convert it to OpenGL units.
const float yPixel = ((m_ballPoint.ry()/MAX_LOGICAL) * MAX_BALL_Y_PX) + MIN_BALL_Y_PX;
glTranslatef(0, -35.0 + yPixel, -90.0);
glBindTexture(GL_TEXTURE_2D, m_ballTexture);
drawRectangle(-RADIUS, -RADIUS, RADIUS, RADIUS);
glPopMatrix();
glFlush();
glDisable(GL_TEXTURE_2D);
}
示例2: movePaddle
int movePaddle(int padDir, float* topY, float MOVE_DISTANCE, int PAD_HEIGHT, bool** ledArray, float LEFT_X, int PAD_WIDTH, float TOP_MARGIN, float BOT_END) {
if(padDir != 1 && padDir != 5) {
padDir = 0;
return padDir;
}
else if(padDir == 1 && (int) (*topY + 0.5) - MOVE_DISTANCE < TOP_MARGIN) {
padDir = 0;
return padDir;
}
else if(padDir == 5 && (int) (*topY + 0.5) + PAD_HEIGHT - 1 + MOVE_DISTANCE > BOT_END) {
padDir = 0;
return padDir;
}
if(padDir == 1 && (int) (*topY) != (int) (*topY - MOVE_DISTANCE)) {
drawRectangle(ledArray, false, *topY + 0.5, LEFT_X, PAD_HEIGHT, PAD_WIDTH);
*topY -= MOVE_DISTANCE;
drawRectangle(ledArray, true, *topY + 0.5, LEFT_X, PAD_HEIGHT, PAD_WIDTH);
}
else if(padDir == 5 && (int) (*topY) != (int) (*topY + MOVE_DISTANCE)) {
drawRectangle(ledArray, false, *topY + 0.5, LEFT_X, PAD_HEIGHT, PAD_WIDTH);
*topY += MOVE_DISTANCE;
drawRectangle(ledArray, true, *topY + 0.5, LEFT_X, PAD_HEIGHT, PAD_WIDTH);
}
return padDir;
}
示例3: drawTopRotor
void drawTopRotor(float r, float angle){
glPushMatrix();
glRotatef(angle,0.0f,1.0f,0.0f);
drawRectangle(r,r/10.0f,r/20.0f);
glRotatef(180.0f,0.0f,1.0f,0.0f);
drawRectangle(r,r/10.0f,r/20.0f);
glPopMatrix();
}
示例4: drawRectangle
void SpaceShip::draw() const {
drawRectangle(body, COLOR);
drawRectangle(cannon, COLOR);
for (int i = 0; i < bullets.size(); ++i) {
if (bullets[i].isAlive()) {
bullets[i].draw();
}
}
}
示例5: glLineWidth
void DrawingContext::drawRectangleFilledWithBorder(GLfloat x, GLfloat y, GLfloat width, GLfloat height) {
glLineWidth(0);
glColor3f(fillR, fillG, fillB);
drawRectangle(GL_QUADS, x, y, width, height);
glLineWidth(lineWidth);
glColor3f(lineR, lineG, lineB);
drawRectangle(GL_LINE_LOOP, x, y, width, height);
}
示例6: createImage
void createImage(){
int background = 0x1e5096;
printf("P3\n");
printf("%i %i\n", WIDTH, HEIGHT);
printf("255\n");
fillBackground(background);
drawRectangle(0x1e8699, 10, 50, 100, 500, 400);
drawRectangle(0x6EED1F, 20, 120, 120, 400, 500);
drawImage();
}
示例7: drawCube
void drawCube(float x1,float y1,float z1,float x2,float y2,float z2){
float z=z2-z1;
float d=30,x3,y3,x4,y4;
drawRectangle(x1,y1,x2,y2);
x3=pres(x1,z,d);
y3=pres(y1,z,d);
x4=pres(x2,z,d);
y4=pres(y2,z,d);
drawRectangle(x3,y3,x4,y4);
line(x1,y1,x3,y3);
line(x2,y2,x4,y4);
line(x1,y2,x3,y4);
line(x2,y1,x4,y3);
}
示例8: drawRectangle
void drawSpectrum::draw(int result[9]){
for (int i = 0; i < 9; i++) {
if (result[i] < previousFlow[i]) {
int debutEffacement = (previousFlow[i]>8) ? 8 : previousFlow[i];
int x = 9 - debutEffacement;
drawRectangle(i, debutEffacement, x, 1, 12);
previousFlow[i] --;
}
else {
drawRectangle(i, 0, result[i], 1, 60);
previousFlow[i] = result[i];
}
}
}
示例9: while
void Draw::renderRect()
{
std::stack <int> tempPoints;
std::stack <char *> tempColor;
tempPoints=pointlist;
tempColor=colorlist;
if (pointlist.size()/4!=(colorlist.size()))
std::cout<<"Error,mismatch between number of colors and points in the rectangle"<<std::endl;
while(!tempPoints.empty())
{
int x = tempPoints.top();
tempPoints.pop();
int y = tempPoints.top();
tempPoints.pop();
int width = tempPoints.top();
tempPoints.pop();
int height = tempPoints.top();
tempPoints.pop();
drawRectangle(x,y,width,height,tempColor.top());
tempColor.pop();
}
}
示例10: calculateTextSize
void Button::draw ( int _x, int _y )
{
std::pair< int, int > dimensions = calculateTextSize();
drawRectangle( _x, _y, dimensions.first + 2 * PADDING, dimensions.second + 2 * PADDING );
drawText( _x + PADDING, _y + PADDING );
}
示例11: drawRectangle
void DrawingSurface::drawFilledRectangle(const Color::RGBA<float>& frontColor,
const Color::RGBA<float>& backColor, float x, float y, float width, float height, float lineWidth)
{
if (backColor.alpha > 0)
{
// Draw the back as a quad with the proper color
pImpl->baseShader->bindUniform("Color", backColor);
const float vertices[] =
{
x, y + height,
x, y,
x + width, y,
x, y + height,
x + width, y,
x + width, y + height
};
::glEnableVertexAttribArray(Gfx3D::Vertex<>::vaPosition);
::glVertexAttribPointer(Gfx3D::Vertex<>::vaPosition, 2, GL_FLOAT, false, 0, vertices);
// Draw
::glDrawArrays(GL_TRIANGLES, 0, 6);
::glDisableVertexAttribArray(Gfx3D::Vertex<>::vaPosition);
}
if (frontColor != backColor && lineWidth > 0)
drawRectangle(frontColor, backColor, x, y, width, height, lineWidth);
}
示例12: mouse
/* draw figure what was chosen from the buttons */
void mouse(int button, int state, int x, int y)
{
int new_y = mapState.window_height - y;
int a;
Point* new_point ;
a = (x > PANEL_BORD_PADDING);
initFlag(x, new_y);
if (mapState.drawing_state == DRAWING_RECT && a) {
drawRectangle(x, new_y);
} else if (mapState.drawing_state == DRAWING_CIRCLE && a) {
drawCircle(x, new_y, CIRCLE_DIAMETER);
} else if (mapState.drawing_state == DRAWING_LINE && a) {
if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN) {
mapState.DrawingLine = START;
mapState.new_point = createPoint(x, new_y, mapState.points_storage, mapState.marked_point);
createEdge(mapState.edges_storage, mapState.new_point, mapState.marked_point, mapState.previous_point);
mapState.previous_point = mapState.new_point;
}
draw();
}
}
示例13: MessageBox
//处理图片的事件处理函数
void CRecognitionTextView::OnDeal()
{
// TODO: 在此添加命令处理程序代码
if(src == NULL)
{
if(filePath !="")
{
src = tools.deal(filePath,src,&outlineSs,&lines,outline,isCutted);
if(src == NULL)
{
MessageBox(TEXT("加载失败!"));
}
else
{
Invalidate();
drawRectangle(0, m_nVScrollPos);
OnPaint();
}
}
else
{
MessageBox(TEXT("未加载图片!"));
}
}
else
{
MessageBox(TEXT("不能处理图片!"));
}
}
示例14: main
void main(void)
{
unsigned char tmp;
unsigned char x = 0;
P1_4 = 1;
//P1_4 = 0;
fb_init();
keyboard_init();
EA = 1; // enable global interrupts
clearDisplay();
drawRectangle(0,0,13,19);
while(1) {
/*
tmp = readBuf();
if(tmp == 0x34)
{
if(x == 0){
setPx(2,2);
x = 1;
}
else {
clearPx(2,2);
x = 0;
}
}
*/
}
}
示例15: glLineWidth
void Frame::drawBorder() {
glLineWidth(1.0f);
glColor3f(0.3f, 0.3f, 0.3f);
drawRectangle(
posLeft, posTop,
outerWidth, outerHeight);
}