void pyVault::UpdatePsnlAgeSDL( pySDLStateDataRecord & pyrec ) { plStateDataRecord * rec = pyrec.GetRec(); if ( !rec ) return; hsRef<NetVaultNode> templateNode = new NetVaultNode; if (hsRef<RelVaultNode> rvnFldr = VaultGetAgesIOwnFolder()) { templateNode->SetNodeType(plVault::kNodeType_AgeInfo); VaultAgeInfoNode ageInfo(templateNode); ageInfo.SetAgeFilename(kPersonalAgeFilename); if (hsRef<RelVaultNode> rvnInfo = rvnFldr->GetChildNode(templateNode, 2)) { templateNode->Clear(); templateNode->SetNodeType(plVault::kNodeType_SDL); if (hsRef<RelVaultNode> rvnSdl = rvnInfo->GetChildNode(templateNode, 1)) { VaultSDLNode sdl(rvnSdl); sdl.SetStateDataRecord(rec, plSDL::kDirtyOnly | plSDL::kTimeStampOnRead); } } } }
void pyVault::UpdatePsnlAgeSDL( pySDLStateDataRecord & pyrec ) { plStateDataRecord * rec = pyrec.GetRec(); if ( !rec ) return; NetVaultNode * templateNode = new NetVaultNode; templateNode->IncRef(); if (RelVaultNode * rvnFldr = VaultGetAgesIOwnFolderIncRef()) { templateNode->ClearFieldFlags(); templateNode->SetNodeType(plVault::kNodeType_AgeInfo); VaultAgeInfoNode ageInfo(templateNode); wchar_t str[MAX_PATH]; StrToUnicode(str, kPersonalAgeFilename, arrsize(str)); ageInfo.SetAgeFilename(str); if (RelVaultNode * rvnInfo = rvnFldr->GetChildNodeIncRef(templateNode, 2)) { templateNode->ClearFieldFlags(); templateNode->SetNodeType(plVault::kNodeType_SDL); if (RelVaultNode * rvnSdl = rvnInfo->GetChildNodeIncRef(templateNode, 1)) { VaultSDLNode sdl(rvnSdl); sdl.SetStateDataRecord(rec, plSDL::kDirtyOnly | plSDL::kTimeStampOnRead); rvnSdl->DecRef(); } rvnInfo->DecRef(); } rvnFldr->DecRef(); } templateNode->DecRef(); }
PyObject* pyVault::GetPsnlAgeSDL() const { PyObject * result = nil; hsRef<NetVaultNode> templateNode = new NetVaultNode; if (hsRef<RelVaultNode> rvnFldr = VaultGetAgesIOwnFolder()) { templateNode->SetNodeType(plVault::kNodeType_AgeInfo); VaultAgeInfoNode ageInfo(templateNode); ageInfo.SetAgeFilename(kPersonalAgeFilename); if (hsRef<RelVaultNode> rvnInfo = rvnFldr->GetChildNode(templateNode, 2)) { templateNode->Clear(); templateNode->SetNodeType(plVault::kNodeType_SDL); if (hsRef<RelVaultNode> rvnSdl = rvnInfo->GetChildNode(templateNode, 1)) { VaultSDLNode sdl(rvnSdl); plStateDataRecord * rec = new plStateDataRecord; if (sdl.GetStateDataRecord(rec, plSDL::kKeepDirty)) result = pySDLStateDataRecord::New(rec); else delete rec; } } } if (!result) PYTHON_RETURN_NONE; return result; }
int main(int argc, char **argv){ testCGStress(16); SDL sdl(SDL_INIT_EVERYTHING); Window win("Fluid!", 640, 480); //16 is the dimensions of the textures we're loading SimpleFluid fluidSim(16, win); fluidSim.initSim(); fluidSim.runSim(); return 0; }
int main() { try { SDL sdl(SDL_INIT_AUDIO); return Application::run(); } catch (const PiException& err) { (void) err; std::cerr << err.what() << std::endl; return 1; } //If we could start SDL then we can start running the app //Return the result of the running app return 1; }
int main(int argc, char *argv[]) { // Lua test sel::State luaState{true}; luaState["message"] = "Hello world!"; std::string message = luaState["message"]; std::cout << "Message: " << message << std::endl; // SDL test SDL2pp::SDL sdl(SDL_INIT_VIDEO); SDL2pp::SDLTTF ttf; SDL2pp::SDLImage img; SDL2pp::Window win("Hello world", 0, 0, 800, 600, SDL_WINDOWPOS_UNDEFINED); for (int i = 0; i < 10; ++i) { luaState["number"] = i; std::cout << "Number: " << int(luaState["number"]) << std::endl; SDL_Delay(1000); } luaState("print(\"Goodbye from Lua!\")"); }
int main(int argc, char *argv[]) { try { GFXLib sdl(640, 480, SDL_INIT_EVERYTHING); sdl.loadImage("Mitch.bmp"); bool done = false; while (!done) { done = sdl.events(); sdl.render(); } } catch (const Error &err) { std::cerr << "SDL2 ERROR: " << err.what() << std::endl; return 1; } return 0; }
PyObject* pyVault::GetPsnlAgeSDL() const { PyObject * result = nil; NetVaultNode * templateNode = new NetVaultNode; templateNode->IncRef(); if (RelVaultNode * rvnFldr = VaultGetAgesIOwnFolderIncRef()) { templateNode->ClearFieldFlags(); templateNode->SetNodeType(plVault::kNodeType_AgeInfo); VaultAgeInfoNode ageInfo(templateNode); wchar_t str[MAX_PATH]; StrToUnicode(str, kPersonalAgeFilename, arrsize(str)); ageInfo.SetAgeFilename(str); if (RelVaultNode * rvnInfo = rvnFldr->GetChildNodeIncRef(templateNode, 2)) { templateNode->ClearFieldFlags(); templateNode->SetNodeType(plVault::kNodeType_SDL); if (RelVaultNode * rvnSdl = rvnInfo->GetChildNodeIncRef(templateNode, 1)) { VaultSDLNode sdl(rvnSdl); plStateDataRecord * rec = new plStateDataRecord; if (sdl.GetStateDataRecord(rec, plSDL::kKeepDirty)) result = pySDLStateDataRecord::New(rec); else delete rec; rvnSdl->DecRef(); } rvnInfo->DecRef(); } rvnFldr->DecRef(); } templateNode->DecRef(); if (!result) PYTHON_RETURN_NONE; return result; }
int ART(Scene& scene) { bool profiling = false; Timer timer("Main"); int x,y; Color pixel; Write file(scene.Width(), scene.Height()); SDLEngine sdl(scene.Width(), scene.Height()); if(sdl.Status() == SDLENGINE_FAIL) return EXIT_FAILURE; RTEngine rt(scene); int time; double last_time=0, total_time =0; double last_rays=0, total_rays =0; std::cout << "Begin rendering" << std::endl; for(int iterations = 1; !sdl.PollGetEscape() && (profiling == false || iterations <2); ++iterations) { time = timer.StartNew(); for(last_rays = 0; ( !sdl.PollGetRefresh() && (last_time = timer.Elapsed(time)) < 2 /*&& last_rays < 500000*/); ++last_rays) { rt.Trace(); } timer.StopLast(); total_rays += last_rays; total_time += last_time; std::cout << iterations << "th iteration, shot " << last_rays << " rays, total " << total_rays << " rays shot, total time "<< total_time << " seconds" << std::endl; // Let's write the image and update screen! or just update for(x = 0; x < sdl.GetWidth(); x++) { for(y = 0; y < sdl.GetHeight(); y++) { // std::cout << "Showing x: " << x << " and y: " << y << std::endl; pixel = scene.Pixel(x,y); sdl.SetPixel(x,y, (int)(pixel.x*255), (int)(pixel.y*255), (int)(pixel.z*255)); // image.plot(x,sdl.GetHeight()-y,pixel.x,pixel.y,pixel.z); } } sdl.UpdateSc(); } std::cout << "Total " << total_rays << " casted in " << total_time << " seconds, averaging to " << total_rays/total_time << " rays per second" << std::endl; file.WritePixels(scene); // sdl.UpdateSc(); timer.SinceStart(); if (!profiling) sdl.Wait(); return EXIT_SUCCESS; }