//panjie add for to render offline buffer void GLES20RenderEngine::beginGroup(const mat4& colorTransform, bool isGLES) { //GLuint tname, name; if (isGLES) { isToOfB = true; } else { isToOfB = false; return; //startFlag = true; } ALOGE("panjie beginGroup startFlag is:%d ",startFlag); if (startFlag) { startFlag = false; //panjie init opengl env ogl_init(); ogl_resize(/*mVpHeight,*//*2880*/mVpWidth, /*1704*/mVpHeight); ogl_create_background_default_texture(/*2880*/mVpWidth , /*1704*/mVpHeight/*, mVpWidth*/); //panjie end GLuint tname, name; // create the texture glGenTextures(1, &tname); glBindTexture(GL_TEXTURE_2D, tname); 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_RGBA, mVpWidth, mVpHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); // create a Framebuffer Object to render into glGenFramebuffers(1, &name); ALOGE("panjie name is : %d tname is : %d ",name,tname); glBindFramebuffer(GL_FRAMEBUFFER, name); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tname, 0); //} //Group group; group.texture = tname; group.fbo = name; group.width = mVpWidth; group.height = mVpHeight; group.colorTransform = colorTransform; if(GL_FALSE == glIsFramebuffer(mFboName)){ ALOGE("GL_FALSE == glIsFramebuffer mFboName = %d ", mFboName); glGenTextures(1, &mTexName); glBindTexture(GL_TEXTURE_2D, mTexName); 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_RGBA, mVpWidth, mVpHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); //original fbo, delete it then we get error glGenFramebuffers(1, &mFboName); } } Group mGroup; mGroup.texture = mTexName; mGroup.fbo = mFboName; mGroup.width = mVpWidth; mGroup.height = mVpHeight; //group.colorTransform = colorTransform; mGroupStack.push(mGroup); }
int main(int argc, char* argv[]) { const char* url = argc == 2 ? argv[1] : "http://www.google.com"; //ProfilerStart("/home/pi/Sample.prof"); bcm_host_init(); memset(&g_state, 0, sizeof(struct state)); ogl_init(&g_state); GMainLoop* mainLoop = g_main_loop_new(0, false); WKContextRef context = WKContextCreateWithInjectedBundlePath(WKStringCreateWithUTF8CString(SAMPLE_INJECTEDBUNDLE_DIR "libSampleInjectedBundle.so")); NIXView webView = NIXViewCreate(context, NULL); WKPageRef page = NIXViewGetPage(webView); NIXViewClient viewClient; memset(&viewClient, 0, sizeof(NIXViewClient)); viewClient.version = kNIXViewClientCurrentVersion; viewClient.viewNeedsDisplay = viewNeedsDisplay; NIXViewSetViewClient(webView, &viewClient); NIXViewInitialize(webView); WKPageLoaderClient loaderClient; memset(&loaderClient, 0, sizeof(loaderClient)); loaderClient.version = kWKPageLoaderClientCurrentVersion; loaderClient.didReceiveTitleForFrame = didReceiveTitleForFrame; WKPageSetPageLoaderClient(page, &loaderClient); NIXViewSetSize(webView, WKSizeMake(g_state.screen_width, g_state.screen_height)); WKPageLoadURL(page, WKURLCreateWithUTF8CString(url)); //ProfilerFlush(); //ProfilerStop(); g_main_loop_run(mainLoop); NIXViewRelease(webView); WKRelease(context); g_main_loop_unref(mainLoop); ogl_exit(&g_state); return 0; }
int cface_main(int argc, char* argv[]) // Window Show State { if(!ogl::create("OGL framework", 640, 480, 32)) return 0; ogl_resize(640, 480); ogl_init(); // Quit If Window Was Not Created while(true) { if(active) ogl_draw_scene(); if(!ogl::input()) break; } ogl::destroy(); // Kill The Window return 0; }
void init_graphics(int nargs, char** args, const char* title_bar, int x, int y) { /*KKCODEBLOCKSSUCKS*/#define SKMK_GLUT #ifdef SKMK_GLUT glutInit(&nargs, args); glutInitDisplayMode(GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH | GLUT_STENCIL); //kk glutInitContextVersion(3, 3); glutInitContextVersion(3, 1); glutInitContextProfile(GLUT_CORE_PROFILE); #ifdef SKMK_DEBUG glutInitContextFlags(GLUT_DEBUG); #endif glutInitWindowSize(x, y); glutInitWindowPosition(300, 300); int window = glutCreateWindow(title_bar); ogl_load_funcs(); glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION); skmk.ogl_state = malloc(sizeof(struct ogl_state)); init_ogl(skmk.ogl_state); //!! glutDisplayFunc(ogl_draw); glutReshapeFunc(reshape); glutKeyboardFunc(keyboard); glutMainLoop(); #elif SKMK_SDL2 //SDL_GLContext glcontext = SDL_GL_CreateContext(SDL_WINDOW); { SDL_Init(SDL_INIT_EVERYTHING); //TODO: Check errors K_SDL_WINDOW = SDL_CreateWindow(title_bar, 0, 0, x, y, SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); K_GL_CONTEXT = SDL_GL_CreateContext(K_SDL_WINDOW); ogl_init(); } #else #error You have to either use GLUT or SDL. #endif }
int mlx_launch(t_env *env) { debug_stdout("INIT", FILE_LINE_FUN); if (!(MLX = mlx_init())) return (ft_error(env, __FUNCTION__, "mlx_init error")); if (!(WIN = mlx_new_opengl_window(MLX, WDT, HGT, TITLE))) return (ft_error(env, __FUNCTION__, "mlx_new_window error")); mlx_opengl_window_set_context(WIN); if (ogl_init(env) != EXIT_SUCCESS) return (ft_error(env, __FUNCTION__, "ogl_init error")); mlx_expose_hook(WIN, expose_hook, env); mlx_key_hook(WIN, key_hook, env); mlx_hook(WIN, KeyRelease, KeyReleaseMask, key_hook, env); if (print_tutorial(env) != EXIT_SUCCESS) return (ft_error(env, __FUNCTION__, "print_tutorial error")); mlx_hook(WIN, LASTEvent, NoEventMask, idle_hook, env); mlx_loop_hook(MLX, expose_hook, env); test_opengl_error("ERROR", __FILE__, __LINE__, "Launching MLX_LOOP"); mlx_loop(MLX); return (EXIT_SUCCESS); }
int main( int argc, char *arvg[] ) { int quit = 0; int config_status = 0; int event; #ifdef __WIN32__ freopen( "cabrio.out", "w", stdout ); freopen( "cabrio.err", "w", stderr ); #endif config_status = config_open( NULL ); if( config_status == -1 ) return -1; if( sdl_init() != 0 ) bail(); if( ogl_init() != 0 ) bail(); /* Clear the screen as soon as we can. This avoids graphics * glitches which can occur with some SDL implementations. */ ogl_clear(); sdl_swap(); if( event_init() != 0 ) bail(); if( font_init() != 0 ) bail(); if( config_status == 1 ) { /* Config file didn't exist, so run the setup utility */ if( setup() != 0 ) return -1; config_update(); if( config_create() != 0 ) return -1; } location_init(); /* If config or location results in a new font, it'll be loaded here. */ font_free(); font_init(); /* Large game lists take a while to initialise, * so show the background while we wait... */ bg_init(); bg_clear(); bg_draw(); sdl_swap(); if( platform_init() != 0 ) bail(); if( category_init() != 0 ) bail(); if( game_sel_init() != 0 ) bail(); if( hint_init() != 0 ) bail(); if( snap_init() != 0 ) bail(); if( game_list_create() != 0 ) bail(); if( menu_init() != 0 ) bail(); if( submenu_init() != 0 ) bail(); sound_init(); video_init(); event_flush(); if( !config_get()->iface.theme.menu.auto_hide ) menu_show(); focus_set( FOCUS_GAMESEL ); while( !quit ) { ogl_clear(); bg_draw(); snap_draw(); if (!config_get()->iface.hide_buttons) hint_draw(); menu_draw(); submenu_draw(); game_sel_draw(); sdl_swap(); if (Mix_PlayingMusic() != 1 && config_get()->iface.theme_sound && reader_running == 0) playmusic(); if (( event = event_poll() )) { if( supress_wait == 0 ) { if( event == EVENT_QUIT ) { quit = 1; } else { supress(); event_process( event ); } } } if( supress_wait > 0 ) supress_wait--; sdl_frame_delay(); } clean_up(); return 0; }
int gr_init(int mode) { int retcode,t,glt=0; // Only do this function once! if (gr_installed==1) return -1; #ifdef OGL_RUNTIME_LOAD ogl_init_load_library(); #endif #ifdef GR_SUPPORTS_FULLSCREEN_TOGGLE if (FindArg("-gl_voodoo")) { ogl_voodoohack=1; gr_toggle_fullscreen(); } if (FindArg("-fullscreen")) gr_toggle_fullscreen(); #endif if ((glt=FindArg("-gl_alttexmerge"))) ogl_alttexmerge=1; if ((t=FindArg("-gl_stdtexmerge"))) if (t>=glt)//allow overriding of earlier args ogl_alttexmerge=0; if ((glt=FindArg("-gl_16bittextures"))) ogl_rgba_format=GL_RGB5_A1; if ((glt=FindArg("-gl_mipmap"))) { GL_texmagfilt=GL_LINEAR; GL_texminfilt=GL_LINEAR_MIPMAP_NEAREST; } if ((glt=FindArg("-gl_trilinear"))) { GL_texmagfilt=GL_LINEAR; GL_texminfilt=GL_LINEAR_MIPMAP_LINEAR; } if ((t=FindArg("-gl_simple"))) { if (t>=glt) { //allow overriding of earlier args glt=t; GL_texmagfilt=GL_NEAREST; GL_texminfilt=GL_NEAREST; } } if ((t=FindArg("-gl_texmagfilt")) || (t=FindArg("-gl_texmagfilter"))) { if (t>=glt)//allow overriding of earlier args GL_texmagfilt=ogl_atotexfilti(Args[t+1],0); } if ((t=FindArg("-gl_texminfilt")) || (t=FindArg("-gl_texminfilter"))) { if (t>=glt)//allow overriding of earlier args GL_texminfilt=ogl_atotexfilti(Args[t+1],1); } GL_needmipmaps=ogl_testneedmipmaps(GL_texminfilt); if ((t=FindArg("-gl_anisotropy")) || (t=FindArg("-gl_anisotropic"))) { GL_texanisofilt=atof(Args[t+1]); } mprintf((0,"gr_init: texmagfilt:%x texminfilt:%x needmipmaps=%i anisotropic:%f\n",GL_texmagfilt,GL_texminfilt,GL_needmipmaps,GL_texanisofilt)); if ((t=FindArg("-gl_vidmem"))) { ogl_mem_target=atoi(Args[t+1])*1024*1024; } if ((t=FindArg("-gl_reticle"))) { gl_reticle=atoi(Args[t+1]); } //printf("ogl_mem_target=%i\n",ogl_mem_target); ogl_init();//platform specific initialization ogl_init_texture_list_internal(); MALLOC( grd_curscreen,grs_screen,1 ); memset( grd_curscreen, 0, sizeof(grs_screen)); grd_curscreen->sc_canvas.cv_bitmap.bm_data = NULL; // Set the mode. if ((retcode=gr_set_mode(mode))) { return retcode; } grd_curscreen->sc_canvas.cv_color = 0; grd_curscreen->sc_canvas.cv_drawmode = 0; grd_curscreen->sc_canvas.cv_font = NULL; grd_curscreen->sc_canvas.cv_font_fg_color = 0; grd_curscreen->sc_canvas.cv_font_bg_color = 0; gr_set_current_canvas( &grd_curscreen->sc_canvas ); gr_installed = 1; atexit(gr_close); return 0; }
int vid_init(void) { int t, glt = 0; // Only do this function once! if (vid_installed == 1) return -1; #ifdef _WIN32 ogl_init_load_library(); #endif #ifdef VID_SUPPORTS_FULLSCREEN_TOGGLE if (FindArg("-gl_voodoo")){ ogl_voodoohack=1; vid_toggle_fullscreen(); } if (FindArg("-fullscreen")) vid_toggle_fullscreen(); #endif if ((glt=FindArg("-gl_alttexmerge"))) ogl_alttexmerge=1; if ((t=FindArg("-gl_stdtexmerge"))) if (t>=glt)//allow overriding of earlier args ogl_alttexmerge=0; if ((glt = FindArg("-gl_16bittextures"))) { ogl_rgba_internalformat = GL_RGB5_A1; ogl_rgb_internalformat = GL_RGB5; } if ((glt=FindArg("-gl_mipmap"))){ GL_texmagfilt=GL_LINEAR; GL_texminfilt=GL_LINEAR_MIPMAP_NEAREST; } if ((glt=FindArg("-gl_trilinear"))) { GL_texmagfilt = GL_LINEAR; GL_texminfilt = GL_LINEAR_MIPMAP_LINEAR; } if ((t=FindArg("-gl_simple"))){ if (t>=glt){//allow overriding of earlier args glt=t; GL_texmagfilt=GL_NEAREST; GL_texminfilt=GL_NEAREST; } } if ((t=FindArg("-gl_texmagfilt")) || (t=FindArg("-gl_texmagfilter"))){ if (t>=glt)//allow overriding of earlier args GL_texmagfilt=ogl_atotexfilti(Args[t+1],0); } if ((t=FindArg("-gl_texminfilt")) || (t=FindArg("-gl_texminfilter"))){ if (t>=glt)//allow overriding of earlier args GL_texminfilt=ogl_atotexfilti(Args[t+1],1); } GL_needmipmaps=ogl_testneedmipmaps(GL_texminfilt); if ((t = FindArg("-gl_anisotropy")) || (t = FindArg("-gl_anisotropic"))) { GL_texanisofilt=atof(Args[t + 1]); } mprintf((0,"gr_init: texmagfilt:%x texminfilt:%x needmipmaps=%i anisotropic:%f\n",GL_texmagfilt,GL_texminfilt,GL_needmipmaps,GL_texanisofilt)); if ((t=FindArg("-gl_vidmem"))){ ogl_mem_target=atoi(Args[t+1])*1024*1024; } if ((t=FindArg("-gl_reticle"))){ gl_reticle=atoi(Args[t+1]); } //printf("ogl_mem_target=%i\n",ogl_mem_target); ogl_init();//platform specific initialization ogl_init_texture_list_internal(); cmd_addcommand("gl_texturemode", ogl_cmd_texturemode, "gl_texturemode <x>\n" " use OpenGL texture mode <x>. Available mode are\n" " GL_NEAREST\n" " GL_LINEAR\n" " GL_NEAREST_MIPMAP_NEAREST\n" " GL_LINEAR_MIPMAP_NEAREST\n" " GL_NEAREST_MIPMAP_LINEAR\n" " GL_LINEAR_MIPMAP_LINEAR"); vid_installed = 1; atexit(vid_close); return 0; }