void GuiStaticGraphicElement::renderElement(IRenderer* renderer) {
    int windowX, windowY;
    getWindowCoords(windowX, windowY);
    
    if (graphic != nullptr) {
        graphic->drawAt(windowX, windowY);
    }
}
Example #2
0
void GuiPanelHeader::renderElement(IRenderer* renderer) {
    GuiStaticGraphicElement::renderElement(renderer);

    int windowX, windowY;
    getWindowCoords(windowX, windowY);

    if (iconGraphic != nullptr) {
        iconGraphic->drawShadowAt(windowX + 209, windowY + 6);
        iconGraphic->drawAt(windowX + 203, windowY);
    }
}
Example #3
0
bool GuiBase::hitTest(int windowX, int windowY) const {
    // Unsichtbare Elemente werden nicht getroffen
    if (!visible) {
        return false;
    }

    // Gibt es sichtbare Kinder an dieser Stelle? Dann liegen sie drüber und wir treffen nicht hier
    for (const GuiBase* childElement : childElements) {
        if (childElement->hitTest(windowX, windowY)) {
            return false;
        }
    }

    // Fensterkoordinaten ermitteln
    int thisWindowX, thisWindowY;
    getWindowCoords(thisWindowX, thisWindowY);

    // Kollision prüfen
    return ((windowX >= thisWindowX) && (windowY >= thisWindowY) &&
            (windowX < thisWindowX + width) && (windowY < thisWindowY + height));
}
Example #4
0
int ofxObject::collectNodes(int iSelect, ofxObject *iNodes[], int iNumber, int iMax)
{
	int curNode = iNumber;
  
	if (iNumber >= iMax) {
		printf("ofxObject::collectNodes() cannot render more than %d objects.\n", iMax);
		return curNode;
	}
  
	// v2.25 - default - we are not sorted.
	sortedObjectsWindowZ = 0;
	isSortedObject = false;
  
	if (shown) {
		if ((iSelect == OF_RENDER_TRANSPARENT) && !hasTransparency()) {
			// Skip it — looking for transparent objects, but this one is opaque
		}
		else if	((iSelect == OF_RENDER_OPAQUE) && hasTransparency()) {
			// Skip it — looking for opaque objects, but this one is transparent
		}
		else if ((iSelect == OF_RENDER_ONTOP) && (!renderOntop)) {
			// Skip it - looking for on-top objects, but this is regular
		}
		else {
			// this is an object we want to add to the list
			iNodes[iNumber] = (ofxObject *)this;
			curNode++;
      
			if (!renderOntop) isSortedObject = true;
		}
    
		if (isSortedObject) sortedObjectsWindowZ = getWindowCoords().z;
		//continue down the tree
		for (unsigned int i = 0; i < children.size(); i++) {
			curNode = children[i]->collectNodes(iSelect, iNodes, curNode, iMax);
		}
	}
  
	return curNode;
}
Example #5
0
void GUI3DDirectionArrow::render() {

	glPushAttrib( GL_ALL_ATTRIB_BITS );

	float winX=0.f, winY=0.f;
	getWindowCoords( winX, winY );

	glViewport( (int)winX, (int)winY, (int)myW, (int)myH );
	glScissor( (int)winX, (int)winY, (int)myW, (int)myH );

	// @TODO: Would be nice to put in normals and a light source on this
	glEnable( GL_LIGHTING );
	glEnable( GL_LIGHT0 );
	float pos0[4] = { -1.f, 0.5, 0.f, 0.f };
	float dif0[4] = { 0.3f, 0.3f, 0.6f, 1.f };
	glLightfv( GL_LIGHT0, GL_POSITION, pos0 );
	glLightfv( GL_LIGHT0, GL_DIFFUSE, dif0 );
	glEnable( GL_LIGHT1 );
	float pos1[4] = { 0.8f, 0.1f, 0.001f, 0.f };
	float dif1[4] = { 0.8f, 0.8f, 1.0f, 1.f };
	glLightfv( GL_LIGHT1, GL_POSITION, pos1 );
	glLightfv( GL_LIGHT1, GL_DIFFUSE, dif1 );

	glMatrixMode( GL_PROJECTION );
	glPushMatrix();
	glLoadIdentity();
	gluPerspective( 45.f, 1.f, 0.1, 10.0 );
	glMatrixMode( GL_MODELVIEW );
	glPushMatrix();
	glLoadIdentity();
	gluLookAt( 0.0, 1.2, 2.5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0 );

	glMultMatrixf( (const float *)&mat );

	glClear( GL_DEPTH_BUFFER_BIT );
	glEnable( GL_DEPTH_TEST );
	glEnable( GL_COLOR_MATERIAL );

	// DRAW the stick part
	{
		glColor3ub( 255, 255, 255 );
		glBegin( GL_QUAD_STRIP );
		float tf = 0.f, tfStep = PI2F / 16.f;
		for( int t=0; t<=16; t++, tf += tfStep ) {
			FVec3 a( 0.f, sinf(tf), cosf(tf) );
			FVec3 top = a;
			top.mul( 0.1f );
			top.x = 0.3f;
			FVec3 bot = a;
			bot.mul( 0.2f );
			bot.x = -1.f;
			glNormal3fv( a );
			glVertex3fv( top );
			glVertex3fv( bot );
		}
		glEnd();
	}

	// DRAW a cap on the stick part
	{
		glColor3ub( 255, 255, 255 );
		glBegin( GL_TRIANGLE_FAN );
		float tf = 0.f, tfStep = PI2F / 16.f;
		glNormal3f( -1.f, 0.f, 0.f );
		glVertex3f( -1.f, 0.f, 0.f );
		for( int t=0; t<=16; t++, tf += tfStep ) {
			glVertex3f( -1.f, 0.2f*(float)sin(tf), 0.2f*(float)cos(tf) );
		}
		glEnd();
	}

	// DRAW the pointy part
	{
		glColor3ub( 255, 200, 200 );
		glBegin( GL_QUAD_STRIP );
		float tf = 0.f, tfStep = PI2F / 16.f;
		for( int t=0; t<=16; t++, tf += tfStep ) {
			FVec3 a( 0.f, (float)sin(tf), (float)cos(tf) );
			FVec3 top = a;
			top.mul( 0.0f );
			top.x = 1.f;
			FVec3 bot = a;
			bot.mul( 0.3f );
			bot.x = 0.3f;
			glNormal3fv( a );
			glVertex3fv( top );
			glVertex3fv( bot );
		}
		glEnd();
	}

	// DRAW a cap on the pointy part
	{
		glColor3ub( 255, 200, 200 );
		glBegin( GL_TRIANGLE_FAN );
		float tf = 0.f, tfStep = PI2F / 16.f;
		glNormal3f( -1.f, 0.f, 0.f );
		glVertex3f( 0.3f, 0.f, 0.f );
		for( int t=0; t<=16; t++, tf += tfStep ) {
			glVertex3f( 0.3f, 0.3f*(float)sin(tf), 0.3f*(float)cos(tf) );
		}
		glEnd();
	}

	glMatrixMode( GL_PROJECTION );
	glPopMatrix();
	glMatrixMode( GL_MODELVIEW );
	glPopMatrix();
}