// main() function // Initializes the user interface (and any user variables) // then hands over control to the event handler, which calls // display() whenever the GL window needs to be redrawn. int main(int argc, char** argv) { // Process program arguments if(argc != 3) { printf("Usage: demo [width] [height]\n"); printf("Using 800x600 window by default...\n"); Win[0] = 800; Win[1] = 600; } else { Win[0] = atoi(argv[1]); Win[1] = atoi(argv[2]); } // Initialize glut, glui, and opengl glutInit(&argc, argv); initGlut(argv[0]); initGlui(); initGl(); // Invoke the standard GLUT main event loop glutMainLoop(); return 0; // never reached }
/* connect to server, create and map window, * allocate colors and (shared) memory */ static int config(uint32_t width, uint32_t height, uint32_t d_width, uint32_t d_height, uint32_t flags, char *title, uint32_t format) { int xs, ys; image_height = height; image_width = width; image_format = format; is_yuv = mp_get_chroma_shift(image_format, &xs, &ys) > 0; is_yuv |= (xs << 8) | (ys << 16); glFindFormat(format, NULL, &gl_texfmt, &gl_format, &gl_type); int_pause = 0; vo_flipped = !!(flags & VOFLAG_FLIPPING); if (create_window(d_width, d_height, flags, title) < 0) return -1; if (vo_config_count) uninitGl(); if (glctx.setGlWindow(&glctx) == SET_WINDOW_FAILED) return -1; if (mesa_buffer && !mpglAllocateMemoryMESA) { mp_msg(MSGT_VO, MSGL_ERR, "Can not enable mesa-buffer because AllocateMemoryMESA was not found\n"); mesa_buffer = 0; } initGl(vo_dwidth, vo_dheight); return 0; }
void H19::run() { int dummy_argc = 1; char* dummy_argv = (char*) "dummy"; glutInit(&dummy_argc, &dummy_argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA); glutInitWindowSize(640 + 40, 500 + 40); glutInitWindowPosition(500, 100); glutCreateWindow((char*) "Virtual Heathkit H-89 All-in-One Computer"); glClearColor(0.0f, 0.0f, 0.0f, 0.9f); // glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA); glBlendFunc(GL_ONE, GL_ONE); // glBlendEquation(GL_FUNC_ADD); glBlendColor(0.5, 0.5, 0.5, 0.9); // glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glShadeModel(GL_FLAT); initGl(); glutReshapeFunc(reshape); glutKeyboardFunc(keyboard); glutSpecialFunc(special); glutDisplayFunc(glDisplay); glutTimerFunc(screenRefresh_m, timer, 1); glutIgnoreKeyRepeat(1); glutMainLoop(); }
/** \fn resetVdpau */ bool vdpauVideoFilterDeint::setupVdpau(void) { scaler=NULL; secondField=false; nextFrame=0; if(!admVdpau::isOperationnal()) { ADM_warning("Vdpau not operationnal\n"); return false; } if(VDP_STATUS_OK!=admVdpau::outputSurfaceCreate(VDP_RGBA_FORMAT_B8G8R8A8, info.width,info.height,&outputSurface)) { ADM_error("Cannot create outputSurface0\n"); return false; } for(int i=0;i<ADM_NB_SURFACES;i++) surfacePool[i]=VDP_INVALID_HANDLE; for(int i=0;i<ADM_NB_SURFACES;i++) { if(VDP_STATUS_OK!=admVdpau::surfaceCreate( previousFilter->getInfo()->width, previousFilter->getInfo()->height, &(surfacePool[i]))) { ADM_error("Cannot create input Surface %d\n",i); goto badInit; } aprintf("Created surface %d\n",(int)surfacePool[i]); } // allocate our (dummy) images for(int i=0;i<3;i++) xslots[i].image=new ADMImageDefault( previousFilter->getInfo()->width, previousFilter->getInfo()->height); if(VDP_STATUS_OK!=admVdpau::mixerCreate(previousFilter->getInfo()->width, previousFilter->getInfo()->height,&mixer,true)) { ADM_error("Cannot create mixer\n"); goto badInit; } tempBuffer=new uint8_t[info.width*info.height*4]; scaler=new ADMColorScalerSimple( info.width,info.height, ADM_COLOR_BGR32A,ADM_COLOR_YV12); freeSurface.clear(); for(int i=0;i<ADM_NB_SURFACES;i++) freeSurface.push_back(surfacePool[i]); ADM_info("VDPAU setup ok\n"); if(initGl()==false) { ADM_error("Cannot setup openGL\n"); goto badInit; } ADM_info("VDPAU setup ok\n"); return true; badInit: cleanupVdpau(); passThrough=true; return false; }
int GlfwApp::run() { createRenderingTarget(); if (!window) { FAIL("Unable to create OpenGL window"); } initGl(); int framecount = 0; long start = Platform::elapsedMillis(); while (!glfwWindowShouldClose(window)) { glfwPollEvents(); update(); draw(); finishFrame(); long now = Platform::elapsedMillis(); ++framecount; if ((now - start) >= 2000) { float elapsed = (now - start) / 1000.f; fps = (float) framecount / elapsed; SAY("FPS: %0.2f", fps); start = now; framecount = 0; } } glfwDestroyWindow(window); return 0; }
static void check_events(void) { int e=glctx.check_events(); if(e&VO_EVENT_REINIT) { uninitGl(); initGl(vo_dwidth, vo_dheight); } if(e&VO_EVENT_RESIZE) resize(vo_dwidth,vo_dheight); if(e&VO_EVENT_EXPOSE && int_pause) redraw(); }
void TestWindow::draw() { if (_aboutToQuit) { return; } // Attempting to draw before we're visible and have a valid size will // produce GL errors. if (!isVisible() || _size.width() <= 0 || _size.height() <= 0) { return; } static std::once_flag once; std::call_once(once, [&] { initGl(); }); if (!_glContext.makeCurrent(this)) { return; } updateSurfaces(); auto size = this->geometry().size(); auto incrementX = size.width() / DIVISIONS_X; auto incrementY = size.height() / DIVISIONS_Y; _glf.glViewport(0, 0, size.width(), size.height()); _glf.glClearColor(1, 0, 0, 1); _glf.glClear(GL_COLOR_BUFFER_BIT); for (uint32_t x = 0; x < DIVISIONS_X; ++x) { for (uint32_t y = 0; y < DIVISIONS_Y; ++y) { auto& qmlInfo = _surfaces[x][y]; if (!qmlInfo.surface || !qmlInfo.texture) { continue; } _glf.glBindFramebuffer(GL_READ_FRAMEBUFFER, _fbo); _glf.glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, qmlInfo.texture, 0); _glf.glBlitFramebuffer( // src coordinates 0, 0, _qmlSize.width() - 1, _qmlSize.height() - 1, // dst coordinates incrementX * x, incrementY * y, incrementX * (x + 1), incrementY * (y + 1), // blit mask and filter GL_COLOR_BUFFER_BIT, GL_NEAREST); } } _glf.glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0); _glf.glBindFramebuffer(GL_READ_FRAMEBUFFER, 0); _glContext.swapBuffers(this); }
void TestWindow::draw() { if (_aboutToQuit) { return; } // Attempting to draw before we're visible and have a valid size will // produce GL errors. if (!isVisible() || _size.width() <= 0 || _size.height() <= 0) { return; } if (!_glContext.makeCurrent(this)) { return; } static std::once_flag once; std::call_once(once, [&] { initGl(); }); beginFrame(); renderFrame(); endFrame(); }
//====================================================================================================================== // Constructor = //====================================================================================================================== Application::Application(int width, int height): physics(NULL), camPos(0.0, 0.0, 5.0), camZ(0.0, 0.0, 1.0), camY(0.0, 1.0, 0.0), movingDist(0.2), movingAng(0.1), keys(SDLK_LAST, 0), time(0) { SDL_Init(SDL_INIT_VIDEO); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1); //SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 8); mainSurf = SDL_SetVideoMode(width, height, 24, SDL_HWSURFACE | SDL_OPENGL); // move window /*SDL_SysWMinfo myinfo; Display *d; SDL_GetWMInfo(&myinfo); if(myinfo.subsystem == SDL_SYSWM_X11) { d = myinfo.info.x11.display; myinfo.info.x11.lock_func(); XMoveWindow(d, myinfo.info.x11.wmwindow, 400, 800); myinfo.info.x11.unlock_func(); }*/ initGl(); resize(width, height); // init physics physics = new Physics; }