本文整理汇总了C++中Array::GetPtr方法的典型用法代码示例。如果您正苦于以下问题:C++ Array::GetPtr方法的具体用法?C++ Array::GetPtr怎么用?C++ Array::GetPtr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Array
的用法示例。
在下文中一共展示了Array::GetPtr方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ArrayBeyondTest
void ArrayBeyondTest()
{
Array<int, 5> a;
a[4] = 5;
cout << a[4] <<endl;
//无法检测内存越界
int* p1 = a.GetPtr();
p1[5] = 6;
cout << p1[5] <<endl;
//无法使用p[i]
Array<int, 5> *p2 = a.getptr();
Array<Array<int, 10>,5> b;
b[4][9] = 6;
cout << b[4][9] <<endl;
Array<TestStruct, 5> c;
TestStruct t = {0};
t.b[4] = 7;
c[4] = t;
cout << c[4].b[4] <<endl;
}
示例2: Flip
void GLGSRender::Flip()
{
if(m_read_buffer)
{
gcmBuffer* buffers = (gcmBuffer*)Memory.GetMemFromAddr(m_gcm_buffers_addr);
u32 width = re(buffers[m_gcm_current_buffer].width);
u32 height = re(buffers[m_gcm_current_buffer].height);
u32 addr = GetAddress(re(buffers[m_gcm_current_buffer].offset), CELL_GCM_LOCATION_LOCAL);
if(Memory.IsGoodAddr(addr))
{
//TODO
//buffer rotating
static Array<u8> pixels;
pixels.SetCount(width * height * 4);
u8* src = (u8*)Memory.VirtualToRealAddr(addr);
for(u32 y=0; y<height; ++y)
{
memcpy(pixels + (height - y - 1) * width * 4, src + y * width * 4, width * 4);
}
glDrawPixels(width, height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, pixels.GetPtr());
}
}
else if(m_fbo.IsCreated())
{
m_fbo.Bind(GL_READ_FRAMEBUFFER);
GLfbo::Bind(GL_DRAW_FRAMEBUFFER, 0);
GLfbo::Blit(
m_surface_clip_x, m_surface_clip_y, m_surface_clip_x + m_surface_clip_w, m_surface_clip_y + m_surface_clip_h,
m_surface_clip_x, m_surface_clip_y, m_surface_clip_x + m_surface_clip_w, m_surface_clip_y + m_surface_clip_h,
GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT, GL_NEAREST);
m_fbo.Bind();
}
for(uint i=0; i<m_post_draw_objs.GetCount(); ++i)
{
m_post_draw_objs[i].Draw();
}
m_frame->Flip();
if(m_fbo.IsCreated())
m_fbo.Bind();
}