Example #1
0
void tOleHandler::CalcNaturalSize()
{
  HRESULT hr;
  SIZEL sizel;
  RECTL rcl;

  assert(m_pIViewObject2 != NULL);

  if(!m_pIViewObject2)
    return;

  hr = m_pIViewObject2->GetExtent(m_fe.dwAspect, -1, NULL, &sizel);

  if(FAILED(hr))
    return;

  SETRECTL(rcl, 0, 0, sizel.cx/10, -sizel.cy/10);
  RectSet(&rcl, FALSE, TRUE);

  // Obtem medidas ja' convertidas para pixels
  SizeGet(&sizel, TRUE);

  natural_width = sizel.cx;
  natural_height = sizel.cy;
}
Example #2
0
int sgl_close_camera(CameraSgl *camera)
{
	IMAQdxError 	error = 0;
	
	if (camera->session_id) {
		sgl_stop_acquistion(camera);
		error = IMAQdxUnconfigureAcquisition(camera->session_id);
		
		if (error) {
			goto ERROR_MSG;
		}
		
		IMAQdxCloseCamera (camera->session_id);
		camera->session_id = 0;
		if (camera->display_win_num >= 0) {
			imaqCloseWindow(camera->display_win_num);
			camera->display_win_num = -1;
		}
		memset((void*)camera->interface_name, 0, sizeof(camera->interface_name));
		memset((void*)&camera->info, 0, sizeof(camera->info));
		camera->attached_win = NULL;
		camera->display_win = NULL;
		RectSet(&camera->rect_show, 0, 0, 0, 0);
		sgl_release_camera_data(camera);
	}

	return 0;
	
ERROR_MSG:
	sgl_camera_message_error(error, camera->error_callback);
	
	return -1;
}
Example #3
0
void bmpTextEntity::GenGlyphs()
{
	int lineNumber = 0;
	int xPositionIndex = 0;

	for(int i = 0; i < text.length(); i++)
	{
		if(text[i] == '\n' || text[i] == '\r\n')
		{
			lineNumber++;
		}
		else
		{
			glyphs[i].renderRect = &glyphRects[i];
			glyphs[i].InitSprite(font.texture, rows, columns, 0, 0);
			glyphs[i].SetAtlasLocation(asciiTable[text[i]]);
			Renderer::SetSpecialUniforms(glyphs[i].renderInfo, glyphs[i].spriteInfo, &glyphs[i]);
			
			int sizeX = characterSize.x;
			int sizeY = characterSize.y;
			float ratioDiff = 1.f;
			if(modifiedSize > 0)
			{
				ratioDiff = (float)modifiedSize / sizeY;
				sizeX = (int)(sizeX * ratioDiff);
				sizeY = (int)(sizeY * ratioDiff);
			}

			if(characterWidths.size() > 0)
				xPositionIndex += (int)(characterWidths[asciiTable[text[i]]] * ratioDiff);
			else
				xPositionIndex += sizeX;

			RectSet(
				tf->rectangle.left + xPositionIndex, 
				tf->rectangle.top + (sizeY * lineNumber),
				sizeX, sizeY, 
				&glyphRects[i]);
			glyphs[i].renderInfo.depth = layer;
			
			for(int j = 0; j < glyphs[i].renderInfo.uniforms.size(); j++)
			{
				if(dfStrCmp("rect", glyphs[i].renderInfo.uniforms[j].name))
				{
					glyphs[i].renderInfo.uniforms[j].valueRect =  &glyphRects[i];
					break;
				}
			}
		}
	}
}
void dfParticleSystem::UpdateParticle(ParticleInfo &particle, int index)
{
	particle.lifetime += dfDeltaTime;
	if(particle.lifetime > particle.lifespan)
	{
		particleRenderers[index].renderInfo.active = false;
		particle.dead = true;
		delete particle.renderRect;
		numParticles--;
		if(index == currentParticleCap - 1)
			currentParticleCap--;
		return;
	}

	float t = particle.lifetime / particle.lifespan;
	float ct = t;
	if(ct < sInfo.beginFadeTime)
		ct = 0.f;
	else
		ct = (ct - sInfo.beginFadeTime) / (1.f - sInfo.beginFadeTime);

	particle.color = vec4(
		particle.startColor.x + ((sInfo.endColor.x - particle.startColor.x) * ct),
		particle.startColor.y + ((sInfo.endColor.y - particle.startColor.y) * ct),
		particle.startColor.z + ((sInfo.endColor.z - particle.startColor.z) * ct),
		particle.startColor.w + ((sInfo.endColor.w - particle.startColor.w) * ct));
	particleRenderers[index].renderInfo.color = particle.color;

	if(sInfo.fadeSize)
	{
		particle.w = particle.maxSize * (1.f-ct);
		particle.h = particle.maxSize * (1.f-ct);
	}

	particle.pos.x += particle.veloc.x;
	particle.pos.y += particle.veloc.y;
	particle.veloc.x += particle.acc;
	particle.veloc.y += particle.acc;

	particle.rotation += particle.rotationSpd;

	
	RectSet(particle.pos.x - (particle.w / 2.f), particle.pos.y - (particle.h / 2.f), 
		particle.w, particle.h, particle.renderRect);
	
}
Example #5
0
void tOleHandler::UpdateInPlaceObjectRects(LPCRECT prcPos
    , BOOL fUseTenantRect)
    {
    RECTL       rcl;
    RECT        rc;
    RECT        rcClip;
    BOOL        fResizeTenant=TRUE;

    //We don't clip special anywhere in our window.
    SetRect(&rcClip, 0, 0, 32767, 32767);

    /*
     * Note that if the object here is activate-when-visible
     * we'll always have this pointer.
     */
    if (NULL!=m_pIOleIPObject)
        {
        /*
         * This uses the last position rectangle from
         * IOleInPlaceSite::OnPosRectChange if it's been
         * initialized
         */
        if (NULL==prcPos && -1!=m_rcPos.left && !fUseTenantRect)
            prcPos=&m_rcPos;

        //This code is normally called from OnPosRectChange direct.
        if (NULL!=prcPos && !fUseTenantRect)
            {
            rc=*prcPos;

            //Calculate the boundaries of the full page
            //m_pPG->CalcBoundingRect(&rcClip, FALSE);

            //Make sure we limit object to page boundaries.
            IntersectRect(&rc, &rc, &rcClip);
            }
        else
            {
            /*
             * We have no rectangle of the object on which to
             * base the position, so just use the tenant rectangle.
             * This code is also used when scrolling objects.
             */
            RectGet(&rcl, TRUE);
            RECTFROMRECTL(rc, rcl);

            //Account for scrolling
//            OffsetRect(&rc, -(int)m_pPG->m_xPos, -(int)m_pPG->m_yPos);
            fResizeTenant=FALSE;
            }


        /*
         * NOTE:  The rectangles to SetObjectRects is in client
         * coordinates of the pages window.
         */
        if (NULL!=m_pIOleIPObject)
            m_pIOleIPObject->SetObjectRects(&rc, &rcClip);

        if (fResizeTenant)
            {
            //Need to tell the tenant to change position too
            RECTLFROMRECT(rcl, rc);
            RectSet(&rcl, TRUE, FALSE);
            }
        }

    return;
    }
void dfParticleSystem::CreateParticle()
{
	ParticleInfo p;
	InitParticle(p);
	if(sInfo.useSpawnRect)
	{
		p.pos = vec2(
			(dfRand() * sInfo.spawnRect.width) + sInfo.spawnRect.left,
			(dfRand() * sInfo.spawnRect.height) + sInfo.spawnRect.top);
	}
	else
	{
		p.pos = vec2(sInfo.spawnPoint.x, sInfo.spawnPoint.y);
	}
	p.acc = sInfo.minAcc + (dfRand() * (sInfo.maxAcc - sInfo.minAcc));
	int colorIndex = rand() % sInfo.startColors.size();
	p.startColor = sInfo.startColors[colorIndex];
	p.color = p.startColor;
	p.dead = false;
	p.maxSize = sInfo.minParticleSize + (dfRand() * (sInfo.maxParticleSize - sInfo.minParticleSize));
	p.w = p.maxSize;
	p.h = p.maxSize;
	p.lifespan = sInfo.minLifespan + (dfRand() * (sInfo.maxLifespan - sInfo.minLifespan));
	p.lifetime = 0;
	p.rotation = sInfo.minStartRotation + (dfRand() * (sInfo.maxStartRotation - sInfo.minStartRotation));
	p.rotationSpd = sInfo.minRotationSpd + (dfRand() * (sInfo.maxRotationSpd - sInfo.minRotationSpd));
	float newVeloc = dfRand() * (sInfo.maxVeloc - sInfo.minVeloc);
	float xComp = cos((Pi32 / 180.f) * p.rotation) * newVeloc;
	float yComp = sin((Pi32 / 180.f) * p.rotation) * newVeloc;
	p.veloc = vec2(xComp, yComp);

	dfAssert(sInfo.textures.size() > 0); // need a texture to attatch to particle, dawg!
	int textureIndex = rand() % sInfo.textures.size();
	//p.texture = textures[textureIndex];
	p.renderRect = new Rect();
	RectSet(p.pos.x - (p.w / 2.f), p.pos.y - (p.h / 2.f), p.w, p.h, p.renderRect);

	for(int i = 0; i < currentParticleCap + 1 < MAX_PARTICLES ? currentParticleCap + 1 : MAX_PARTICLES; i++)
	{
		if(particles[i].dead)
		{
			particles[i] = p;
			
			particleRenderers[i].renderRect = p.renderRect;
			particleRenderers[i].SetTexture(sInfo.textures[textureIndex]);
			particleRenderers[i].renderInfo.active = true;
			particleRenderers[i].renderInfo.depth = layer;

			for(int cIndex = 0; cIndex < particleRenderers[i].renderInfo.uniforms.size(); cIndex++)
			{
				if(dfStrCmp("rect", particleRenderers[i].renderInfo.uniforms[cIndex].name))
				{
					particleRenderers[i].renderInfo.uniforms[cIndex].valueRect = p.renderRect;
					break;
				}
			}

			numParticles++;
			if(i == currentParticleCap)
				currentParticleCap++;

			return;
		}
	}

	dfWarn("Could not create particle. Max particles!");
}