Search
lxdream.org :: lxdream/src/video.c
lxdream 0.9.1
released Jun 29
Download Now
filename src/video.c
changeset 65:9f124c245fc6
prev31:495e480360d7
author nkeynes
date Tue Jan 03 12:21:45 2006 +0000 (14 years ago)
permissions -rw-r--r--
last change Implement blanking (maybe, untested)
Quick hack to generate appropriate events on ta list completion
file annotate diff log raw
nkeynes@31
     1
/**
nkeynes@65
     2
 * $Id: video.c,v 1.3 2006-01-03 12:21:45 nkeynes Exp $
nkeynes@31
     3
 *
nkeynes@31
     4
 * The PC side of the video support (responsible for actually displaying / 
nkeynes@31
     5
 * rendering frames)
nkeynes@31
     6
 *
nkeynes@31
     7
 * Copyright (c) 2005 Nathan Keynes.
nkeynes@31
     8
 *
nkeynes@31
     9
 * This program is free software; you can redistribute it and/or modify
nkeynes@31
    10
 * it under the terms of the GNU General Public License as published by
nkeynes@31
    11
 * the Free Software Foundation; either version 2 of the License, or
nkeynes@31
    12
 * (at your option) any later version.
nkeynes@31
    13
 *
nkeynes@31
    14
 * This program is distributed in the hope that it will be useful,
nkeynes@31
    15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
nkeynes@31
    16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
nkeynes@31
    17
 * GNU General Public License for more details.
nkeynes@31
    18
 */
nkeynes@31
    19
nkeynes@1
    20
#include <gnome.h>
nkeynes@65
    21
#include <stdint.h>
nkeynes@1
    22
nkeynes@1
    23
GdkImage *img;
nkeynes@1
    24
GtkWindow *video_win;
nkeynes@1
    25
GtkWidget *video_area;
nkeynes@1
    26
char *video_data;
nkeynes@65
    27
uint32_t video_width = 640;
nkeynes@65
    28
uint32_t video_height = 480;
nkeynes@65
    29
uint32_t video_frame_count = 0;
nkeynes@1
    30
nkeynes@1
    31
void video_open( void )
nkeynes@1
    32
{
nkeynes@1
    33
    img = gdk_image_new( GDK_IMAGE_FASTEST, gdk_visual_get_system(),
nkeynes@1
    34
                         640, 480 );
nkeynes@1
    35
    video_win = GTK_WINDOW(gtk_window_new( GTK_WINDOW_TOPLEVEL ));
nkeynes@1
    36
    video_area = gtk_image_new_from_image(img, NULL);
nkeynes@1
    37
    gtk_widget_show( video_area );
nkeynes@1
    38
    gtk_container_add( GTK_CONTAINER(video_win), video_area );
nkeynes@1
    39
    video_data = img->mem;
nkeynes@1
    40
    
nkeynes@1
    41
    gtk_window_set_title( video_win, "DreamOn! - Emulation Window" );
nkeynes@1
    42
    gtk_window_set_policy( video_win, FALSE, FALSE, FALSE );
nkeynes@1
    43
    gtk_window_set_default_size( video_win, 640, 480 );
nkeynes@1
    44
    
nkeynes@1
    45
    gtk_widget_show( GTK_WIDGET(video_win) );
nkeynes@1
    46
}
nkeynes@1
    47
nkeynes@65
    48
/**
nkeynes@65
    49
 * Fill the entire frame with the specified colour (00RRGGBB)
nkeynes@65
    50
 */
nkeynes@65
    51
void video_fill( uint32_t colour ) 
nkeynes@65
    52
{
nkeynes@65
    53
    char *p = video_data;
nkeynes@65
    54
    int i;
nkeynes@65
    55
    for( i=0; i<video_width*video_height; i++ ) {
nkeynes@65
    56
	*p++ = (colour>>16) & 0xFF;
nkeynes@65
    57
	*p++ = (colour>>8) & 0xFF;
nkeynes@65
    58
	*p++ = (colour) & 0xFF;
nkeynes@65
    59
    }
nkeynes@65
    60
}
nkeynes@65
    61
nkeynes@1
    62
void video_update_frame( void )
nkeynes@1
    63
{
nkeynes@65
    64
    video_frame_count++;
nkeynes@1
    65
    gtk_widget_queue_draw( video_area );
nkeynes@1
    66
}
nkeynes@1
    67
nkeynes@1
    68
void video_update_size( int hres, int vres, int colmode )
nkeynes@1
    69
{
nkeynes@1
    70
    /* do something intelligent */
nkeynes@1
    71
}
.