本文整理汇总了C++中render函数的典型用法代码示例。如果您正苦于以下问题:C++ render函数的具体用法?C++ render怎么用?C++ render使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了render函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
cudaGraphicsResource *resource;
//Create a texture to store ray tracing result
GLuint tex;
glActiveTexture(GL_TEXTURE0);
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D, tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, width, height, 0, GL_RGBA, GL_FLOAT, NULL);
cudaCheck(cudaGraphicsGLRegisterImage(&resource, tex, GL_TEXTURE_2D, cudaGraphicsMapFlagsWriteDiscard));
glBindTexture(GL_TEXTURE_2D, 0);
Shader final = Shader("fsQuad.vert", "fsQuad.frag");
FullscreenQuad fsQuad = FullscreenQuad();
float4* buffer;
cudaCheck(cudaMalloc((void**)&buffer, width * height * sizeof(float4)));
cudaCheck(cudaMemset(buffer, 0, width * height * sizeof(float4)));
//Mesh
float3 offset = make_float3(0);
float3 scale = make_float3(15);
Mesh cBox("objs/Avent", 0, scale, offset);
offset = make_float3(0, 55, 0);
scale = make_float3(100);
Mesh light("objs/plane", (int)cBox.triangles.size(), scale, offset);
cBox.triangles.insert(cBox.triangles.end(), light.triangles.begin(), light.triangles.end());
cBox.aabbs.insert(cBox.aabbs.end(), light.aabbs.begin(), light.aabbs.end());
std::cout << "Num triangles: " << cBox.triangles.size() << std::endl;
cBox.root = AABB(fminf(cBox.root.minBounds, light.root.minBounds), fmaxf(cBox.root.maxBounds, light.root.maxBounds));
BVH bvh(cBox.aabbs, cBox.triangles, cBox.root);
Camera cam(make_float3(14, 15, 80), make_int2(width, height), 45.0f, 0.04f, 80.0f);
Camera* dCam;
cudaCheck(cudaMalloc((void**)&dCam, sizeof(Camera)));
cudaCheck(cudaMemcpy(dCam, &cam, sizeof(Camera), cudaMemcpyHostToDevice));
cudaCheck(cudaGraphicsMapResources(1, &resource, 0));
cudaArray* pixels;
cudaCheck(cudaGraphicsSubResourceGetMappedArray(&pixels, resource, 0, 0));
cudaResourceDesc viewCudaArrayResourceDesc;
viewCudaArrayResourceDesc.resType = cudaResourceTypeArray;
viewCudaArrayResourceDesc.res.array.array = pixels;
cudaSurfaceObject_t viewCudaSurfaceObject;
cudaCheck(cudaCreateSurfaceObject(&viewCudaSurfaceObject, &viewCudaArrayResourceDesc));
cudaCheck(cudaGraphicsUnmapResources(1, &resource, 0));
while (!glfwWindowShouldClose(window)) {
float currentFrame = float(glfwGetTime());
deltaTime = currentFrame - lastFrame;
lastFrame = currentFrame;
//Check and call events
glfwPollEvents();
handleInput(window, cam);
if (cam.moved) {
frameNumber = 0;
cudaCheck(cudaMemset(buffer, 0, width * height * sizeof(float4)));
}
cam.rebuildCamera();
cudaCheck(cudaMemcpy(dCam, &cam, sizeof(Camera), cudaMemcpyHostToDevice));
frameNumber++;
if (frameNumber < 20000) {
cudaCheck(cudaGraphicsMapResources(1, &resource, 0));
std::chrono::time_point<std::chrono::system_clock> start, end;
start = std::chrono::system_clock::now();
render(cam, dCam, viewCudaSurfaceObject, buffer, bvh.dTriangles, bvh.dNodes, frameNumber, cam.moved);
end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed = end - start;
std::cout << "Frame: " << frameNumber << " --- Elapsed time: " << elapsed.count() << "s\n";
cudaCheck(cudaGraphicsUnmapResources(1, &resource, 0));
}
cam.moved = false;
glUseProgram(final.program);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, tex);
glClear(GL_COLOR_BUFFER_BIT);
final.setUniformi("tRender", 0);
fsQuad.render();
//std::cout << glGetError() << std::endl;
//Swap the buffers
glfwSwapBuffers(window);
glfwSetCursorPos(window, lastX, lastY);
}
示例2: DoTunnel
void DoTunnel(float limit)
{
params.on_speed = 2.0/100.0;
params.start_dwell = 2;
params.curve_dwell = 0;
params.corner_dwell = 2;
params.curve_angle = cosf(30.0*(M_PI/180.0)); // 30 deg
params.end_dwell = 2;
params.snap = 1/100000.0;
params.flatness = 0.000005;
params.start_wait = 6;
params.off_speed = 2.0/30.0;
params.end_wait = 3;
params.render_flags &= ~RENDER_NOREORDER;
olSetRenderParams(¶ms);
float ctime = 0;
int i,j;
olLoadIdentity();
float z = 0.0f;
float rz = 0.0f;
float dz=1.2;
int id=0;
while (audiotime < limit) {
float left = (limit-audiotime)/AB;
olResetColor();
if (ctime < 2.0)
olMultColor(C_GREY((int)(255*ctime/2)));
else if (left < 2.0)
olMultColor(C_GREY((int)(255*left/2)));
olLoadIdentity3();
olPerspective(45, 1, 1, 100);
while(z > dz) {
z -= dz;
id++;
}
olScale3(0.6, 0.6, 1.0);
olTranslate3(0, 0, 1.5);
olTranslate3(0, 0, -z);
tunnel_revxform(rz);
for(i=0;i<10;i++) {
if ((id+i) > 5) {
olPushMatrix3();
olTranslate3(0,0,dz*i);
tunnel_xform(rz+dz*(i+id));
olBegin(OL_LINESTRIP);
for(j=0;j<11;j++) {
float theta = j/5.0*M_PI;
uint32_t c = C_RED;
if(i==9) {
c = C_RED_I((int)(255 * z/dz));
}
olVertex3(sinf(theta), cosf(theta), 0, c);
//olVertex3(j/11.0,0,0,C_WHITE);
}
olEnd();
olPopMatrix3();
}
}
for(j=0;j<10;j++) {
float theta = j/5.0*M_PI;
olBegin(OL_LINESTRIP);
for(i=0;i<9;i++) {
if ((id+i) > 5) {
olPushMatrix3();
olTranslate3(0,0,dz*i);
tunnel_xform(rz+dz*(i+id));
olVertex3(sinf(theta), cosf(theta), 0,
C_GREEN_I((int)(255 * i/8.0)) | C_BLUE_I((int)(255 * (1-(i/8.0)))));
olPopMatrix3();
}
}
olEnd();
}
ctime += render();
z += ftime*3.2;
rz += ftime*3.2;
}
}
示例3: getCanvas
void StereoPainter::paint() {
int width = getCanvas()->getSize().x;
int height = getCanvas()->getSize().y;
// Special handling for side-by-side stereo
if (stereoMode_ == SIDE_BY_SIDE) {
getCamera()->setRatio(float(width / 2) / height);
}
// Add headtracking offset
if (trackingEnabled_ && headTracker_) {
headTracker_->adaptCameraToHead();
}
switch (stereoMode_) {
default:
// Falls through..
case MONOSCOPIC:
{
glDrawBuffer(GL_BACK);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Render middle view
// NOTE: Special headtracking frustums might require the stereo handling process
// of the camera look() method so we set the eye separation to 0 and render
// the left eye view instead of just:
// getCamera()->look(Camera::EYE_MIDDLE);
float initialEyeSep = getCamera()->getEyeSeparation();
getCamera()->setEyeSeparation(0);
getCamera()->look(Camera::EYE_LEFT);
getCamera()->setEyeSeparation(initialEyeSep);
render();
}
break;
case FRAME_SEQUENTIAL:
glDrawBuffer(GL_BACK);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Render left eye view
getCamera()->look(Camera::EYE_LEFT);
render();
getCanvas()->swap();
// Render right eye view
getCamera()->look(Camera::EYE_RIGHT);
render();
// For continuous rendering refresh canvas
getCanvas()->update();
break;
case SIDE_BY_SIDE:
glDrawBuffer(GL_BACK);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Render left eye view
glViewport(0, 0, width / 2, height);
getCamera()->look(Camera::EYE_LEFT);
render();
// Render right eye view
glViewport(width / 2, 0, width / 2, height);
getCamera()->look(Camera::EYE_RIGHT);
render();
glViewport(0, 0, width, height);
break;
case ANAGLYPH:
glDrawBuffer(GL_BACK);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Render left eye view
glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_TRUE);
getCamera()->look(Camera::EYE_LEFT);
render();
glClear(GL_DEPTH_BUFFER_BIT);
// Render right eye view
glColorMask(GL_FALSE, GL_FALSE, GL_TRUE, GL_TRUE);
getCamera()->look(Camera::EYE_RIGHT);
render();
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
break;
case QUADRO_PAGE_FLIPPING:
// Render left eye view
glDrawBuffer(GL_BACK_LEFT);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
getCamera()->look(Camera::EYE_LEFT);
render();
//.........这里部分代码省略.........
示例4: blitPrototileMap
void SDLGod::renderTileMap(Arraytrix<prototile>* p_tiles)
{
blitPrototileMap(p_tiles);
render();
}
示例5: DoTitle
void DoTitle(float limit)
{
IldaFile *ild;
ild = olLoadIlda("lase_title.ild");
include_dark_points = 1;
int count = count_active_points(ild);
float cur_draw = 0;
float ctime = 0;
olSetVertexShader(cutoff);
params.render_flags |= RENDER_NOREORDER;
olSetRenderParams(¶ms);
while(1) {
int obj;
float w;
points_left = cur_draw;
olDrawIlda(ild);
ctime += render();
cur_draw += ftime * count / 3.0;
if (cur_draw > count) {
break;
}
}
olSetVertexShader(NULL);
while(AB*ctime < 8) {
olDrawIlda(ild);
ctime += render();
}
wipe_center = -1.0;
wipe_w = 0.4;
wipe_inv = 1;
const char *s="A realtime laser demo";
float s_x = -olGetStringWidth(font, 0.2, s) / 2;
float s_y = -0.5;
float s_h = 0.2;
while(1) {
olDrawIlda(ild);
olSetPixelShader(hwipe);
olDrawString(font, s_x, s_y, s_h, C_WHITE, s);
olSetPixelShader(NULL);
ctime += render();
wipe_center += 1.7*ftime;
if(wipe_center > 1.0f)
break;
}
float bright = 300.0f;
while(audiotime < limit) {
uint32_t col;
if (bright > 255.0f)
col = C_WHITE;
else
col = C_GREY((int)bright);
olPushColor();
olMultColor(col);
olDrawIlda(ild);
olDrawString(font, s_x, s_y, s_h, C_WHITE, s);
olPopColor();
render();
bright -= ftime * 130.0;
if (bright < 0)
bright = 0;
}
}
示例6: carSimulation
//.........这里部分代码省略.........
if ( currentTime - frameLastTime >= 1.0 ) {
// printf and reset timer
printf("%f ms/frame\n", 1000.0/double(nbFrames));
nbFrames = 0;
frameLastTime += 1.0;
}
double now = glfwGetTime();
double deltaTime = now - oldTime;
oldTime = now;
//test position
/* glm::vec3 distance = myCar.getCenter() - path.at(nextPoint); */
/* printf("Next: %i (%f)\n", nextPoint, glm::dot(distance, distance)); */
/* if(glm::dot(distance, distance) < distances.at(nextPoint)*distances.at(nextPoint)) { */
/* nextPoint++; */
/* if (nextPoint > path.size() - 1) { */
/* nextPoint = 0; */
/* } */
/* } */
/* std::vector<Car*> carList = Car::getCarList(); */
glClear( GL_COLOR_BUFFER_BIT );
//start drawing
for(std::vector<Car*>::iterator it = cars.begin(); it != cars.end();) {
int increment = 1;
(*it)->update(deltaTime,*walls);
double input[LINE_COUNT + 1]; //For biasing
input[0] = 1.0;
glm::mat4 carMatrix = Projection * Car::getCamera() * (*it)->getMatrix();
render(programID, MatrixID, ColorID, carbuffer, carVAO, carMatrix, CAR_COLOR);
std::vector<DetectLine> lines = (*it)->getLineList();
int i = 0;
for (std::vector<DetectLine>::iterator lIt = lines.begin(); lIt != lines.end(); lIt++) {
renderLine(programID, MatrixID, ColorID, linebuffer, lineVAO, Projection * Car::getCamera() * lIt->getMatrix(), LINE_COLOR);
double closest = -1;
for (std::vector<Wall>::iterator wIt = walls->begin(); wIt != walls->end(); wIt++) {
glm::mat4 wallMatrix = wIt->getMatrix();
glm::vec3 wallB = glm::vec3(wallMatrix * glm::vec4(1.0,0.0,0.0,1.0));
glm::vec3 wallA = glm::vec3(wallMatrix * glm::vec4(-1.0,0.0,0.0,1.0));
//printf("A:%s, B:%s\n", glm::to_string(wallA).c_str(), glm::to_string(wallB).c_str());
double out = 0;
if (collisionLineLine(lIt->getCenter(), lIt->getEnd(), wallA , wallB, &out) == true) {
if (closest == -1 || out < closest) {
closest = out;
}
}
}
input[i+1] = closest;
i++;
/* printf("Closest:%f\n",closest); */
lIt->setDistance(closest);
}
NEAT::Organism* org = (*it)->getOrganism();
if (org) {
NEAT::Network* net = org->net;
net->load_sensors(input);
if (!(net->activate())) return;
示例7: main
//.........这里部分代码省略.........
config->setInt32("DS.team", teamNum);
config->initInt32("DS.alliance", Alliance::RED);
config->initInt32("DS.position", 1);
DS::initialize(teamNum);
auto ds = DS::getInstance();
enum GUIMode { MAIN, INFO, JOYSTICKS, CONTROL, HELP, COUNT };
GUIMode mode = GUIMode::MAIN;
auto runner = std::async(std::launch::async, &DS::run, ds);
std::map<GUIMode, Screen*> screens;
screens[MAIN] = new ScreenMain();
screens[INFO] = new ScreenInfo();
screens[JOYSTICKS] = new ScreenJoysticks();
screens[CONTROL] = new ScreenControl();
screens[HELP] = new ScreenHelp();
while (!quit) {
while (gui->pollEvent(&e) != 0) {
if (e.type == SDL_QUIT) {
quit = true;
} else if (e.type == SDL_JOYDEVICEREMOVED || e.type == SDL_JOYDEVICEADDED) {
ds->setEnable(false);
ds->loadJoysticks();
} else if (e.type == SDL_KEYDOWN && e.key.repeat == 0) {
auto key = e.key.keysym;
if (key.sym == SDLK_e) {
ds->toggleEnable();
} else if (key.sym == SDLK_SPACE) {
ds->setEnable(false);
} else if (key.sym == SDLK_0) {
ds->setEStop();
} else if (key.sym == SDLK_q) {
quit = true;
} else if (key.sym == SDLK_r) {
if (key.mod & KMOD_SHIFT) {
ds->reboot();
} else {
ds->restartCode();
}
} else if (key.sym == SDLK_BACKQUOTE) {
ds->setAlliance(ds->getAlliance() == Alliance::BLUE ? Alliance::RED : Alliance::BLUE);
} else if (key.sym >= SDLK_1 && key.sym <= SDLK_9) {
uint8_t keyNum = (uint8_t)(1 + key.sym - SDLK_1);
if (key.mod & KMOD_CTRL && keyNum >= 1 && keyNum <= 3) {
ds->setPosition(keyNum);
} else if (key.mod & KMOD_SHIFT && keyNum >= 1 && keyNum <= 3) {
ds->setEnable(false);
ds->setMode((Mode)(keyNum - 1));
} else if (keyNum >= 1 && keyNum <= GUIMode::COUNT) {
mode = (GUIMode)(keyNum - 1);
}
}
}
screens[mode]->update(e);
}
if (gui->readyToDraw()) {
gui->setOffset(10, 10);
gui->clear();
gui->drawScreen(screens[mode]);
gui->setOffset(10, gui->getHeight() - gui->getCharSize().y);
gui->drawText(0, 0, "1: Main", mode == GUIMode::MAIN ? Colors::BLACK : Colors::DISABLED);
gui->drawTextRel(9, 0, "2: Info", mode == GUIMode::INFO ? Colors::BLACK : Colors::DISABLED);
gui->drawTextRel(9, 0, "3: Joysticks", mode == GUIMode::JOYSTICKS ? Colors::BLACK : Colors::DISABLED);
gui->drawTextRel(14, 0, "4: Control", mode == GUIMode::CONTROL ? Colors::BLACK : Colors::DISABLED);
gui->drawTextRel(12, 0, "5: Help", mode == GUIMode::HELP ? Colors::BLACK : Colors::DISABLED);
gui->render();
}
std::string s = narf::util::format("Team %d", teamNum);
if (ds->isConnected()) {
auto rio = ds->getRoboRIO();
s += " - ";
if (rio->getEStop()) {
s += "E-Stopped";
} else {
s += narf::util::format("%s %s", modeNames[rio->getMode()].c_str(), rio->getEnable() ? "Enabled" : "Disabled");
}
s += narf::util::format(" - %s %d", allianceNames[ds->getAlliance()].c_str(), ds->getPosition());
if (!rio->getCode()) {
s += " - No Code";
}
} else {
s += " - No Comms";
}
gui->setTitle(s);
ds->updateJoysticks();
SDL_Delay(25);
}
ds->saveJoysticks();
ds->stop();
SDL_Quit();
return 0;
}
示例8: main
/**
* Starting point for the program.
*
* @param argc The number of command line arguments.
* @param argv The array of command line arguments.
* @return Program exit status.
*/
int main(int argc, char **argv) {
SDL_Window *win = NULL;
SDL_Renderer *rend = NULL;
SDL_Texture *tex_player = NULL;
if(init(&win, &rend, &tex_player)) {
return 1;
}
Game_Data game_data;
game_data.battle_data.state = GAME_BATTLE_MOVE;
game_data.battle_data.num_units = 2;
game_data.battle_data.board.tiles
= malloc(GRID_COLS * GRID_ROWS * sizeof *game_data.battle_data.board.tiles);
game_data.battle_data.turn_order =
malloc(game_data.battle_data.num_units
* sizeof *game_data.battle_data.turn_order);
game_data.battle_data.camera_pos = (Coord_f){0.0, 0.0};
game_data.battle_data.camera_vel = (Coord_f){0.0, 0.0};
game_data.battle_data.board.cols = GRID_COLS;
game_data.battle_data.board.rows = GRID_ROWS;
game_data.battle_data.turn = 0;
for(int i = 0; i < GRID_COLS; i++)
for(int j = 0; j < GRID_ROWS; j++) {
game_data.battle_data.board.tiles[j * GRID_COLS + i].ent = NULL;
}
SDL_Event event;
Battle_Entity *temp;
temp = game_data.battle_data.board.tiles[10 * GRID_ROWS + 5].ent
= malloc(sizeof(Battle_Entity));
temp->img.tex = tex_player;
temp->img.dest_x = 5.0 * WIN_WIDTH / GRID_ROWS;
temp->img.dest_y = 10.0 * WIN_HEIGHT / GRID_COLS;
temp->img.dest_w = WIN_WIDTH / GRID_ROWS;
temp->img.dest_h = WIN_HEIGHT / GRID_COLS;
temp->img.src_x = 0.0;
temp->img.src_y = 0.0;
temp->img.src_w = 0.0;
temp->img.src_h = 0.0;
temp->team = TEAM_SELECTED;
temp->pos = (Coord_f){10.0, 5.0};
temp->vel = (Coord_f){0.0, 0.0};
temp->move_queue.key_size = 0;
temp->move_queue.head = NULL;
game_data.battle_data.turn_order[0] = temp;
temp = game_data.battle_data.board.tiles[19 * GRID_ROWS + 19].ent
= malloc(sizeof(Battle_Entity));
temp->img.tex = tex_player;
temp->img.dest_x = 19.0 * WIN_WIDTH / GRID_ROWS;
temp->img.dest_y = 19.0 * WIN_HEIGHT / GRID_COLS;
temp->img.dest_w = WIN_WIDTH / GRID_ROWS;
temp->img.dest_h = WIN_HEIGHT / GRID_COLS;
temp->img.src_x = 0.0;
temp->img.src_y = 0.0;
temp->img.src_w = 0.0;
temp->img.src_h = 0.0;
temp->team = TEAM_SELECTED;
temp->pos = (Coord_f){19.0, 19.0};
temp->vel = (Coord_f){0.0, 0.0};
temp->move_queue.key_size = 0;
temp->move_queue.head = NULL;
game_data.battle_data.turn_order[1] = temp;
game_data.battle_data.keys = 0;
double time = SDL_GetTicks();
while(game_data.battle_data.state != GAME_STOPPED) {
SDL_RenderClear(rend);
while(SDL_PollEvent(&event)) {
handle_event(&event, &game_data);
}
update_world(&game_data, SDL_GetTicks() - time);
time = SDL_GetTicks();
render(rend, &game_data);
SDL_RenderPresent(rend);
}
free(game_data.battle_data.board.tiles[10 * GRID_ROWS + 5].ent);
free(game_data.battle_data.board.tiles[19 * GRID_ROWS + 19].ent);
SDL_DestroyTexture(tex_player);
SDL_DestroyRenderer(rend);
//.........这里部分代码省略.........
示例9: clear
void OpenGL::refresh() {
clear();
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texture);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_BGRA, inputFormat, buffer);
struct History {
GLuint texture;
unsigned width, height;
GLuint filter, wrap;
};
vector<History> history;
unsigned sourceWidth = width, sourceHeight = height;
history.prepend({texture, sourceWidth, sourceHeight, filter, wrap});
for(auto& p : programs) {
unsigned targetWidth = p.absoluteWidth ? p.absoluteWidth : outputWidth;
unsigned targetHeight = p.absoluteHeight ? p.absoluteHeight : outputHeight;
if(p.relativeWidth) targetWidth = sourceWidth * p.relativeWidth;
if(p.relativeHeight) targetHeight = sourceHeight * p.relativeHeight;
p.size(targetWidth, targetHeight);
glUseProgram(p.program);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, p.framebuffer);
glrUniform1i("phase", p.phase);
glrUniform1i("sourceLength", history.size());
glrUniform1i("pixmapLength", p.pixmaps.size());
glrUniform4f("targetSize", targetWidth, targetHeight, 1.0 / targetWidth, 1.0 / targetHeight);
glrUniform4f("outputSize", outputWidth, outputHeight, 1.0 / outputWidth, 1.0 / outputHeight);
//glrUniform4f("targetActualSize", glrSize(targetWidth), glrSize(targetHeight), 1.0 / glrSize(targetWidth), 1.0 / glrSize(targetHeight));
//glrUniform4f("outputActualSize", glrSize(outputWidth), glrSize(outputHeight), 1.0 / glrSize(outputWidth), 1.0 / glrSize(outputHeight));
unsigned aid = 0;
for(auto& pixmap : history) {
glrUniform1i({"source[", aid, "]"}, aid);
glrUniform4f({"sourceSize[", aid, "]"}, pixmap.width, pixmap.height, 1.0 / pixmap.width, 1.0 / pixmap.height);
//glrUniform4f({"sourceActualSize[", aid, "]"}, glrSize(pixmap.width), glrSize(pixmap.height), 1.0 / glrSize(pixmap.width), 1.0 / glrSize(pixmap.height));
glActiveTexture(GL_TEXTURE0 + (aid++));
glBindTexture(GL_TEXTURE_2D, pixmap.texture);
glrParameters(pixmap.filter, pixmap.wrap);
}
unsigned bid = 0;
for(auto& pixmap : p.pixmaps) {
glrUniform1i({"pixmap[", bid, "]"}, aid + bid);
glrUniform4f({"pixmapSize[", bid, "]"}, pixmap.width, pixmap.height, 1.0 / pixmap.width, 1.0 / pixmap.height);
//glrUniform4f({"pixmapActualSize[", bid, "]"}, glrSize(pixmap.width), glrSize(pixmap.height), 1.0 / glrSize(pixmap.width), 1.0 / glrSize(pixmap.height));
glActiveTexture(GL_TEXTURE0 + aid + (bid++));
glBindTexture(GL_TEXTURE_2D, pixmap.texture);
glrParameters(pixmap.filter, pixmap.wrap);
}
glActiveTexture(GL_TEXTURE0);
glrParameters(p.filter, p.wrap);
p.render(sourceWidth, sourceHeight, targetWidth, targetHeight);
glBindTexture(GL_TEXTURE_2D, p.texture);
p.phase = (p.phase + 1) % p.modulo;
sourceWidth = p.width, sourceHeight = p.height;
history.prepend({p.texture, sourceWidth, sourceHeight, p.filter, p.wrap});
}
unsigned targetWidth = absoluteWidth ? absoluteWidth : outputWidth;
unsigned targetHeight = absoluteHeight ? absoluteHeight : outputHeight;
if(relativeWidth) targetWidth = sourceWidth * relativeWidth;
if(relativeHeight) targetHeight = sourceHeight * relativeHeight;
glUseProgram(program);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
glrUniform1i("source[0]", 0);
glrUniform4f("targetSize", targetWidth, targetHeight, 1.0 / targetWidth, 1.0 / targetHeight);
glrUniform4f("outputSize", outputWidth, outputHeight, 1.0 / outputWidth, 1.0 / outputHeight);
glrParameters(filter, wrap);
render(sourceWidth, sourceHeight, outputWidth, outputHeight);
}
示例10: setMatrix
void setMatrix(MATPTR matrix)
{
render(&rendered, matrix);
}
示例11: render
void RenderablePicoSurface::render (Renderer& renderer, const Matrix4& localToWorld) const
{
render(renderer, localToWorld, _shader);
}
示例12: getOutputSoundfileName
int MusicModel::processArgs(const std::vector<std::string> &args)
{
System::inform("BEGAN MusicModel::processArgv()...\n");
std::map<std::string, std::string> argsmap;
std::string key;
for (size_t i = 0, n = args.size(); i < n; ++i) {
const std::string token = args[i];
std::string value = "";
if (token.find("--") == 0) {
key = token;
System::inform("argument[%2d]: %s\n", i, key.c_str());
} else {
value = token;
System::inform("argument[%2d]: %s = %s\n", i, key.c_str(), value.c_str());
}
argsmap[key] = value;
}
char command[0x200];
int errorStatus = 0;
bool postPossible = false;
std::string playSoundfileName = getOutputSoundfileName();
if ((argsmap.find("--dir") != argsmap.end()) && !errorStatus) {
setOutputDirectory(argsmap["--dir"]);
}
if ((argsmap.find("--midi") != argsmap.end()) && !errorStatus) {
errorStatus = generate();
if (errorStatus) {
return errorStatus;
}
getScore().save(getMidiFilename().c_str());
}
if ((argsmap.find("--notation") != argsmap.end()) && !errorStatus) {
translateToNotation();
}
if ((argsmap.find("--audio") != argsmap.end()) && !errorStatus) {
postPossible = false;
const char *audiosystem = argsmap["--audio"].c_str();
const char *devicename = argsmap["--device"].c_str();
std::sprintf(command,
"csound --midi-key=4 --midi-velocity=5 -m195 -+rtaudio=%s -o %s",
audiosystem, devicename);
System::inform("Csound command: %s\n", command);
setCsoundCommand(command);
errorStatus = render();
}
if ((argsmap.find("--csound") != argsmap.end()) && !errorStatus) {
postPossible = true;
errorStatus = render();
}
if ((argsmap.find("--pianoteq") != argsmap.end()) && !errorStatus) {
std::sprintf(command, "Pianoteq --midi=%s\n", getMidiFilename().c_str());
System::inform("Executing command: %s\n", command);
errorStatus = std::system(command);
}
if ((argsmap.find("--pianoteq-wav") != argsmap.end()) && !errorStatus) {
postPossible = true;
std::sprintf(command, "Pianoteq --headless --midi %s --rate 48000 --wav %s\n", getMidiFilename().c_str(), getOutputSoundfileName().c_str());
System::inform("Executing command: %s\n", command);
errorStatus = std::system(command);
}
if ((argsmap.find("--playmidi") != argsmap.end()) && !errorStatus) {
std::sprintf(command, "%s %s\n", argsmap["--playmidi"].c_str(), getMidiFilename().c_str());
System::inform("Executing command: %s\n", command);
errorStatus = std::system(command);
}
if ((argsmap.find("--post") != argsmap.end()) && !errorStatus && postPossible) {
errorStatus = translateMaster();
playSoundfileName = getNormalizedSoundfileName();
}
if ((argsmap.find("--playwav") != argsmap.end()) && !errorStatus) {
std::sprintf(command, "%s %s\n", argsmap["--playwav"].c_str(), playSoundfileName.c_str());
System::inform("Csound command: %s\n", command);
errorStatus = std::system(command);
}
System::inform("ENDED MusicModel::processArgv().\n");
return errorStatus;
}
示例13: _entryPoint
void _entryPoint()
{
struct Services services;
/****************************> Get Handles <****************************/
//Get a handle to coreinit.rpl
OSDynLoad_Acquire("coreinit.rpl", &services.coreinit_handle);
//Get a handle to vpad.rpl */
unsigned int vpad_handle;
OSDynLoad_Acquire("vpad.rpl", &vpad_handle);
/****************************> External Prototypes <****************************/
//VPAD functions
int(*VPADRead)(int controller, VPADData *buffer, unsigned int num, int *error);
//OS functions
void(*_Exit)();
/****************************> Exports <****************************/
//VPAD functions
OSDynLoad_FindExport(vpad_handle, 0, "VPADRead", &VPADRead);
// Draw functions
OSDynLoad_FindExport(services.coreinit_handle, 0, "OSScreenPutPixelEx", &services.OSScreenPutPixelEx);
OSDynLoad_FindExport(services.coreinit_handle, 0, "DCFlushRange", &services.DCFlushRange);
OSDynLoad_FindExport(services.coreinit_handle, 0, "OSScreenFlipBuffersEx", &services.OSScreenFlipBuffersEx);
OSDynLoad_FindExport(services.coreinit_handle, 0, "OSScreenGetBufferSizeEx", &services.OSScreenGetBufferSizeEx);
OSDynLoad_FindExport(services.coreinit_handle, 0, "OSScreenPutFontEx", &services.OSScreenPutFontEx);
OSDynLoad_FindExport(services.coreinit_handle, 0, "OSScreenClearBufferEx", &services.OSScreenClearBufferEx);
//OS functions
OSDynLoad_FindExport(services.coreinit_handle, 0, "_Exit", &_Exit);
cleanSlate(&services);
/****************************> Globals <****************************/
struct SpaceGlobals mySpaceGlobals;
//Flag for restarting the entire game.
mySpaceGlobals.restart = 1;
mySpaceGlobals.services = &services;
// initial state is title screen
mySpaceGlobals.state = 1;
mySpaceGlobals.titleScreenRefresh = 1;
//Flags for render states
mySpaceGlobals.renderResetFlag = 0;
mySpaceGlobals.menuChoice = 0; // 0 is play, 1 is password
// setup the password list
unsigned int pwSeed = 27;
int x;
for (x=0; x<100; x++)
mySpaceGlobals.passwordList[x] = (int)(prand(&pwSeed)*100000);
// set the starting time
int64_t (*OSGetTime)();
OSDynLoad_FindExport(services.coreinit_handle, 0, "OSGetTime", &OSGetTime);
mySpaceGlobals.seed = OSGetTime();
/****************************> VPAD Loop <****************************/
int error;
VPADData vpad_data;
// decompress compressed things into their arrays, final argument is the transparent color in their palette
decompress_sprite(3061, 200, 100, compressed_title, mySpaceGlobals.title, 39);
decompress_sprite(511, 36, 36, compressed_ship, mySpaceGlobals.orig_ship, 14);
decompress_sprite(206, 23, 23, compressed_enemy, mySpaceGlobals.enemy, 9);
// setup palette and transparent index
mySpaceGlobals.curPalette = ship_palette;
mySpaceGlobals.transIndex = 14;
// initialize starfield for this game
initStars(&mySpaceGlobals);
mySpaceGlobals.invalid = 1;
while (1)
{
VPADRead(0, &vpad_data, 1, &error);
//Get the status of the gamepad
mySpaceGlobals.button = vpad_data.btn_hold;
mySpaceGlobals.rstick = vpad_data.rstick;
mySpaceGlobals.lstick = vpad_data.lstick;
mySpaceGlobals.touched = vpad_data.tpdata.touched;
if (mySpaceGlobals.touched == 1)
{
mySpaceGlobals.touchX = ((vpad_data.tpdata.x / 9) - 11);
mySpaceGlobals.touchY = ((3930 - vpad_data.tpdata.y) / 16);
}
if (mySpaceGlobals.restart == 1)
{
reset(&mySpaceGlobals);
mySpaceGlobals.restart = 0;
}
if (mySpaceGlobals.state == 1) // title screen
{
//.........这里部分代码省略.........
示例14: start
void BaseGame::beginGame()
{
sf::RenderWindow *window = Locator::locate<RenderService>()->getWindow();
// position
auto windowSize = window->getSize();
window->setPosition({
Config::getInt("display.position.x") - static_cast<int>(windowSize.x / 2),
Config::getInt("display.position.y") - static_cast<int>(windowSize.y / 2)
});
// initially fill screen
window->clear(backgroundColour);
window->display();
start();
fps.init(Config::getFloat("debug.fps-tick-rate"));
sf::Clock clock;
sf::Event e;
// todo separate physics from rendering
while (window->isOpen())
{
window = Locator::locate<RenderService>()->getWindow();
EventService *es = Locator::locate<EventService>();
// process OS events
while (window->pollEvent(e))
{
if (e.type == sf::Event::Closed)
window->close();
else if (e.type == sf::Event::Resized)
Locator::locate<CameraService>()->updateViewSize(e.size.width, e.size.height);
else if (e.type == sf::Event::MouseWheelScrolled)
{
CameraService *camera = Locator::locate<CameraService>();
sf::Vector2i mousePos = {e.mouseWheelScroll.x, e.mouseWheelScroll.y};
const sf::Keyboard::Key &sprintKey = Locator::locate<InputService>()->getKey(KEY_SPRINT);
const float increment = sf::Keyboard::isKeyPressed(sprintKey) ? 1.3f : 1.1f;
float zoom = e.mouseWheelScroll.delta > 0 ? 1.f / increment : increment;
camera->zoomTo(zoom, mousePos, *window);
}
else if (e.type == sf::Event::KeyPressed || e.type == sf::Event::KeyReleased)
{
Event event;
event.type = EVENT_RAW_INPUT_KEY;
event.rawInputKey.key = e.key.code;
event.rawInputKey.pressed = e.type == sf::Event::KeyPressed;
es->callEvent(event);
}
else if (e.type == sf::Event::MouseButtonPressed || e.type == sf::Event::MouseButtonReleased)
{
Event event;
event.type = EVENT_RAW_INPUT_CLICK;
event.rawInputClick.button = e.mouseButton.button;
event.rawInputClick.x = e.mouseButton.x;
event.rawInputClick.y = e.mouseButton.y;
event.rawInputClick.pressed = e.type == sf::Event::MouseButtonPressed;
es->callEvent(event);
}
}
// process game events
es->processQueue();
// tick
float delta(clock.restart().asSeconds());
tick(delta);
// render
window->clear(backgroundColour);
render(*window);
// overlay
if (showFPS)
{
// restore to default for gui display
auto windowSize = window->getSize();
window->setView(sf::View(sf::FloatRect(0, 0, windowSize.x, windowSize.y)));
fps.tick(delta, *window);
}
window->display();
}
}
示例15: QWidget
//.........这里部分代码省略.........
ui->tableImpresion->setColumnWidth(3,75);
ui->tableImpresion->setColumnWidth(4,75);
ui->tableImpresion->setColumnWidth(5,120);
ui->tableImpresion->setColumnWidth(6,100);
ui->tableImpresion->setColumnWidth(7,65);
QString styleSheet = "QHeaderView::section {"
"spacing: 5px;"
"height: 23px;"
"background-color: darkcyan;"
"color: black;"
"border: 1px solid black;"
"margin: 0px;"
"text-align: right;"
"font-family: arialblack;"
"font: bold 12px;"
"font-size: 12px; }";
ui->tableImpresion->horizontalHeader()->setStyleSheet(styleSheet);
int j=0;
int i=0;
QTableWidgetItem *item;
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setOrientation(QPrinter::Landscape);
QString fileNameAndPath = QFileDialog::getSaveFileName(this, "Guardar en formato PDF", "listaDeSociosAl_" + QDate::currentDate().toString("dd_MM_yy"),"*.pdf");
if (!fileNameAndPath.isNull()) {
printer.setOutputFileName(fileNameAndPath);
} else {
d_espera->close();
delete ui;
close();
return;
}
QPainter painter(&printer);
painter.setRenderHint(QPainter::Antialiasing);
painter.setRenderHint(QPainter::HighQualityAntialiasing);
QFont f = QFont();
f.setPixelSize(10);
QApplication::processEvents();
while (j<rowCount){
QSqlRecord row = model->record(j);
ui->tableImpresion->insertRow(i);
item = new QTableWidgetItem(row.value(0).toString());
item->setFont(f);
item->setTextAlignment(Qt::AlignCenter);
item->setFlags(item->flags()&~Qt::ItemIsEditable);
ui->tableImpresion->setItem(i, 0, item);
item = new QTableWidgetItem(row.value(2).toString() + ", " + row.value(1).toString());
item->setFont(f);
item->setFlags(item->flags()&~Qt::ItemIsEditable);
ui->tableImpresion->setItem(i, 1, item);
item = new QTableWidgetItem(row.value(3).toString());
item->setFont(f);
item->setFlags(item->flags()&~Qt::ItemIsEditable);
ui->tableImpresion->setItem(i, 2, item);
item = new QTableWidgetItem(row.value(4).toString());
item->setFont(f);
item->setTextAlignment(Qt::AlignCenter);
item->setFlags(item->flags()&~Qt::ItemIsEditable);
ui->tableImpresion->setItem(i, 3, item);
item = new QTableWidgetItem(row.value(5).toString());
item->setFlags(item->flags()&~Qt::ItemIsEditable);
item->setFont(f);
item->setTextAlignment(Qt::AlignCenter);
ui->tableImpresion->setItem(i, 4, item);
item = new QTableWidgetItem(row.value(6).toString());
item->setFlags(item->flags()&~Qt::ItemIsEditable);
item->setFont(f);
ui->tableImpresion->setItem(i, 5, item);
item = new QTableWidgetItem(row.value(9).toString());
item->setFont(f);
item->setFlags(item->flags()&~Qt::ItemIsEditable);
ui->tableImpresion->setItem(i, 6, item);
item = new QTableWidgetItem(row.value(10).toString());
item->setFont(f);
item->setTextAlignment(Qt::AlignCenter);
item->setFlags(item->flags()&~Qt::ItemIsEditable);
ui->tableImpresion->setItem(i, 7, item);
j++;
i++;
if (i==maxRowsPerPage){
i=0;
render(&painter, QPoint(), QRegion(), QWidget::DrawChildren);
printer.newPage();
hoja++;
ui->tableImpresion->clearContents();
d_espera->updateValue(progressIncrement);
QApplication::processEvents();
ui->labelHoja->setText("Hoja "+QString::number(hoja)+" de "+hojamax);
}
}
if (i>0) {
render(&painter, QPoint(), QRegion(), QWidget::DrawChildren);
QApplication::processEvents();
}
painter.end();
d_espera->close();
delete ui;
close();
}