Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
15 years ago

Some help in application selector example

Hi,

Can anyone explain this function to me (I mean explaining each statment in this function and how does it work)

Note : This function is included in the app_selector_gui.c in the appication selector example which works on the Nios II embededd Cyclone III edition .

int AsPrerenderFont( unsigned char* rendered_letters[],

struct abc_font_struct font[],

int fg_color,

int bg_color )

{

int i;

// We're going to use the video library functions to render this, and

// since those functions expect an alt_video_display type to which to write,

// we create a small temporary one here and fill it out just enough to draw

// to it.

alt_video_display* temp_buffer;

temp_buffer = (alt_video_display*) malloc(sizeof (alt_video_display));

temp_buffer->color_depth = 32;

temp_buffer->num_frame_buffers = 1;

temp_buffer->bytes_per_pixel = ( 4 );

temp_buffer->buffer_being_written = 0;

temp_buffer->buffer_ptrs[0] = (alt_video_frame*) malloc( sizeof( alt_video_frame ));

for( i = 0; i < 94; i++ )

{

temp_buffer->width = font.bounds_width ;

temp_buffer->height = font.bounds_height;

temp_buffer->bytes_per_frame = (( temp_buffer->width * temp_buffer->height ) * 4 );

temp_buffer->buffer_ptrs[0]->buffer = (void*) malloc( temp_buffer->bytes_per_frame );

vid_print_char_alpha ( 0, 0, fg_color, i + 33, bg_color, font, temp_buffer );

rendered_letters[i] = temp_buffer->buffer_ptrs[0]->buffer;

}

free( temp_buffer->buffer_ptrs[0] );

free( temp_buffer );

return( 0 );

}
No RepliesBe the first to reply