Search
lxdream.org :: lxdream/src/drivers/video_gtk.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/drivers/video_gtk.c
changeset 352:f0df7a6d4703
prev335:fb890e1814c0
next370:3131ba1440fc
author nkeynes
date Sun Feb 11 10:09:32 2007 +0000 (12 years ago)
permissions -rw-r--r--
last change Bug 27: Implement opengl framebuffer objects
Rewrite much of the final video output stage. Now uses generic "render
buffers", implemented on GL using framebuffer objects + textures.
file annotate diff log raw
nkeynes@94
     1
/**
nkeynes@352
     2
 * $Id: video_gtk.c,v 1.10 2007-02-11 10:09:32 nkeynes Exp $
nkeynes@94
     3
 *
nkeynes@94
     4
 * The PC side of the video support (responsible for actually displaying / 
nkeynes@94
     5
 * rendering frames)
nkeynes@94
     6
 *
nkeynes@94
     7
 * Copyright (c) 2005 Nathan Keynes.
nkeynes@94
     8
 *
nkeynes@94
     9
 * This program is free software; you can redistribute it and/or modify
nkeynes@94
    10
 * it under the terms of the GNU General Public License as published by
nkeynes@94
    11
 * the Free Software Foundation; either version 2 of the License, or
nkeynes@94
    12
 * (at your option) any later version.
nkeynes@94
    13
 *
nkeynes@94
    14
 * This program is distributed in the hope that it will be useful,
nkeynes@94
    15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
nkeynes@94
    16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
nkeynes@94
    17
 * GNU General Public License for more details.
nkeynes@94
    18
 */
nkeynes@94
    19
nkeynes@94
    20
#include <gnome.h>
nkeynes@94
    21
#include <gdk/gdkx.h>
nkeynes@94
    22
#include <stdint.h>
nkeynes@180
    23
#include "dream.h"
nkeynes@144
    24
#include "display.h"
nkeynes@94
    25
#include "drivers/video_x11.h"
nkeynes@94
    26
nkeynes@94
    27
GdkImage *video_img = NULL;
nkeynes@94
    28
GtkWindow *video_win = NULL;
nkeynes@94
    29
GtkWidget *video_area = NULL;
nkeynes@94
    30
uint32_t video_width = 640;
nkeynes@94
    31
uint32_t video_height = 480;
nkeynes@94
    32
nkeynes@352
    33
gboolean video_gtk_init();
nkeynes@352
    34
void video_gtk_shutdown();
nkeynes@144
    35
uint16_t video_gtk_resolve_keysym( const gchar *keysym );
nkeynes@94
    36
nkeynes@352
    37
struct display_driver display_gtk_driver = { "gtk", video_gtk_init, NULL,
nkeynes@352
    38
					     video_gtk_resolve_keysym,
nkeynes@352
    39
					     NULL, NULL, NULL, NULL, NULL, NULL, NULL };
nkeynes@352
    40
					     
nkeynes@144
    41
nkeynes@144
    42
gboolean video_gtk_keydown_callback(GtkWidget       *widget,
nkeynes@144
    43
				     GdkEventKey     *event,
nkeynes@144
    44
				     gpointer         user_data)
nkeynes@144
    45
{
nkeynes@144
    46
    input_event_keydown( event->keyval );
nkeynes@144
    47
}
nkeynes@144
    48
nkeynes@144
    49
uint16_t video_gtk_resolve_keysym( const gchar *keysym )
nkeynes@144
    50
{
nkeynes@144
    51
    int val = gdk_keyval_from_name( keysym );
nkeynes@144
    52
    if( val == GDK_VoidSymbol )
nkeynes@144
    53
	return 0;
nkeynes@144
    54
    return (uint16_t)val;
nkeynes@144
    55
}
nkeynes@144
    56
nkeynes@144
    57
gboolean video_gtk_keyup_callback(GtkWidget       *widget,
nkeynes@144
    58
				  GdkEventKey     *event,
nkeynes@144
    59
				  gpointer         user_data)
nkeynes@144
    60
{
nkeynes@144
    61
    input_event_keyup( event->keyval );
nkeynes@144
    62
}
nkeynes@94
    63
nkeynes@352
    64
gboolean video_gtk_init()
nkeynes@94
    65
{
nkeynes@352
    66
    video_win = GTK_WINDOW(gtk_window_new( GTK_WINDOW_TOPLEVEL ));
nkeynes@352
    67
    gtk_window_set_title( video_win, APP_NAME " - Emulation Window" );
nkeynes@352
    68
    gtk_window_set_policy( video_win, FALSE, FALSE, FALSE );
nkeynes@94
    69
    
nkeynes@352
    70
    g_signal_connect( video_win, "key_press_event", 
nkeynes@352
    71
		      G_CALLBACK(video_gtk_keydown_callback), NULL );
nkeynes@352
    72
    g_signal_connect( video_win, "key_release_event", 
nkeynes@352
    73
		      G_CALLBACK(video_gtk_keyup_callback), NULL );
nkeynes@352
    74
    gtk_widget_add_events( GTK_WIDGET(video_win), 
nkeynes@352
    75
			   GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK |
nkeynes@352
    76
			   GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK );
nkeynes@352
    77
    video_area = gtk_image_new();
nkeynes@352
    78
    gtk_widget_show( GTK_WIDGET(video_area) );
nkeynes@352
    79
    gtk_container_add( GTK_CONTAINER(video_win), GTK_WIDGET(video_area) );
nkeynes@352
    80
    gtk_widget_show( GTK_WIDGET(video_win) );
nkeynes@352
    81
    video_img = gdk_image_new( GDK_IMAGE_FASTEST, gdk_visual_get_system(),
nkeynes@352
    82
                               video_width, video_height );
nkeynes@352
    83
    gtk_image_set_from_image( GTK_IMAGE(video_area), video_img, NULL );
nkeynes@352
    84
nkeynes@335
    85
    gtk_window_set_default_size( video_win, video_width, video_height );
nkeynes@352
    86
nkeynes@352
    87
    video_glx_init( gdk_x11_display_get_xdisplay( gtk_widget_get_display(GTK_WIDGET(video_win))),
nkeynes@352
    88
		    gdk_x11_screen_get_xscreen( gtk_widget_get_screen(GTK_WIDGET(video_win))),
nkeynes@352
    89
		    GDK_WINDOW_XWINDOW( GTK_WIDGET(video_win)->window ),
nkeynes@352
    90
		    video_width, video_height, &display_gtk_driver );
nkeynes@94
    91
    return TRUE;
nkeynes@94
    92
}
nkeynes@94
    93
nkeynes@352
    94
void video_gtk_shutdown()
nkeynes@352
    95
{
nkeynes@94
    96
nkeynes@352
    97
nkeynes@94
    98
}
nkeynes@94
    99
.