Beispiel #1
0
Void CText::Render(CRenderer& renderer)
{
	Int32 length = m_TextLength - m_CtrlCharCount;
	Float32 x, y;
	CVector2f reso = renderer.GetCurrentViewport()->GetSize();

    if( length <= 0 || m_Font == NULL  )
        return ;

	CShader& shader = m_Font->GetShader();


    if(length <= m_Capacity)
    {
		UpdateBuffer( 0, length);

		renderer.Activate( m_VertexBuffer, 0 );
		renderer.Activate( m_VertexLayout );

        x = (Float32) ( GetPosition().GetX() );
        y = (Float32) ( 1.0f - GetPosition().GetY() );

        CVector3f snapedPos( (Float32)x, (Float32)y , 0.0f );

        shader.GetParameter("Position")->SetValue( snapedPos );
        shader.GetParameter("Resolution")->SetValue( reso );
        shader.GetParameter("InputTexture")->SetValue( m_Font->GetTexture() );

        CVector2f textureSize( (Float32)m_Font->GetTextureWidth(), (Float32)m_Font->GetTextureHeight() );
        shader.GetParameter("Color")->SetValue( m_Color );

        renderer.Activate( shader );

		renderer.Draw( nPrimitiveType_TriangleList, length * 6, 0 );

    }
    else
    {
        Int32 offset = 0;
        Int32 count = m_Capacity;

        while(offset < length)
        {
            UpdateBuffer( offset, count);
            offset += count;

            count = length - offset;
            if(count > m_Capacity)
                count = m_Capacity;
        }
    }

}
void GenmeshAnimationPDL::Update(csTicks current, int num_verts, 
                                 uint32 version_id)
{
  if (!prepared) Prepare();

  if (buffers.GetSize() == 0) return;

  // @@@ FIXME: Bit of a waste here to always update custom buffers...
  for (size_t b = 0; b < buffers.GetSize(); b++)
  {
    bool updateRB = (buffers[b].lastMeshVersion != version_id)
      || !buffers[b].rbuf.IsValid();

    UpdateBuffer (buffers[b], current, 0, num_verts, version_id);
    if (updateRB)
    {
      buffers[b].rbuf = csRenderBuffer::CreateRenderBuffer (
        buffers[b].combinedColors.GetSize(), CS_BUF_DYNAMIC, CS_BUFCOMP_FLOAT,
        4);

      const char* rbufname = factory->type->strings->Request (buffers[b].name);
      genmesh->RemoveRenderBuffer (rbufname);
      genmesh->AddRenderBuffer (rbufname, buffers[b].rbuf);
    }
    buffers[b].rbuf->SetData (buffers[b].combinedColors.GetArray());
  }
}
Beispiel #3
0
/*! Updates the UI Widget
 *
 *  @param          fDeltaTime      Elapsed time since lase update
 *  @returns        ICRESULT        Success/failure of Updating the widget
**/
ICRESULT icWidget::Update(const icReal fDeltaTime)
{
    if (m_bUpdateBuffer)
        UpdateBuffer();

    return IC_OK;
}// END FUNCTION Update(const icReal fDeltaTime)
Beispiel #4
0
	void ArrayBuffer<DataType>::SetBufferUsage(unsigned int usage)
	{
		if (m_BufferUsage != usage)
		{
			DeleteBuffer();
			UpdateBuffer();
		}
	}
void BFTimeCtrl::TextCtrl::ApplyIncrement (bool bPositiv)
{
	UpdatePosition();
	SelectPart();	
	UpdateBuffer();
	Increment(bPositiv);
	FlushBuffer();
	SelectPart();
}
Beispiel #6
0
//--------------------------------------------------------------------------------
DubDelay::DubDelayKernel::DubDelayKernel(AUEffectBase * inAudioUnit)
	: AUKernelBase(inAudioUnit)
{
	buffer = NULL;
	allocatedBufferSize = 0;
	UpdateBuffer();

	Reset();
}
Beispiel #7
0
	MemoryArrayReader(const char *buffer, long length)
	{
		if (length > 0)
		{
			buf.Resize(length);
			memcpy(&buf[0], buffer, length);
		}
		UpdateBuffer();
	}
void Animator::UpdateAnimation()
{
    updatebuffer = AnimationList[cur_anim].UpdateLoop();
    if(updatebuffer)
        UpdateBuffer();

    //ToBatchRenderer();
    return;
}
const csColor4* GenmeshAnimationPDL::UpdateColors (csTicks current,
	const csColor4* colors, int num_colors, uint32 version_id)
{
  if (!prepared) Prepare();

  if (colorsBuffer.name == 0) return colors;
  UpdateBuffer (colorsBuffer, current, colors, num_colors, version_id);
  return colorsBuffer.combinedColors.GetArray();
}
GLuint Model::AddVertex(VertexFormat* vert)
{
	if (numVertices > 0)
	{
		// Allocate space equivalent to our current vertices array.
		VertexFormat* tempVerts = (VertexFormat*)malloc(sizeof(VertexFormat) * numVertices);
		
		// Copy our current vertices array into our temporary array.
		memcpy(tempVerts, vertices, numVertices);

		// Increase the number of vertices count by 1.
		numVertices++;

		// Free the vertices array.
		free(vertices);

		// Allocate space equivalent to our new vertices size.
		vertices = (VertexFormat*)malloc(sizeof(VertexFormat) * numVertices);

		// Copy the data from the temporary array back into the vertices array.
		memcpy(vertices, tempVerts, numVertices - 1);

		// Free the temporary array.
		free(tempVerts);

		// Set the last value in the vertices array to the new vertex.
		vertices[numVertices - 1] = *vert;

		// Update our buffer to match this change.
		UpdateBuffer();

		// Return the index reference to this vertex.
		return numVertices - 1;
	}
	else
	{
		// Create a new vertices array of size 1.
		vertices = (VertexFormat*)malloc(sizeof(VertexFormat));

		// Set the value to the new vertex.
		vertices[0] = *vert;

		// Set the number of vertices to 1.
		numVertices = 1;

		// Initialize the buffer.
		InitBuffer();

		// Return the index reference to this vertex (zero).
		return 0;
	}
}
Beispiel #11
0
HRESULT	CRainDropper::FrameMove	()
{
	m_elapsedTime		=	m_timer ->GetElapsedTime ();
	m_elapsedMiliTime	=	m_timer ->GetElapsedMilliTime ();

	if	(	m_elapsedTime	>	0.1f	)	m_elapsedTime	=	0.1f;
	
	CheckDropGenerating ();
	UpdateDrops ();
	UpdateBuffer ();
	
	return	S_OK;
}
Beispiel #12
0
// callback
void CSoundStreamServerSession::MaoscBufferCopied(TInt aError, const TDesC8& /*aBuffer*/) {
	readyForWrite=true;

	// underflow? reopen!
	if (aError==KErrUnderflow) {
		ReOpen();
	}
	
	// update next buffer
	if ((aError==KErrUnderflow) || (aError==KErrNone)) {
		UpdateBuffer();
	}
}
Beispiel #13
0
// playing stopped
void CSoundStreamServerSession::MaoscPlayComplete(TInt aError) {
	readyForWrite=true;

	timeOfUpdate.UniversalTime();
	
	// if underflow, restart
	if (aError==KErrUnderflow) {
		ReOpen();
		UpdateBuffer();
	} else {
		// no underflow? then it was manually stopped...
		CActiveScheduler::Stop();
	}
}
Beispiel #14
0
void UCIParser<NumType, LabelType>::SetFilePosition(int64_t position)
{
    int rc = _fseeki64(m_pFile, position, SEEK_SET);
    if (rc)
        RuntimeError("UCIParser::SetFilePosition - error seeking in file");

    // setup state machine to start at this position
    PrepareStartPosition(position);

    // read in the first buffer of data from this position,  first buffer is expected to be read after a reposition
    UpdateBuffer();

    // FUTURE: in debug we could validate the value is either 0, or the previous character is a '\n'
}
void FD3D12DynamicRHI::UnlockBuffer(FRHICommandListImmediate* RHICmdList, BufferType* Buffer)
{
	FD3D12LockedResource& LockedData = Buffer->LockedData;
	check(LockedData.bLocked == true);

	// Determine whether the buffer is dynamic or not.
	const bool bIsDynamic = (Buffer->GetUsage() & BUF_AnyDynamic) ? true : false;

	if (bIsDynamic)
	{
		// If the Buffer is dynamic, its upload heap memory can always stay mapped. Don't do anything.
	}
	else
	{
		if (LockedData.bLockedForReadOnly)
		{
			//Nothing to do, just release the locked data at the end of the function
		}
		else
		{
			// Copy the contents of the temporary memory buffer allocated for writing into the Buffer.
			BufferType* CurrentBuffer = Buffer;

			// Update all of the resources in the LDA chain
			while (CurrentBuffer)
			{
				// If we are on the render thread, queue up the copy on the RHIThread so it happens at the correct time.
				if (ShouldDeferBufferLockOperation(RHICmdList))
				{
					new (RHICmdList->AllocCommand<FRHICommandUpdateBuffer>()) FRHICommandUpdateBuffer(&CurrentBuffer->ResourceLocation, LockedData.ResourceLocation, LockedData.LockedOffset, LockedData.LockedPitch);
				}
				else
				{
					UpdateBuffer(CurrentBuffer->ResourceLocation.GetResource(),
						CurrentBuffer->ResourceLocation.GetOffsetFromBaseOfResource() + LockedData.LockedOffset,
						LockedData.ResourceLocation.GetResource(),
						LockedData.ResourceLocation.GetOffsetFromBaseOfResource(),
						LockedData.LockedPitch);
				}

				CurrentBuffer = CurrentBuffer->GetNextObject();
			}
		}
	}

	LockedData.Reset();
}
Beispiel #16
0
bool FileReader::OpenMemoryArray(std::function<bool(TArray<uint8_t>&)> getter)
{
	auto reader = new MemoryArrayReader(nullptr, 0);
	if (getter(reader->GetArray()))
	{
		Close();
		reader->UpdateBuffer();
		mReader = reader;
		return true;
	}
	else
	{
		// This will keep the old buffer, if one existed
		delete reader;
		return false;
	}
}
void FD3D12DynamicRHI::UnlockBuffer(FRHICommandListImmediate* RHICmdList, BufferType* Buffer)
{
	// Find the outstanding lock for this Buffer.
	FD3D12LockedKey LockedKey(Buffer);
	FD3D12LockedData* LockedData = FindInOutstandingLocks(LockedKey);
	check(LockedData);

	// Determine whether the buffer is dynamic or not.
	const bool bIsDynamic = (Buffer->GetUsage() & BUF_AnyDynamic) ? true : false;

	if (bIsDynamic)
	{
		// If the Buffer is dynamic, its upload heap memory can always stay mapped. Don't do anything.
	}
	else
	{
		// If the static Buffer lock involved a staging resource, it was locked for reading.
		if (LockedData->StagingResource)
		{
			// Unmap the staging buffer's memory.
			ID3D12Resource* StagingBuffer = LockedData->StagingResource.GetReference()->GetResource();
			StagingBuffer->Unmap(0, nullptr);
		}
		else
		{
			// Copy the contents of the temporary memory buffer allocated for writing into the Buffer.
			FD3D12ResourceLocation* UploadHeapLocation = LockedData->UploadHeapLocation.GetReference();

			// If we are on the render thread, queue up the copy on the RHIThread so it happens at the correct time.
			if (ShouldDeferBufferLockOperation(RHICmdList))
			{
				new (RHICmdList->AllocCommand<FRHICommandUpdateBuffer>()) FRHICommandUpdateBuffer(Buffer->ResourceLocation, UploadHeapLocation, LockedData->Pitch);
			}
			else
			{
				UpdateBuffer(Buffer->ResourceLocation->GetResource(),
					Buffer->ResourceLocation->GetOffset(), UploadHeapLocation->GetResource(), UploadHeapLocation->GetOffset(), LockedData->Pitch);
			}
		}
	}

	// Remove the FD3D12LockedData from the lock map.
	// If the lock involved a staging resource, this releases it.
	RemoveFromOutstandingLocks(LockedKey);
}
Beispiel #18
0
// callback for iStream->Open()
void CSoundStreamServerSession::MaoscOpenComplete(TInt aError) {
	if (aError==KErrNone) {
        // set stream properties to 16bit,16KHz mono
		iStream->SetAudioPropertiesL(TMdaAudioDataSettings::ESampleRate16000Hz, 
                                     TMdaAudioDataSettings::EChannelsMono);

		iStream->SetVolume(iStream->MaxVolume());        
		iStream->SetPriority(EPriorityMuchMore, EMdaPriorityPreferenceNone);
		
		initialized=true;

		// Start timer (Fill first buffer)
		UpdateBuffer();
	
	} else {
		// should not happen...
		RDebug::Print(_L("Could not init sound!"));
	}
}
Beispiel #19
0
void Renderer::set_lighting_constant_values()
{
	const vector<Light*> &lights_to_render = scene_to_render->get_lights();
	if (lights_to_render.size() > 0)
	{
		Light* first_light = lights_to_render[0];
		lighting_contants_buffer_cpu.light_color = first_light->get_color();
		lighting_contants_buffer_cpu.ws_light_position = first_light->get_position();

		D3DXMATRIX viewProjection = camera_->get_view_projection_matrix();
		D3DXVECTOR4 ss_light_p;
		D3DXVec4Transform(&ss_light_p, &lighting_contants_buffer_cpu.ws_light_position, &viewProjection);
		ss_light_p = ss_light_p / ss_light_p.w;
		ss_light_p.x = ss_light_p.x * 0.5 + 0.5;
		ss_light_p.y = ss_light_p.y * 0.5 + 0.5;

		lighting_contants_buffer_cpu.ss_light_position = ss_light_p;

		UpdateBuffer(&lighting_contants_buffer_cpu, sizeof(LightingConstantsBuffer), lighting_constants_buffer_gpu);
	}
}
Beispiel #20
0
	void Shader::BindSubMesh(const std::shared_ptr<Mesh> &mesh, unsigned int index)
	{
		auto subMesh = mesh->GetSubMeshAt(index);
		if (subMesh == nullptr)
		{
			FURYW << "SubMesh out of range!";
			return;
		}

		if (mesh->GetDirty())
			mesh->UpdateBuffer();

		if (subMesh->GetDirty())
			subMesh->UpdateBuffer();

		if (m_Dirty || mesh->GetDirty() || subMesh->GetDirty() || subMesh->Indices.GetDirty())
			return;

		BindMeshData(mesh);

		glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, subMesh->Indices.GetID());
	}
Beispiel #21
0
void O_Drawer(void)
{
   int i;
   int offset;

   // Erase old and Draw new cursor frame
   EraseBlock(56, 40, o_cursor1->width, 200, NULL);
   if(cursorframe)
      DrawJagobj(o_cursor1, 60, menuitem[cursorpos].y - 2, NULL);
   else
      DrawJagobj(o_cursor2, 60, menuitem[cursorpos].y - 2, NULL);

   // Draw menu

   print(104, 10, "Options");

   for(i = 0; i < NUMMENUITEMS; i++)
   {
      print(menuitem[i].x, menuitem[i].y, menuitem[i].name);

      if(menuitem[i].hasslider == true)
      {
         DrawJagobj(o_slidertrack , menuitem[i].x + 2, menuitem[i].y + 20, NULL);
         offset = (slider[i].curval * SLIDEWIDTH) / slider[i].maxval;
         DrawJagobj(o_slider, menuitem[i].x + 7 + offset, menuitem[i].y + 20, NULL);
      }
   }

   // Draw control info

   print(menuitem[controls].x + 10, menuitem[controls].y + 20, "A");
   print(menuitem[controls].x + 10, menuitem[controls].y + 40, "B");
   print(menuitem[controls].x + 10, menuitem[controls].y + 60, "C");

   O_DrawControl();

   UpdateBuffer();
}
Beispiel #22
0
void Renderer::set_mesh_constant_values(const Mesh *mesh)
{
	D3DXMATRIX world_matrix = mesh->get_frame();
	D3DXMATRIX world_view_matrix = world_matrix * camera_->get_view_matrix();
	D3DXMATRIX world_view_projection_matrix = world_matrix * camera_->get_view_projection_matrix();

	float determinant;
	D3DXMATRIX inv_world_matrix;
	D3DXMATRIX inv_world_view_matrix;
	D3DXMATRIX inv_world_view_projection_matrix;

	D3DXMatrixInverse(&inv_world_matrix, &determinant, &world_matrix);
	D3DXMatrixInverse(&inv_world_view_matrix, &determinant, &world_view_matrix);
	D3DXMatrixInverse(&inv_world_view_projection_matrix, &determinant, &world_view_projection_matrix);

	D3DXMatrixTranspose(&world_matrix, &world_matrix);
	D3DXMatrixTranspose(&world_view_matrix, &world_view_matrix);
	D3DXMatrixTranspose(&world_view_projection_matrix, &world_view_projection_matrix);

	D3DXMatrixTranspose(&inv_world_matrix, &inv_world_matrix);
	D3DXMatrixTranspose(&inv_world_matrix, &inv_world_matrix);
	D3DXMatrixTranspose(&inv_world_view_projection_matrix, &inv_world_view_projection_matrix);

	mesh_constants_buffer_cpu.world_matrix = world_matrix;
	mesh_constants_buffer_cpu.world_view_matrix = world_view_matrix;
	mesh_constants_buffer_cpu.world_view_projection_matrix = world_view_projection_matrix;

	mesh_constants_buffer_cpu.inv_world_matrix = inv_world_matrix;
	mesh_constants_buffer_cpu.inv_world_view_matrix = inv_world_view_matrix;
	mesh_constants_buffer_cpu.inv_world_view_projection_matrix = inv_world_view_projection_matrix;

	mesh_constants_buffer_cpu.diffuse_color = mesh->get_material() ? mesh->get_material()->get_diffuse_color() : D3DXVECTOR4(1,1,1,1);
	mesh_constants_buffer_cpu.bb_min = mesh->get_bb().get_min();
	mesh_constants_buffer_cpu.bb_max = mesh->get_bb().get_max();

	UpdateBuffer(&mesh_constants_buffer_cpu, sizeof(MeshConstantsBuffer), mesh_constants_buffer_gpu);
}
Beispiel #23
0
void Renderer::set_frame_constant_values()
{
	D3DXMATRIX cur_frame_view_matrix = camera_->get_view_matrix();
	D3DXMATRIX cur_frame_projection_matrix = camera_->get_projection_matrix();
	D3DXMATRIX cur_frame_view_projection_matrix = camera_->get_view_projection_matrix();

	D3DXMATRIX cur_frame_inv_view_matrix = camera_->get_inv_view_matrix();
	D3DXMATRIX cur_frame_inv_projection_matrix = camera_->get_inv_projection_matrix();
	D3DXMATRIX cur_frame_inv_view_projection_matrix = camera_->get_inv_view_projection_matrix();

	D3DXMatrixTranspose(&cur_frame_view_matrix, &cur_frame_view_matrix);
	D3DXMatrixTranspose(&cur_frame_projection_matrix, &cur_frame_projection_matrix);
	D3DXMatrixTranspose(&cur_frame_view_projection_matrix, &cur_frame_view_projection_matrix);

	D3DXMatrixTranspose(&cur_frame_inv_view_matrix, &cur_frame_inv_view_matrix);
	D3DXMatrixTranspose(&cur_frame_inv_projection_matrix, &cur_frame_inv_projection_matrix);
	D3DXMatrixTranspose(&cur_frame_inv_view_projection_matrix, &cur_frame_inv_view_projection_matrix);

	frame_constans_buffer_cpu.view_matrix = cur_frame_view_matrix;
	frame_constans_buffer_cpu.projection_matrix = cur_frame_projection_matrix;
	frame_constans_buffer_cpu.view_projection_matrix = cur_frame_view_projection_matrix;

	frame_constans_buffer_cpu.inv_view_matrix = cur_frame_inv_view_matrix;
	frame_constans_buffer_cpu.inv_projection_matrix = cur_frame_inv_projection_matrix;
	frame_constans_buffer_cpu.inv_view_projection_matrix = cur_frame_inv_view_projection_matrix;
	
	frame_constans_buffer_cpu.right_direction = camera_->get_right_vector();
	frame_constans_buffer_cpu.up_direction = camera_->get_up_vector();
	frame_constans_buffer_cpu.view_direction = camera_->get_forward_vector();
	frame_constans_buffer_cpu.camera_position = camera_->get_position();

	frame_constans_buffer_cpu.near_far_padding2 = D3DXVECTOR4(camera_->get_near(), camera_->get_far(), 0, 0);
	frame_constans_buffer_cpu.screen_texture_half_pixel_forced_mipmap = D3DXVECTOR4((1.0f / float(g_screenWidth)), (1.0f / float(g_screenHeight)), -1, 0);
	frame_constans_buffer_cpu.debug_vector = Utilities::get_debug_vector();

	UpdateBuffer(&frame_constans_buffer_cpu, sizeof(FrameConstantsBuffer), frame_constans_buffer_gpu);
}
Beispiel #24
0
long UCIParser<NumType, LabelType>::Parse(size_t recordsRequested, std::vector<NumType> *numbers, std::vector<LabelType> *labels)
{
    assert(numbers != NULL || m_dimFeatures == 0 || m_parseMode == ParseLineCount);
    assert(labels != NULL || m_dimLabels == 0 || m_parseMode == ParseLineCount);

    // transfer to member variables
    m_numbers = numbers;
    m_labels = labels;

    long TickStart = GetTickCount();
    long recordCount = 0;
    size_t bufferIndex = m_byteCounter - m_bufferStart;
    while (m_byteCounter < m_fileSize && recordCount < recordsRequested)
    {
        // check to see if we need to update the buffer
        if (bufferIndex >= m_bufferSize)
        {
            UpdateBuffer();
            bufferIndex = m_byteCounter - m_bufferStart;
        }

        char ch = m_fileBuffer[bufferIndex];

        ParseState nextState = (ParseState) m_stateTable[(m_current_state << 8) + ch];

        if (nextState <= Exponent)
        {
            m_builtUpNumber = m_builtUpNumber * 10 + (ch - '0');
            // if we are in the decimal portion of a number increase the divider
            if (nextState == Remainder)
                m_divider *= 10;
        }

        // only do a test on a state transition
        if (m_current_state != nextState)
        {
            // System.Diagnostics.Debug.WriteLine("Current state = " + m_current_state + ", next state = " + nextState);

            // if the nextState is a label, we don't want to do any number processing, it's a number prefixed string
            if (nextState != Label)
            {
                // do the numeric processing
                switch (m_current_state)
                {
                case TheLetterE:
                    if (m_divider != 0) // decimal number
                        m_partialResult += m_builtUpNumber / m_divider;
                    else // integer
                        m_partialResult = m_builtUpNumber;
                    m_builtUpNumber = 0;
                    break;
                case WholeNumber:
                    // could be followed by a remainder, or an exponent
                    if (nextState != TheLetterE)
                        if (nextState != Period)
                            DoneWithValue();
                    if (nextState == Period)
                    {
                        m_partialResult = m_builtUpNumber;
                        m_divider = 1;
                        m_builtUpNumber = 0;
                    }
                    break;
                case Remainder:
                    // can only be followed by a exponent
                    if (nextState != TheLetterE)
                        DoneWithValue();
                    break;
                case Exponent:
                    DoneWithValue();
                    break;
                }
            }

            // label handling
            switch (m_current_state)
            {
            case Label:
                DoneWithLabel();
                break;
            case EndOfLine:
                PrepareStartLine();
                break;
            case Whitespace:
                // this is the start of the next space delimited entity
                if (nextState != EndOfLine)
                    m_spaceDelimitedStart = m_byteCounter;
                break;
            }

            // label handling for next state
            switch (nextState)
            {
            // do sign processing on nextState, since we still have the character handy
            case Sign:
                if (ch == '-')
                    m_wholeNumberMultiplier = -1;
                break;
            case ExponentSign:
                if (ch == '-')
                    m_exponentMultiplier = -1;
                break;
            // going into whitespace or endOfLine, so end of space delimited entity
            case Whitespace:
                m_spaceDelimitedMax = m_byteCounter;
                // hit whitespace and nobody processed anything, so add as label
                // if (m_elementsConvertedThisLine == elementsProcessed)
                //    DoneWithLabel();
                break;
            case EndOfLine:
                if (m_current_state != Whitespace)
                {
                    m_spaceDelimitedMax = m_byteCounter;
                    // hit whitespace and nobody processed anything, so add as label
                    // if (m_elementsConvertedThisLine == elementsProcessed)
                    //    DoneWithLabel();
                }
            // process the label at the end of a line
            // if (m_labelMode == LabelLast && m_labels != NULL)
            // {
            //    StoreLastLabel();
            // }
            // intentional fall-through
            case LineCountEOL:
                recordCount++; // done with another record
                if (m_traceLevel > 1)
                {
                    // print progress dots
                    if (recordCount % 100 == 0)
                    {
                        if (recordCount % 1000 == 0)
                        {
                            if (recordCount % 10000 == 0)
                            {
                                fprintf(stderr, "#");
                            }
                            else
                            {
                                fprintf(stderr, "+");
                            }
                        }
                        else
                        {
                            fprintf(stderr, ".");
                        }
                    }
                }
                break;
            case LineCountOther:
                m_spaceDelimitedStart = m_byteCounter;
                break;
            }
        }

        m_current_state = nextState;

        // move to next character
        m_byteCounter++;
        bufferIndex++;
    } // while 1

    long TickStop = GetTickCount();

    long TickDelta = TickStop - TickStart;

    if (m_traceLevel > 2)
        fprintf(stderr, "\n%ld ms, %ld numbers parsed\n\n", TickDelta, (long)m_totalNumbersConverted);
    return recordCount;
}
void SSAO::Initialize(int screenWidth, int screenHeight, float farC, float nearC, float fov) {
	_app->SwitchActive("sib");
	_screenHeight = screenHeight;
	_screenWidth = screenWidth;
	_showDebug = false;
	_near = nearC;
	_far  = farC;
	_fov = fov;
	_kernalSize = 16;
	_noiseSize =  64;
	_rad = 0.065;
	_totStrength = 1.6;
	_strength = 0.7;
	_offset = 18;
	_falloff = 0.0001;
	_defrad = 0.02;
	_deftotStrength = 3.38;
	_defstrength = 0.7;
	_defoffset = 18;
	_deffalloff = 0.0002;
	_blurSize = 4;
	_defblurSize = 4;

	srand(time(NULL));

	//create cosntant buffer
	D3D11_BUFFER_DESC ssaoBuff;
	ssaoBuff.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
	ssaoBuff.ByteWidth = sizeof(SSAOBuffer);
	ssaoBuff.Usage = D3D11_USAGE_DYNAMIC;
	ssaoBuff.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
	ssaoBuff.MiscFlags = 0;
	ssaoBuff.StructureByteStride = 0;

	_device->CreateBuffer(&ssaoBuff, 0, &_ssaoBuffer);
	//create cosntant buffer
	D3D11_BUFFER_DESC ssaoBuff2;
	ssaoBuff2.BindFlags = D3D11_BIND_CONSTANT_BUFFER;
	ssaoBuff2.ByteWidth = sizeof(SSAOBuffer2);
	ssaoBuff2.Usage = D3D11_USAGE_DYNAMIC;
	ssaoBuff2.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
	ssaoBuff2.MiscFlags = 0;
	ssaoBuff2.StructureByteStride = 0;

	HRESULT hret = _device->CreateBuffer(&ssaoBuff2, 0, &_ssaoBuffer2);

	_deviceContext->PSSetConstantBuffers(11, 1, &_ssaoBuffer2);
	_deviceContext->PSSetConstantBuffers(10, 1, &_ssaoBuffer);
	_deviceContext->VSSetConstantBuffers(10, 1, &_ssaoBuffer);
	

	//initialize render targets
	_normalAndDepthBuffer = new RenderTarget(_device, _deviceContext);
	_normalAndDepthBuffer->CreateRenderTarget(_screenWidth, _screenHeight, DXGI_FORMAT_R32G32B32A32_FLOAT);
	_ssaoRT = new RenderTarget(_device, _deviceContext);
	_ssaoRT->CreateRenderTarget(_screenWidth, _screenHeight, DXGI_FORMAT_R32_FLOAT);
	_blurRT = new RenderTarget(_device, _deviceContext);
	_blurRT->CreateRenderTarget(_screenWidth, _screenHeight, DXGI_FORMAT_R32_FLOAT);

	BuildFullScreenQuad();
	BuildSampleKernal();
	BuildNoise();
	BuildFrustumCorner();
	BuildTextures();
	BuildUI();

	_ndPass= new ShaderProgram(_device, _deviceContext);
	_ndPass->CompileShaders(L"media/hlsl/normalAndDepthPass.vsh", L"media/hlsl/normalAndDepthPass.psh");
	_ssaoPass= new ShaderProgram(_device, _deviceContext);
	_ssaoPass->CompileShaders(L"media/hlsl/ssaoPass.vsh", L"media/hlsl/ssaoPass.psh");
	_blurPass= new ShaderProgram(_device, _deviceContext);
	_blurPass->CompileShaders(L"media/hlsl/blurrPass.vsh", L"media/hlsl/blurrPass.psh");
	_debug= new ShaderProgram(_device, _deviceContext);
	_debug->CompileShaders(L"media/hlsl/debug.vsh", L"media/hlsl/debug.psh");


	UpdateBuffer();
	UpdateBuffer2();
}
void BFTimeCtrl::TextCtrl::OnChar (wxKeyEvent& event)
{
	UpdatePosition();
	SelectPart();
	UpdateBuffer();
		
	int iKeycode = event.GetKeyCode();
	
	if (iKeycode >= 48 && iKeycode <= 57 && iPos_ < 8)
	{
		char cKeycode = iKeycode;
		wxString strTemp = strBuffer_ + (wchar_t) cKeycode;

		long lValue;
		strTemp.Right(2).ToLong(&lValue);
		
		if (lValue < iMin_ || lValue > iMax_)
			strBuffer_ = wxString("0") + (wchar_t) cKeycode;
		else 
			strBuffer_ = wxString::Format("%.2d", (int) lValue);

		FlushBuffer();
	}
	
	switch (iKeycode)
	{
		// TAB
		case WXK_TAB:
			FlushBuffer();
			
			if (!event.ShiftDown() )
				iPos_ += 3;
			else
				iPos_ -= 3;
			
			#ifndef __WXMAC__
			if (iPos_ < 0 || iPos_ > 4)
					event.Skip();
			#endif // __WXMAC__

			break;

		// ARROW LEFT
		case WXK_LEFT:
			FlushBuffer();

			iPos_ -= 3;
			if (iPos_ < 0)
				iPos_ = 0;
			break;

		// ARROW RIGHT
		case WXK_RIGHT:
			FlushBuffer();

			iPos_ += 3;
			if (iPos_ > 4) 
				iPos_ = 4;
			break;
						
		case WXK_UP:
			Increment(true);
			FlushBuffer();
			break;
			
		case WXK_DOWN:
			Increment(false);
			FlushBuffer();
			break;
		
		case 65:
		case 97:
		case 80:
		case 112:
			FlushBuffer();
		 	break;
	}
	SelectPart();
}
Beispiel #27
0
INT CmSurfaceManager::CreateBuffer(UINT size, CM_BUFFER_TYPE type,
				   CmBuffer_RT * &pSurface1D,
				   CmOsResource * pCmOsResource, void *&pSysMem)
{
	UINT index = m_pCmDevice->ValidSurfaceIndexStart();
	pSurface1D = NULL;

	if (pCmOsResource) {
		if (GetFreeSurfaceIndex(index) != CM_SUCCESS) {
			return CM_EXCEED_SURFACE_AMOUNT;
		}
	} else {
		BOOL useNewSurface = TRUE;

		if (AllocateSurfaceIndex
		    (size, 0, 0, CM_SURFACE_FORMAT_UNKNOWN, index,
		     useNewSurface, pSysMem) != CM_SUCCESS) {
			return CM_EXCEED_SURFACE_AMOUNT;
		}

		if (!useNewSurface) {
			CmSurface *pSurface = m_SurfaceArray[index];
			if (pSurface
			    && (pSurface->Type() ==
				CM_ENUM_CLASS_TYPE_CMBUFFER_RT)) {
				pSurface1D =
				    static_cast < CmBuffer_RT * >(pSurface);
			} else {
				return CM_FAILURE;
			}
			UpdateBuffer(pSurface1D, size);
			UPDATE_PROFILE_FOR_1D_SURFACE(index, size, TRUE);

			return CM_SUCCESS;
		}
	}

	if (m_bufferCount >= m_maxBufferCount) {
		CM_ASSERT(0);
		return CM_EXCEED_SURFACE_AMOUNT;
	}

	UINT handle = 0;
	INT result = AllocateBuffer(size, type, handle, pCmOsResource, pSysMem);
	if (result != CM_SUCCESS) {
		CM_ASSERT(0);
		return result;
	}

	result =
	    CmBuffer_RT::Create(index, handle, size, pCmOsResource == NULL,
				this, type, pSysMem, pSurface1D);
	if (result != CM_SUCCESS) {
		FreeBuffer(handle);
		CM_ASSERT(0);
		return result;
	}

	m_SurfaceArray[index] = pSurface1D;
	UPDATE_PROFILE_FOR_1D_SURFACE(index, size, FALSE);

	return CM_SUCCESS;
}
Beispiel #28
0
void CIFControl::RenderFade()
{
	float tempTime;
	int r = 0xff, g = 0xff, b = 0xff;

	switch( m_fadeFlag )
	{
	
	case 0 :
		m_fadeStart = g_timer.GetAppMilliTime();
		m_fadeFlag = 1;
		m_fadeColor = 0xff000000;
		break;
	
	case 1 :
		tempTime = g_timer.GetAppMilliTime() - m_fadeStart;
		tempTime /= m_fadeTime;
		if( tempTime > 1.0f ) 
		{
			tempTime = 1.0f;
			m_fadeStart = g_timer.GetAppMilliTime();
			m_fadeFlag = 2;
		}
		r = (int)( (float)r * tempTime );
		r <<= 16;
		g = (int)( (float)g * tempTime );
		g <<= 8;
		b = (int)( (float)b * tempTime );

		m_fadeColor = (0xff000000) | r | g | b;
		break;
	
	case 2 :
		tempTime = g_timer.GetAppMilliTime() - m_fadeStart;
		if( tempTime > m_stayTime )
		{
			m_fadeStart = g_timer.GetAppMilliTime();
			m_fadeFlag = 3;
		}
		m_fadeColor = 0xffffffff;
		break;
	
	case 3 :
		tempTime = g_timer.GetAppMilliTime() - m_fadeStart;
		tempTime /= m_fadeTime;
		tempTime = 1.0f - tempTime;
		if( tempTime < 0.0f ) 
		{
			tempTime = 0.0f;
			m_fadeStart = g_timer.GetAppMilliTime();
			m_fadeFlag = 4;
		}
		r = (int)( (float)r * tempTime );
		r <<= 16;
		g = (int)( (float)g * tempTime );
		g <<= 8;
		b = (int)( (float)b * tempTime );

		m_fadeColor = (0xff000000) | r | g | b;
		break;
	}
	UpdateBuffer();
	Render();
}
Beispiel #29
0
Void CText::UpdateBuffer( )
{
	UpdateBuffer( 0, MathMin( m_Capacity, m_TextLength ) );
}