static void open_ogl (void) { TRACE_VC_MEMORY ("state 0"); #if defined (USE_OMX_TARGET_RPI) && defined (HAVE_GST_EGL) bcm_host_init (); TRACE_VC_MEMORY ("after bcm_host_init"); #endif /* Start OpenGLES */ init_ogl (state); TRACE_VC_MEMORY ("after init_ogl"); /* Wrap the EGL display */ state->gst_display = gst_egl_display_new (state->display, NULL); /* Setup the model world */ init_model_proj (state); TRACE_VC_MEMORY ("after init_model_proj"); /* initialize the OGLES texture(s) */ init_textures (state); TRACE_VC_MEMORY ("after init_textures"); }
int main () { bcm_host_init(); printf("Note: ensure you have sufficient gpu_mem configured\n"); // Clear application state memset( state, 0, sizeof( *state ) ); // Start OGLES init_ogl(state); // Setup the model world init_model_proj(state); // initialise the OGLES texture(s) init_textures(state); while (!terminate) { update_model(state); redraw_scene(state); } exit_func(); return 0; }
static void update_image (APP_STATE_T * state, GstBuffer * buffer) { GstVideoGLTextureUploadMeta *meta = NULL; if (state->current_buffer) { gst_buffer_unref (state->current_buffer); } else { /* Setup the model world */ init_model_proj (state); TRACE_VC_MEMORY ("after init_model_proj"); /* initialize the OGLES texture(s) */ init_textures (state, buffer); TRACE_VC_MEMORY ("after init_textures"); } state->current_buffer = gst_buffer_ref (buffer); TRACE_VC_MEMORY_ONCE_FOR_ID ("before GstVideoGLTextureUploadMeta", gid0); if (state->can_avoid_upload) { GstMemory *mem = gst_buffer_peek_memory (state->current_buffer, 0); g_assert (gst_is_gl_memory (mem)); state->tex = ((GstGLMemory *) mem)->tex_id; } else if ((meta = gst_buffer_get_video_gl_texture_upload_meta (buffer))) { if (meta->n_textures == 1) { guint ids[4] = { state->tex, 0, 0, 0 }; if (!gst_video_gl_texture_upload_meta_upload (meta, ids)) { GST_WARNING ("failed to upload to texture"); } } } TRACE_VC_MEMORY_ONCE_FOR_ID ("after GstVideoGLTextureUploadMeta", gid1); }
static int teapot_gl_init(RASPITEX_STATE *raspitex_state) { const char *model_path = "/opt/vc/src/hello_pi/hello_teapot/teapot.obj.dat"; TEAPOT_STATE_T *state = NULL; int rc = 0; // Clear scene state state = calloc(1, sizeof(TEAPOT_STATE_T)); raspitex_state->scene_state = state; state->screen_width = raspitex_state->width; state->screen_height = raspitex_state->height; rc = raspitexutil_gl_init_1_0(raspitex_state); if (rc != 0) goto end; // Start OGLES init_ogl(state); // Setup the model world init_model_proj(state); state->model = load_wavefront(model_path, NULL); if (! state->model) { vcos_log_error("Failed to load model from %s\n", model_path); rc = -1; } end: return rc; }
int _main () { bcm_host_init(); // Clear application state memset( state, 0, sizeof( *state ) ); // Start OGLES init_ogl(state); // Setup the model world init_model_proj(state); // initialise the OGLES texture(s) init_textures(state); while (!terminate) { update_model(state); redraw_scene(state); } exit_func(); return 0; }
void modelEngine::initialize(void) { numModels = 0; numShaders = 0; modelEngine_init_ogl(&state); init_model_proj(&state); glEnable(GL_TEXTURE_2D); glEnable(GL_CULL_FACE); glCullFace(GL_BACK); glFrontFace(GL_CCW); glEnable(GL_BLEND); glBlendFunc(GL_ONE,GL_ONE_MINUS_SRC_ALPHA); glBlendEquation(GL_FUNC_ADD); glDepthRangef(0.0,1.0); glEnable(GL_DEPTH_TEST); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); //glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_MODULATE); // Enable lighting mat_specular[0] = 1.0; mat_specular[1] = 1.0; mat_specular[2] = 1.0; mat_specular[3] = 1.0; mat_shininess[0] = 50.0; light_position[0] = 0.0; light_position[1] = 5.0; light_position[2] = 36.0; light_position[3] = 0.0; //glClearColor (0.0, 0.0, 0.0, 0.0); GLfloat mat_ambient[] = { 1.0, 0.5, 0.5, 1.0 }; glShadeModel (GL_SMOOTH); glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, mat_ambient); checkGLError(); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular); checkGLError(); glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mat_shininess); checkGLError(); GLfloat light_ambient[] = { 0.5, 0.5, 0.5, 1.0 }; GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 }; glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient); checkGLError(); glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse); checkGLError(); glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular); checkGLError(); glLightfv(GL_LIGHT0, GL_POSITION, light_position); checkGLError(); //glLightfv(GL_LIGHT0, GL_POSITION, light_position); //glLightfv(GL_LIGHT0, GL_AMBIENT, light_position); checkGLError(); glEnable(GL_LIGHTING); checkGLError(); glEnable(GL_LIGHT0); checkGLError(); // Initialize fonts initFonts(); }