本文整理汇总了C++中Array::GetArray方法的典型用法代码示例。如果您正苦于以下问题:C++ Array::GetArray方法的具体用法?C++ Array::GetArray怎么用?C++ Array::GetArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Array
的用法示例。
在下文中一共展示了Array::GetArray方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: Write
void FileStream::Write(Array<byte> data, int offset, int count) {
int dbg = fwrite(data.GetArray()+(size_t)offset,(size_t)1,(size_t)count,fpointer);
ipos +=count;
if(ipos>flen) {
flen = ipos;
}
}
示例3:
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;
}
}
示例4: Read
int FileStream::Read(Array<byte> data, int offset, int count) {
size_t available;
if(flen-ipos<count) {
available = flen-ipos;
} else {
available = count;
}
int retval = (int)fread(data.GetArray()+(size_t)offset,(size_t)1,available,fpointer);
ipos = ftell(fpointer);
return retval;
}
示例5: sizeof
void Directx::TShader::MakeLayout(const SoyGraphics::TGeometryVertex& Vertex,ArrayBridge<uint8>&& CompiledShader,const std::string& ShaderName,ID3D11Device& Device)
{
Array<D3D11_INPUT_ELEMENT_DESC> Layouts;
for ( int e=0; e<Vertex.mElements.GetSize(); e++ )
{
auto& Element = Vertex.mElements[e];
auto& Layout = Layouts.PushBack();
memset( &Layout, 0, sizeof(Layout) );
Layout.SemanticName = Element.mName.c_str();
Layout.Format = GetType( Element.mType, Element.mArraySize );
Layout.SemanticIndex = Element.mIndex;
Layout.InputSlot = 0;
Layout.AlignedByteOffset = 0; // D3D11_APPEND_ALIGNED_ELEMENT
Layout.InputSlotClass = D3D11_INPUT_PER_VERTEX_DATA;
Layout.InstanceDataStepRate = 0;
}
auto Result = Device.CreateInputLayout( Layouts.GetArray(), Layouts.GetSize(), CompiledShader.GetArray(), CompiledShader.GetDataSize(), &mLayout.mObject );
std::stringstream Error;
Error << "CreateInputLayout(" << ShaderName << ")";
Directx::IsOkay( Result, Error.str() );
}
示例6: 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;
}
}