Exemple #1
0
static fullscreen_window_t *getwindow(GtkWidget * win)
{
	gint i;

	if (windows)
	{
		for (i = 0; windows[i]; i++)
		{
			if (windows[i]->window == win)
				return windows[i];
		}
		windows = g_realloc(windows, sizeof (*windows) * (i + 2));
	}
	else
	{
		windows = g_malloc(sizeof (*windows) * 2);
		i = 0;
	}
	windows[i + 1] = NULL;
	windows[i] = g_malloc(sizeof (**windows));
	windows[i]->window = win;
	windows[i]->ox = 0;
	windows[i]->oy = 0;
	windows[i]->owidth = 0;
	windows[i]->oheight = 0;
	windows[i]->display = getdisplay(GDK_WINDOW_XDISPLAY(win->window));
	windows[i]->is_full = 0;
	return windows[i];
}
Exemple #2
0
int vsync_switchmode (int hz)
{
#ifndef RETRO
    static struct PicassoResolution *oldmode;
    static int oldhz;
	int w = currentmode->native_width;
	int h = currentmode->native_height;
	int d = currentmode->native_depth / 8;
        struct MultiDisplay *md = getdisplay (&currprefs);
	struct PicassoResolution *found;
	int newh, i, cnt;

    newh = h * (currprefs.ntscmode ? 60 : 50) / hz;

	found = NULL;
    for (cnt = 0; cnt <= abs (newh - h) + 1 && !found; cnt++) {
            for (i = 0; md->DisplayModes[i].depth >= 0 && !found; i++) {
                    struct PicassoResolution *r = &md->DisplayModes[i];
                    if ( (r->res.width == (uae_u32)w)
					  && ( (r->res.height == (uae_u32)(newh + cnt))
						|| (r->res.height == (uae_u32)(newh - cnt)) )
					  && (r->depth == d) ) {
                            int j = 0;
                            for ( ; r->refresh[j] > 0; j++) {
                                    if (r->refresh[j] == hz || r->refresh[j] == hz * 2) {
                                            found = r;
                                            hz = r->refresh[j];
                                            break;
                                    }
                            }
                    }
            }
    }
    if (found == oldmode && hz == oldhz)
            return true;
    oldmode = found;
    oldhz = hz;
    if (!found) {
            changed_prefs.gfx_apmode[0].gfx_vsync = 0;
            if (currprefs.gfx_apmode[0].gfx_vsync != changed_prefs.gfx_apmode[0].gfx_vsync) {
                    config_changed = 1;
            }
            write_log (_T("refresh rate changed to %d but no matching screenmode found, vsync disabled\n"), hz);
            return false;
    } else {
            newh = found->res.height;
            changed_prefs.gfx_size_fs.height = newh;
            changed_prefs.gfx_apmode[0].gfx_refreshrate = hz;
            if (changed_prefs.gfx_size_fs.height != currprefs.gfx_size_fs.height ||
                    changed_prefs.gfx_apmode[0].gfx_refreshrate != currprefs.gfx_apmode[0].gfx_refreshrate) {
                    write_log (_T("refresh rate changed to %d, new screenmode %dx%d\n"), hz, w, newh);
                    config_changed = 1;
            }
            return true;
    } 
#else
return false;
#endif
}
/*
 *Main
 */
int main(int argc, char** argv) {
    int estado=0;
    int* pestado=&estado;
    int estadomenu=POS1;
    int* pestadomenu=&estadomenu;
    int estadoconfiguracion=USUARIO;
    int* pestadoconfiguracion=&estadoconfiguracion;
    int condiciones=0;      //por lo que me devuelva la funcion setear comienzo
    int estadomensaje=0;
    int* pestadomensaje=&estadomensaje;
    
    if(inicializar()){
        return -1;
    }
    
    ALLEGRO_DISPLAY* display=NULL;
    ALLEGRO_EVENT_QUEUE* eventos=NULL;      //Son basicamente los punteros a estructuras propias de Allegro para la inicializacion de lo 
    ALLEGRO_TIMER*  timer=NULL;             //basico y necesario para hacer funcionar las funciones de esta libreria
    
    display=getdisplay(PANTALLA_ANCHO,PANTALLA_ALTO);
    eventos=geteventqueue();                              //llamo las funciones que crearan los displays y eventos
    timer=gettimer(1.0/FPS);
    if(display==ERROR||eventos==ERROR||timer==ERROR){
        return -1;                                      //si fallo alguna de las funciones llamadas, retorno del main, mostrando que hubo un error
    }
    
    al_register_event_source(eventos, al_get_display_event_source(display));

    al_register_event_source(eventos, al_get_timer_event_source(timer));     //registro los eventos
 
    al_register_event_source(eventos, al_get_mouse_event_source()); 
    
    al_register_event_source(eventos,al_get_keyboard_event_source());
    
    ALLEGRO_BITMAP* imagencelular=NULL;
    
    imagencelular=al_load_bitmap("foto_celular.png");
    if(imagencelular==NULL){fprintf(stderr,"No se pudo cargar la imagen\n");return -1;}     //chequeo que no haya habido errores
    
    al_draw_bitmap(imagencelular,-40,-20,0);
    al_flip_display();
    
    ALLEGRO_BITMAP* pantalla=NULL;      //a partir de ahora, solo trabajaremos graficamente en la pantalla
    pantalla=al_create_bitmap(220,288); //tiene el tamaño de la pantalla
    
    cambiopantalla(display,pantalla);
    al_clear_to_color(al_map_rgb(255,255,255));             //siempre que quiera modificar al bitmap pantalla para despues "pegarlo"
    cambiopantalla(display,pantalla);
    
    /*
     *  La secuencia que realizamos aqui... al_set_target_bitmap(pantalla);
     *                                      
     *                                      CAMBIOS ASOCIADOS A LA PANTALLA
     * 
     *                                      al_set_target_bitmap(al_get_backbuffer(display));
     *                                      al_draw_bitmap(pantalla,48,118,0);
     *                                      al_flip_display();
     * es la que esta comprimida en estas dos funciones
     * 
     */

    
    
    al_start_timer(timer);   //inicializo el timer
    
    INFOPANTALLA mipantalla=getuserdata();
    INFOPANTALLA* pmipantalla=&mipantalla;
    iniciarpantalla(mipantalla,display,pantalla);
    
    while(estado!=FINALIZAR){
        if(estado==PANTALLAPRINCIPAL){
            mantenerpantalla(mipantalla,display,pantalla);
            analizartecladopantalla(eventos,pestado,display,pantalla);
            
        } 
        if(estado==MENU){
            mantenermenu(pestado,pestadomenu,display,pantalla,mipantalla);
            analizartecladomenu(eventos,pestado,pestadomenu);
        }
        if(estado==MENSAJE){
            escribirmensaje(eventos,display,pantalla,pestado,pestadomensaje,pmipantalla);
        
        }
        if(estado==PERSONALIZAR){
            mantenerconfiguracion(pestadoconfiguracion,display,pantalla,eventos,pestado,pmipantalla);
            analizartecladoconfiguracion(eventos,pestadoconfiguracion,pestado,pmipantalla);        
        }
        
        
        
    }
    
    putuserdata(mipantalla);
    *pestado=PANTALLAPRINCIPAL;
    return (EXIT_SUCCESS);
}