Exemple #1
0
int CglWnd::drawGL()
{
	//esDPrint(L"DrawBegin\n");

	glClear(GL_COLOR_BUFFER_BIT);
	//复位坐标
	memcpy(m_dTexVertex, m_oTexVertex, sizeof(m_oTexVertex));
	if (!m_bEdit)
	{
		updateBubbles();
	}
	glVertexAttribPointer(positionLoc, 3, GL_INT, GL_FALSE, 0, m_dTexVertex);
	glVertexAttribPointer(texCoordLoc, 2, GL_FLOAT, GL_FALSE, 0, m_texCoord);
	glBindTexture(GL_TEXTURE_2D, texture[TEXID_BG]);
	glDrawElements(GL_TRIANGLES /*GL_LINE_LOOP*/, columnPieces*rowPieces*3*2, GL_UNSIGNED_SHORT, m_indices);

	if (m_bEdit)
	{	
		int nHide = 0;
		Bubble *bubbleSelect = NULL;
		glBindTexture(GL_TEXTURE_2D, texture[TEXID_SET]);
		for (int i = 0; i < MAX_BUBBLES; i++)
		{
			Bubble *b = &m_bubbles[i];
			if (b->eState == ST_REMOVED) continue;
			b->update();
			if (b->eState == ST_NORMAL)
			{
				nHide++;
				continue;
			}
			if (b->bSelect)
				bubbleSelect = b;
			else
				drawSquare(b->ox, b->oy, b->r * b->zoomRate);
		}
		if (bubbleSelect)
		{
			glBindTexture(GL_TEXTURE_2D, texture[TEXID_SET_SELECT]);
			drawSquare(bubbleSelect->ox, bubbleSelect->oy, bubbleSelect->r * bubbleSelect->zoomRate);
		}
		
		if ( m_activeBubbles > 0)
			m_bEdit = nHide < m_activeBubbles;
	}
	m_toolbar.draw();
	//esDPrint(L"Draw\n");
	eglSwapBuffers(m_Display, m_Surface);
	g_fps_count++;
	return 1;
}
Exemple #2
0
void GameBoard::updateBubblePostion(float dt){
    Bubble * bubble;
    CCPoint * point;
    for (int i=0; i<bubblesData->count(); i++) {
        bubble = (Bubble*) bubblesData->objectAtIndex(bubblesData->count() - 1 - i);
        point = getBubblePostion(bubble);
        if (!bubble->active) {
            bubble->x = point->x;
            bubble->y = point->y;
            bubble->setPosition(CCPointMake(bubble->x, bubble->y));
        }else{
            bubble->update(dt);
        }
    }
}