本文整理汇总了C++中GLVertexBuffer::AddStatic方法的典型用法代码示例。如果您正苦于以下问题:C++ GLVertexBuffer::AddStatic方法的具体用法?C++ GLVertexBuffer::AddStatic怎么用?C++ GLVertexBuffer::AddStatic使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GLVertexBuffer
的用法示例。
在下文中一共展示了GLVertexBuffer::AddStatic方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: window
/*
GL interop test.
Julia.
*/
TEST(GLInteropTest, Julia)
{
try
{
const int width = 1280;
const int height = 720;
const int bufWidth = 1920;
const int bufHeight = 1080;
// ------------------------------------------------------------
GLTestWindow window(width, height, true);
GLContextParam param;
param.DebugMode = true;
param.Multisample = 8;
GLContext context(window.Handle(), param);
GLUtil::EnableDebugOutput(GLUtil::DebugOutputFrequencyLow);
// ------------------------------------------------------------
// Choose device
cudaDeviceProp prop;
memset(&prop, 0, sizeof(cudaDeviceProp));
prop.major = 2;
prop.minor = 0;
int devID;
HandleCudaError(cudaChooseDevice(&devID, &prop));
HandleCudaError(cudaGLSetGLDevice(devID));
// Get properties
HandleCudaError(cudaGetDeviceProperties(&prop, devID));
// Create texture and PBO
GLTexture2D texture;
texture.SetMagFilter(GL_LINEAR);
texture.SetMinFilter(GL_LINEAR);
texture.SetWrap(GL_CLAMP_TO_EDGE);
texture.Allocate(bufWidth, bufHeight, GL_RGBA8);
GLPixelUnpackBuffer pbo;
pbo.Allocate(bufWidth * bufHeight * 4, NULL, GL_DYNAMIC_DRAW);
// Register
cudaGraphicsResource* cudaPbo;
HandleCudaError(cudaGraphicsGLRegisterBuffer(&cudaPbo, pbo.ID(), cudaGraphicsMapFlagsWriteDiscard));
// ------------------------------------------------------------
GLShader shader;
shader.Compile("../resources/texturetest_simple2d.vert");
shader.Compile("../resources/texturetest_simple2d.frag");
shader.Link();
GLVertexArray vao;
GLVertexBuffer positionVbo;
GLIndexBuffer ibo;
glm::vec3 v[] =
{
glm::vec3( 1.0f, 1.0f, 0.0f),
glm::vec3(-1.0f, 1.0f, 0.0f),
glm::vec3(-1.0f, -1.0f, 0.0f),
glm::vec3( 1.0f, -1.0f, 0.0f)
};
GLuint i[] =
{
0, 1, 2,
2, 3, 0
};
positionVbo.AddStatic(12, &v[0].x);
vao.Add(GLDefaultVertexAttribute::Position, &positionVbo);
ibo.AddStatic(6, i);
// ------------------------------------------------------------
double fps = 0.0;
double timeSum = 0.0;
double prevTime = GLTestUtil::CurrentTimeMilli();
int frameCount = 0;
double start = GLTestUtil::CurrentTimeMilli();
float xcparam = -0.8f;
float ycparam = 0.165f;
float inc = 0.001f;
while (window.ProcessEvent())
{
// ------------------------------------------------------------
double currentTime = GLTestUtil::CurrentTimeMilli();
double elapsedTime = currentTime - prevTime;
//.........这里部分代码省略.........