本文整理汇总了C++中Print::printfAt方法的典型用法代码示例。如果您正苦于以下问题:C++ Print::printfAt方法的具体用法?C++ Print::printfAt怎么用?C++ Print::printfAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Print
的用法示例。
在下文中一共展示了Print::printfAt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: k
//.........这里部分代码省略.........
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
unsigned char* textureTmp = new unsigned char[waterfallSize * b.getWidth()];
glTexImage2D( GL_TEXTURE_2D_ARRAY, 0, GL_R8, b.getWidth(), waterfallSize, 0, GL_RED, GL_UNSIGNED_BYTE, textureTmp);
delete textureTmp;
float max = 0;
for (unsigned int i = 0; i < k.mB; ++i) {
drawArray[2 * i + 0] = (float)i / k.mB * 2.0f - 1.0f;
float tmp = std::abs(out[i]);
drawArray[2 * i + 1] = tmp;
max = std::max(tmp, max);
}
font = new Font(512, "res/font/DroidSans.woff", 32, tm);
print = new Print(font);
//print.set(&font, "res/shader/fontVertex.c", "res/shader/fontFragment.c");
print->setScreenSize(screen);
glm::vec2* vert = new glm::vec2[1024];
glm::vec2* debug = new glm::vec2[b.getWidth()];
for (unsigned int i = 0; i < b.getWidth(); ++i) {
debug[i].x = (float)i / b.getWidth() * 2.0f - 1.0f;
}
uint32_t vao;
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
uint32_t vbo[2];
glGenBuffers(1, vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo[0]);
glEnableVertexAttribArray(0);
glBufferData(GL_ARRAY_BUFFER, k.mB * sizeof(glm::vec2), drawArray, GL_DYNAMIC_DRAW);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, 0);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glEnable(GL_BLEND);
glfwSetWindowUserPointer(window, this);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
double time, timeo;
glfwSwapInterval(1);
PaStream* stream;
PaStreamParameters params;
params.device = 21;
params.channelCount = 1;
params.sampleFormat = paFloat32;
params.hostApiSpecificStreamInfo = nullptr;
params.suggestedLatency = 0.5;
err = Pa_OpenStream(&stream, ¶ms, nullptr, sampleRate, paFramesPerBufferUnspecified, 0, paCallback, this);
if (err != paNoError)
printf("error %i", err);
Pa_StartStream(stream);
while(!glfwWindowShouldClose(window))
{
timeo = time;
time = glfwGetTime();
CQT::transform(mAudioData, out, b, mAudioLength);
max = 0.0f;
for (unsigned int i = 0; i < k.mB; ++i) {
drawArray[2 * i + 0] = (float)i / k.mB * 2.0f - 1.0f;
float tmp = std::abs(out[i]);
drawArray[2 * i + 1] = tmp;
max = std::max(tmp, max);
}
for (unsigned int i = 0; i < k.mB; ++i) {
drawArray[2 * i + 1] = std::log(drawArray[2 * i +1]) * mScale + mOffset;
}
//printf("%f\n", drawArray[1]);
glBindVertexArray(vao);
glBindBuffer(GL_ARRAY_BUFFER, vbo[0]);
glBufferData(GL_ARRAY_BUFFER, k.mB * sizeof(glm::vec2), drawArray, GL_DYNAMIC_DRAW);
p->use();
glDrawArrays(GL_LINE_STRIP, 0, k.mB);
for (unsigned int i = 0; i < b.getWidth(); ++i) {
debug[i].y = mAudioData[i] / 15.0;
}
glBufferData(GL_ARRAY_BUFFER, b.getWidth() * sizeof(glm::vec2), debug, GL_DYNAMIC_DRAW);
glDrawArrays(GL_LINE_STRIP, 0, b.getWidth());
print->printfAt(-300.0f, 100.0f, 16.0f, 16.0f, u8"Fps:%03.3f", 1/(time-timeo));
glfwSwapBuffers(window);
glClear(GL_COLOR_BUFFER_BIT);
glfwPollEvents();
}
Pa_StopStream(stream);
Pa_CloseStream(stream);
Pa_Terminate();
std::cout << "Hello World. I'm Peach." << std::endl;
}
示例2: Main
Main()
{
isClicked = false;
screen = Vec2<unsigned int>(800, 600);
std::setlocale(LC_ALL, "en_US.UTF-8");
glfwInit();
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE);
GLFWwindow* window = glfwCreateWindow(screen.x, screen.y, "test", nullptr, nullptr);
if (window == nullptr)
{
printf("cant create window");
return;
}
glfwSetWindowSizeCallback(window, windowSizeCallback);
glfwSetKeyCallback(window, keyCallback);
glfwSetMouseButtonCallback(window, clickCallback);
glfwSetCursorPosCallback(window, mouseCallback);
glfwMakeContextCurrent(window);
glewExperimental = true;
glewInit();
//glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
glDebugMessageCallback(debugCallback, nullptr);
glEnable(GL_DEBUG_OUTPUT);
printf("%s\n", glGetString(GL_VERSION));
Shader* fs = new Shader("res/shader/fragment.c", true, GL_FRAGMENT_SHADER);
Shader* vs = new Shader("res/shader/vertex.c", true, GL_VERTEX_SHADER);
Program* p = new Program();
p->attach(fs);
p->attach(vs);
p->build();
p->use();
tm = new TextureManager();
font = new Font(512, "res/font/DroidSans.woff", 32, tm);
print = new Print(font);
//print.set(&font, "res/shader/fontVertex.c", "res/shader/fontFragment.c");
print->setScreenSize(screen);
glm::vec2* vert = new glm::vec2[1024];
uint32_t vao;
glGenVertexArrays(1, &vao);
glBindVertexArray(vao);
uint32_t vbo;
glGenBuffers(1, &vbo);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
glEnableVertexAttribArray(0);
glBufferData(GL_ARRAY_BUFFER, 1024 * sizeof(glm::vec2), vert, GL_DYNAMIC_DRAW);
glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, 0);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glEnable(GL_BLEND);
glfwSetWindowUserPointer(window, this);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
tr = new TileRenderer();
d = new Drawing(tr);
tr->setScreenSize(screen);
//glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
double time, timeo;
glfwSwapInterval(0);
while(!glfwWindowShouldClose(window))
{
timeo = time;
time = glfwGetTime();
glClear(GL_COLOR_BUFFER_BIT);
glBindVertexArray(vao);
glBindBuffer(GL_ARRAY_BUFFER, vbo);
d->render();
//tr->renderTile(t);
print->printfAt(-0.3f, 0.7f, 16.0f, 16.0f, u8"Fps:%03.3f", 1/(time-timeo));
glfwSwapBuffers(window);
glfwWaitEvents();
}
std::cout << "Hello World. I'm Peach." << std::endl;
}