本文整理汇总了C++中Array::GetDataSize方法的典型用法代码示例。如果您正苦于以下问题:C++ Array::GetDataSize方法的具体用法?C++ Array::GetDataSize怎么用?C++ Array::GetDataSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Array
的用法示例。
在下文中一共展示了Array::GetDataSize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetArrayBridge
Directx::TShader::TShader(const std::string& vertexSrc,const std::string& fragmentSrc,const SoyGraphics::TGeometryVertex& Vertex,const std::string& ShaderName,const std::map<std::string,std::string>& Macros,TContext& Context) :
mBoundContext ( nullptr )
{
auto& Device = Context.LockGetDevice();
auto& Compiler = Context.GetCompiler();
try
{
Array<uint8> VertBlob;
Array<uint8> FragBlob;
Compiler.Compile( GetArrayBridge(VertBlob), vertexSrc, "Vert", "vs_5_0", ShaderName + " vert shader", Macros );
Compiler.Compile( GetArrayBridge(FragBlob), fragmentSrc, "Frag", "ps_5_0", ShaderName + " frag shader", Macros );
auto Result = Device.CreateVertexShader( VertBlob.GetArray(), VertBlob.GetDataSize(), nullptr, &mVertexShader.mObject );
Directx::IsOkay( Result, "CreateVertexShader" );
Result = Device.CreatePixelShader( FragBlob.GetArray(), FragBlob.GetDataSize(), nullptr, &mPixelShader.mObject );
Directx::IsOkay( Result, "CreatePixelShader" );
MakeLayout( Vertex, GetArrayBridge(VertBlob), ShaderName, Device );
Context.Unlock();
}
catch(std::exception& e)
{
Context.Unlock();
throw;
}
}
示例2:
Directx::TGeometry::TGeometry(const ArrayBridge<uint8>&& Data,const ArrayBridge<size_t>&& _Indexes,const SoyGraphics::TGeometryVertex& Vertex,TContext& ContextDx) :
mVertexDescription ( Vertex ),
mIndexCount ( 0 )
{
Array<uint32> Indexes;
for ( int i=0; i<_Indexes.GetSize(); i++ )
Indexes.PushBack( size_cast<uint32>( _Indexes[i] ) );
// Set up the description of the static vertex buffer.
D3D11_BUFFER_DESC vertexBufferDesc;
vertexBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
vertexBufferDesc.ByteWidth = Data.GetDataSize();//Vertex.GetDataSize();
vertexBufferDesc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
vertexBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
vertexBufferDesc.MiscFlags = 0;
vertexBufferDesc.StructureByteStride = Vertex.GetStride(0); // should be 0
// Give the subresource structure a pointer to the vertex data.
D3D11_SUBRESOURCE_DATA vertexData;
vertexData.pSysMem = Data.GetArray();
vertexData.SysMemPitch = 0;
vertexData.SysMemSlicePitch = 0;
// Set up the description of the static index buffer.
D3D11_BUFFER_DESC indexBufferDesc;
indexBufferDesc.Usage = D3D11_USAGE_DEFAULT;
indexBufferDesc.ByteWidth = Indexes.GetDataSize();
indexBufferDesc.BindFlags = D3D11_BIND_INDEX_BUFFER;
indexBufferDesc.CPUAccessFlags = 0;
indexBufferDesc.MiscFlags = 0;
indexBufferDesc.StructureByteStride = 0;
// Give the subresource structure a pointer to the index data.
D3D11_SUBRESOURCE_DATA indexData;
indexData.pSysMem = Indexes.GetArray();
indexData.SysMemPitch = 0;
indexData.SysMemSlicePitch = 0;
auto& Device = ContextDx.LockGetDevice();
try
{
auto Result = Device.CreateBuffer(&vertexBufferDesc, &vertexData, &mVertexBuffer.mObject );
Directx::IsOkay( Result, "Create vertex buffer");
Result = Device.CreateBuffer(&indexBufferDesc, &indexData, &mIndexBuffer.mObject );
Directx::IsOkay( Result, "Create index buffer");
mIndexCount = Indexes.GetSize();
mIndexFormat = DXGI_FORMAT_R32_UINT;
}
catch( std::exception& e)
{
ContextDx.Unlock();
throw;
}
}
示例3: Encode
bool TProtocolPokey::Encode(const TJob& Job,Array<char>& Output)
{
// job to command id
auto Command = TPokeyCommand::ToType( Job.mParams.mCommand );
unsigned char tempOut[64-8]; // gr: was 64, but their code NEVER uses more than 56 (64-8)
unsigned char data2,data3,data4,data5;
switch ( Command )
{
case TPokeyCommand::GetDeviceMeta:
case TPokeyCommand::GetDeviceState:
data2 = 0;
data3 = 0;
data4 = 0;
data5 = 0;
break;
// special case where we send zero bytes
case TPokeyCommand::Discover:
Output.PushBack(0xff);
//Soy::Assert( Output.GetDataSize() == 0, "should send zero bytes for discovery");
return true;
default:
return false;
};
auto RequestId = mRequestCounter++;
unsigned char Header[8];
Header[0] = 0xBB;
Header[1] = Command;
Header[2] = data2;
Header[3] = data3;
Header[4] = data4;
Header[5] = data5;
Header[6] = RequestId;
Header[7] = TPokeyCommand::CalculateChecksum(Header);
Output.PushBackArray( GetRemoteArray( reinterpret_cast<const char*>(Header), sizeofarray(Header) ) );
Output.PushBackArray( GetRemoteArray( reinterpret_cast<const char*>(tempOut), sizeofarray(tempOut) ) );
if ( !Soy::Assert( Output.GetDataSize()==64, "Always send 64 bytes" ) )
return false;
/*
// Wait for the response
while(1)
{
result = recv(comSocket, (char *)rxBuffer, 64, 0);
// 64 bytes received?
if (result == 64)
{
if (rxBuffer[0] == 0xAA && rxBuffer[6] == RequestID)
{
if (rxBuffer[7] == CalculateChecksum(rxBuffer))
{
memcpy(Response, rxBuffer, 64);
return 0;
}
}
}
else if (result == 0)
printf("Connection closed\n");
else
printf("recv failed: %d\n", WSAGetLastError());
if (++retries1 > 10) break;
}
if (retries2++ > 3) break;
}
return -1;
// Get serial number and versions
if (SendRequest(0x00, 0, 0, 0, 0, tempOut, tempIn) != 0) return -1;
deviceStat->DeviceData.SerialNumber = (int)(tempIn[2]) * 256 + (int)tempIn[3];
deviceStat->DeviceData.FirmwareVersionMajor = tempIn[4];
deviceStat->DeviceData.FirmwareVersionMinor = tempIn[5];
*/
return true;
}
示例4: DecodeHeader
TDecodeResult::Type TProtocolPokey::DecodeHeader(TJob& Job,TChannelStream& Stream)
{
// read the first byte, if it's 0xAA we know it's a reply packet
// if it's not, we have to assume it's a broadcast reply with an IP...
Array<char> Data;
auto DataBridge = GetArrayBridge(Data);
if ( !Stream.Pop( 1, DataBridge ) )
return TDecodeResult::Waiting;
if ( static_cast<unsigned char>(Data[0]) == 0xAA )
{
if ( !Stream.Pop( 64-1, DataBridge ) )
{
Stream.UnPop(DataBridge);
return TDecodeResult::Waiting;
}
BufferArray<unsigned char,64> UData;
GetArrayBridge(UData).PushBackReinterpret( Data.GetArray(), Data.GetDataSize() );
if ( !DecodeReply( Job, UData ) )
return TDecodeResult::Ignore;
return TDecodeResult::Success;
}
else
{
// old protocol size 14
// new protocol size 19
// assume is broadcast reply
if ( !Stream.Pop( 14-1, DataBridge ) )
{
Stream.UnPop(DataBridge);
return TDecodeResult::Waiting;
}
// gr: not sure why but have to use some data as signed and some as unsigned... not making sense to me, maybe encoding done wrong on pokey side
BufferArray<unsigned char, 100> UData;
GetArrayBridge(UData).PushBackReinterpret(Data.GetArray(), Data.GetDataSize());
std::stringstream Version;
Version << (int)UData[3] << "." << (int)UData[4];
// if new protocol
bool Protocol4913 = Version.str() == "49.13";
bool Protocol3352 = Version.str() == "33.52";
bool Protocol4800 = Version.str() == "48.0";
// same protocol as newer
Protocol4913 |= Protocol4800;
if ( Protocol4913 )
{
if ( !Stream.Pop(5, DataBridge) )
{
Stream.UnPop(DataBridge);
return TDecodeResult::Waiting;
}
UData.Clear();
GetArrayBridge(UData).PushBackReinterpret(Data.GetArray(), Data.GetDataSize());
}
else if ( Protocol3352 )
{
}
else
{
std::Debug << "unknown pokey protocol " << Version.str() << std::endl;
return TDecodeResult::Ignore;
}
int Serial = 0;
if ( Protocol4913 )
{
Serial = ( (int)UData[15] << 8 ) | (int)UData[14];
}
else if ( Protocol3352 )
{
Serial = ( (int)UData[1] << 8 ) | (int)UData[2];
}
std::stringstream Address;
Address << (int)UData[5] << "." << (int)UData[6] << "." << (int)UData[7] << "." << (int)UData[8];
Address << ":20055";
std::stringstream HostAddress;
HostAddress << (int)UData[10] << "." << (int)UData[11] << "." << (int)UData[12] << "." << (int)UData[13];
Job.mParams.mCommand = TJobParams::CommandReplyPrefix + TPokeyCommand::ToString( TPokeyCommand::Discover );
Job.mParams.AddParam("userid", static_cast<int>(UData[0]) );
Job.mParams.AddParam("version", Version.str() );
Job.mParams.AddParam("serial", Serial );
Job.mParams.AddParam("dhcpenabled", static_cast<int>(UData[9]) );
Job.mParams.AddParam("address", Address.str() );
Job.mParams.AddParam("hostaddress", HostAddress.str() );
return TDecodeResult::Success;
}
}