int main(int argc, char **argv) { s32 result; result = SDL_Init(SDL_INIT_VIDEO); if(result) { ross_log("Failed to init SDL", LOG_ERROR); return(-1); } WindowDimension window_dimension; window_dimension.width = 800; window_dimension.height = 600; SDL_Window *window = SDL_CreateWindow("rossie", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, window_dimension.width, window_dimension.height, SDL_WINDOW_OPENGL | SDL_WINDOW_MAXIMIZED); if(window) { SDL_GLContext context = SDL_GL_CreateContext(window); if(context) { if(glewInit() == GLEW_OK) { global_running = 1; GLuint shader_program = compile_shaders(); ProgramBuffers program_buffers = setup_buffers(); glEnableClientState(GL_VERTEX_ARRAY); glViewport(0, 0, window_dimension.width, window_dimension.height); Input last_input = {}; while(global_running) { SDL_PumpEvents(); Input new_input; new_input = get_frame_input(); manage_events(new_input, window); render(new_input, last_input, shader_program, program_buffers); SDL_GL_SwapWindow(window); last_input = new_input; } } else { ross_log("Failed to init glew", LOG_ERROR); } SDL_GL_DeleteContext(context); } else { ross_log("Failed to create SDL GL context", LOG_ERROR); } } else { ross_log("Failed to create window", LOG_ERROR); } SDL_DestroyWindow(window); SDL_Quit(); return(0); }
C_RESULT vp_stages_output_sdl_stage_transform(vp_stages_output_sdl_config_t *cfg, vp_api_io_data_t *in, vp_api_io_data_t *out) { #if defined(_CK4215_) && defined(WIN32) struct SDL_SysWMinfo wmInfo; #endif vp_os_mutex_lock(&out->lock); #if defined(_CK4215_) && defined(WIN32) if( exit_pipeline == TRUE ) { /* It let the VPSDK handles the closing of the SDL */ out->status = VP_API_STATUS_ENDED; return (VP_FAILURE); } #endif if(out->status == VP_API_STATUS_INIT) { out->numBuffers = 1; out->size = cfg->y_size + 2*cfg->c_size; out->buffers = (int8_t**)vp_os_malloc(sizeof(uint8_t*)+out->size*sizeof(uint8_t)); out->buffers[0] = (int8_t*)(out->buffers+1); out->indexBuffer = 0; #if defined(_CK4215_) && defined(WIN32) if( main_windows ) cfg->surface = SDL_SetVideoMode(cfg->width, cfg->height, cfg->bpp, SDL_NOFRAME); else cfg->surface = SDL_SetVideoMode(cfg->width, cfg->height, cfg->bpp, SDL_HWSURFACE); #else cfg->surface = SDL_SetVideoMode(cfg->width, cfg->height, cfg->bpp, SDL_HWSURFACE); #endif SDL_ShowCursor(SDL_DISABLE); cfg->overlay = SDL_CreateYUVOverlay(cfg->pic_width, cfg->pic_height, SDL_YV12_OVERLAY, cfg->surface); #if defined(_CK4215_) && defined(WIN32) SDL_VERSION(&wmInfo.version); if(-1 == SDL_GetWMInfo(&wmInfo)) { OutputDebugString(SDL_GetError()); return -1; } child_windows = (void *) wmInfo.window; //Attach to parent windows if( main_windows ) SetParent((HWND)child_windows,(HWND) main_windows); if( main_windows ) { //Put the child windows at the good position //MoveWindow((HWND)child_windows, 0,0,/*g_x, g_y,*/ cfg->width, cfg->height, FALSE); MoveWindow((HWND)child_windows, cfg->window_pos_x, cfg->window_pos_y, cfg->width, cfg->height, FALSE); } else { SetWindowPos( (HWND)child_windows, HWND_TOPMOST, cfg->window_pos_x, //0, // X cfg->window_pos_y,//0, // Y cfg->width, // cx cfg->height, // cy SWP_SHOWWINDOW//SWP_NOREPOSITION//SWP_NOREDRAW //uFlags ); } #endif } out->status = (in->status == VP_API_STATUS_STILL_RUNNING ? VP_API_STATUS_PROCESSING : in->status); pipeline_opened = 1; if((out->status == VP_API_STATUS_PROCESSING || out->status == VP_API_STATUS_STILL_RUNNING) && in->size > 0) { vp_stages_display_frame(cfg, (vp_api_picture_t*)in->buffers); #if defined(_CK4215_) && defined(WIN32) manage_events(); #endif vp_os_memcpy(out->buffers[0], ((vp_api_picture_t*)in->buffers)->y_buf, cfg->y_size); if(cfg->c_size) { vp_os_memcpy(out->buffers[0]+cfg->y_size, ((vp_api_picture_t*)in->buffers)->cb_buf, cfg->c_size); vp_os_memcpy(out->buffers[0]+cfg->y_size+cfg->c_size, ((vp_api_picture_t*)in->buffers)->cr_buf, cfg->c_size); } } // not managed if(in->status == VP_API_STATUS_ENDED) { pipeline_opened = 0; vp_os_free(out->buffers); out->buffers = NULL; } vp_os_mutex_unlock(&out->lock); return (VP_SUCCESS); }