int nbodyGLSetup(const VisArgs* args) { sceneInit(args); nbodyInitDrawState(); /* prepare rendering */ glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH); glutInitWindowSize(width, height); glutInitWindowPosition(0, 0); window = glutCreateWindow("Milkyway@Home N-body"); glutDisplayFunc(drawGLScene); if (scene->fullscreen) { glutFullScreen(); glutPassiveMotionFunc(passiveMotionFunc); } glutIdleFunc(drawGLScene); glutReshapeFunc(resizeGLScene); glutKeyboardFunc(keyPressed); glutSpecialFunc(specialKeyPressed); glutMouseFunc(mouseFunc); glutMotionFunc(motionFunc); initGL(width, height); return 0; }
//! A appeller juste avant la boucle principale (Main Loop) et après la creation de a fenetre GLvoid GLInit(GLsizei Width, GLsizei Height) { printf("repertoire courant="); system("pwd"); glEnable(GL_TEXTURE_2D); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // The Background Color = Black glClearDepth(1.0); glDepthFunc(GL_LESS); glEnable(GL_DEPTH_TEST); glShadeModel(GL_SMOOTH); // Indique à GL de calculer la couleur suivant la formule // couleur_du_buffer = alpha * couleur_polygone + (1-alpha)*couleur_du_buffer_de_fond glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDisable(GL_BLEND); // Indique à GL d'eliminer les fragments du polygones qui sont transparents // (On ne garde que les pixel dont alpha>0.01, ) glAlphaFunc(GL_GREATER, 0.01f); glDisable(GL_ALPHA_TEST) ; glEnable( GL_NORMALIZE); // set up lights. glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient); glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse); glLightfv(GL_LIGHT1, GL_SPECULAR, LightSpecular); glLightfv(GL_LIGHT1, GL_POSITION, LightPosition); glEnable(GL_LIGHT1); if (bLight) glEnable(GL_LIGHTING); else glDisable(GL_LIGHTING); glColorMaterial( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); glEnable( GL_COLOR_MATERIAL ); //glDisable( GL_COLOR_MATERIAL ); camInit(cam); sceneInit( scene ); }
int main() { // Initialize graphics gfxInitDefault(); C3D_Init(C3D_DEFAULT_CMDBUF_SIZE); // Initialize the renderbuffer static C3D_RenderBuf rb; C3D_RenderBufInit(&rb, 240, 400, GPU_RB_RGBA8, GPU_RB_DEPTH24_STENCIL8); rb.clearColor = CLEAR_COLOR; C3D_RenderBufClear(&rb); C3D_RenderBufBind(&rb); // Initialize the scene sceneInit(); // Main loop while (aptMainLoop()) { C3D_VideoSync(); hidScanInput(); // Respond to user input u32 kDown = hidKeysDown(); if (kDown & KEY_START) break; // break in order to return to hbmenu // Render the scene sceneRender(); C3D_Flush(); C3D_RenderBufTransfer(&rb, (u32*)gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL), DISPLAY_TRANSFER_FLAGS); C3D_RenderBufClear(&rb); } // Deinitialize the scene sceneExit(); // Deinitialize graphics C3D_Fini(); gfxExit(); return 0; }
//--------------------------------------------------------------------------------- int main(int argc, char **argv) { //--------------------------------------------------------------------------------- // Initialize graphics gfxInitDefault(); C3D_Init(C3D_DEFAULT_CMDBUF_SIZE); // Initialize the render target C3D_RenderTarget* target = C3D_RenderTargetCreate(240, 400, GPU_RB_RGBA8, GPU_RB_DEPTH24_STENCIL8); C3D_RenderTargetSetClear(target, C3D_CLEAR_ALL, CLEAR_COLOR, 0); C3D_RenderTargetSetOutput(target, GFX_TOP, GFX_LEFT, DISPLAY_TRANSFER_FLAGS); // Initialize the scene sceneInit(); // Main loop while (aptMainLoop()) { hidScanInput(); // Respond to user input u32 kDown = hidKeysDown(); if (kDown & KEY_START) break; // break in order to return to hbmenu moveSprites(); // Render the scene C3D_FrameBegin(C3D_FRAME_SYNCDRAW); C3D_FrameDrawOn(target); sceneRender(); C3D_FrameEnd(0); } // Deinitialize the scene sceneExit(); // Deinitialize graphics C3D_Fini(); gfxExit(); return 0; }
int main() { // Initialize graphics gfxInitDefault(); gpuInit(); // Initialize the scene sceneInit(); gpuClearBuffers(CLEAR_COLOR); // Main loop while (aptMainLoop()) { gspWaitForVBlank(); // Synchronize with the start of VBlank gfxSwapBuffersGpu(); // Swap the framebuffers so that the frame that we rendered last frame is now visible hidScanInput(); // Read the user input // Respond to user input u32 kDown = hidKeysDown(); if (kDown & KEY_START) break; // break in order to return to hbmenu // Render the scene gpuFrameBegin(); sceneRender(); gpuFrameEnd(); gpuClearBuffers(CLEAR_COLOR); // Flush the framebuffers out of the data cache (not necessary with pure GPU rendering) //gfxFlushBuffers(); } // Deinitialize the scene sceneExit(); // Deinitialize graphics gpuExit(); gfxExit(); return 0; }