OpenGL 2彼此相差

时间:2017-05-28 11:43:53

标签: opengl

我希望在openGL场景中以2个正方形为中心。

我想要这样:https://image.prntscr.com/image/776a14cd345047a1985072e0cf279ceb.png

我怎么能用glVertex和glColor做到这一点?

由于

1 个答案:

答案 0 :(得分:0)

这样的事情:

UILabel *messageLbl = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, self.tableView.bounds.size.width, 50)];

messageLbl.text = @"\n\n NO REGISTRATIONS FOUND";
messageLbl.font = [UIFont fontWithName:@"Sansation-Bold" size:20.0f];
messageLbl.textColor = [UIColor lightGrayColor];
messageLbl.textAlignment = NSTextAlignmentCenter;
messageLbl.numberOfLines = 0;

[messageLbl sizeToFit];

//set back to label view
self.tableView.tableHeaderView = messageLbl;

这是我最好的眼球工作之一。输出(左边是我的,右下边是你的):

enter image description here

请注意,我正在绘制一个全屏黑色四边形而不是通常做的事情(void draw() { glBegin(GL_QUADS); glColor3f(0.0f, 0.0f, 0.0f); glVertex2f(-1.0f, -1.0f); glVertex2f( 1.0f, -1.0f); glVertex2f( 1.0f, 1.0f); glVertex2f(-1.0f, 1.0f); glColor3f(1.0f, 1.0f, 1.0f); glVertex2f(-0.5f, 0.8f); glVertex2f( 0.8f, 0.8f); glVertex2f( 0.8f, 0.0f); glVertex2f(-0.5f, 0.0f); glVertex2f(-0.3f, 0.0f); glVertex2f( 0.6f, 0.0f); glVertex2f( 0.6f,-0.6f); glVertex2f(-0.3f,-0.6f); glEnd(); } 然后glClearColor(0.0f, 0.0f, 0.0f);),因为你专门用glClear(GL_COLOR_BUFFER_BIT);和{{1}来提问}}