Example #1
0
static gint button_press_event( GtkWidget      *widget,
                                GdkEventButton *event )
{
  static GdkGC *copy_gc = NULL;
  int x, y;
  
  x = event->x;
  y = event->y;

  pos_x[pos_nr] = (double) x;
  pos_y[pos_nr] = (double) y;

  pos_nr = (pos_nr+1) % 2;

  draw_test();

  if (copy_gc == NULL) {
    copy_gc = gdk_gc_new(widget->window);
  }

  gdk_draw_rgb_image(widget->window,
		     copy_gc,
		     0, 0,
		     width, height,
		     GDK_RGB_DITHER_NONE,
		     rgbdata, width*3 );

  return TRUE;
}
int main(int argc, char *argv[])
{
	parse_opts(argc, argv);

	setup_msr();
	setup_drm();
	setup_modeset();
	setup_vblank_interval();
	setup_alarm();

	printf("Test name:\t%s\n", opts.test_name);

	unset_mode();
	set_mode();

	setup_idle();

	if (opts.do_page_flip)
		page_flip_test();

	if (opts.do_draw)
		draw_test();

	if (opts.do_draw_and_flip)
		draw_and_flip_test();

	teardown_modeset();
	teardown_drm();
	teardown_msr();
	return 0;
}
Example #3
0
static void
change_spread (GtkEntry *entry,
	       int *ptr)
{
  double d;
  d = g_ascii_strtod (gtk_entry_get_text (entry), NULL);
  *ptr = (int)d;
  draw_test();
  gtk_widget_queue_draw (drawing_area);
}
Example #4
0
static void
change_gradient (GtkEntry *entry,
		 double *ptr)
{
  double d;
  d = g_ascii_strtod (gtk_entry_get_text (entry), NULL);
  if (d != 0.0)
    *ptr = 1.0/d;
  else
    *ptr = 0.0;
  draw_test();
  gtk_widget_queue_draw (drawing_area);
}
Example #5
0
/* Create a new backing pixmap of the appropriate size */
static gint configure_event( GtkWidget         *widget,
                             GdkEventConfigure *event )
{
  if (rgbdata)
    free(rgbdata);

  rgbdata = malloc(3*widget->allocation.width*widget->allocation.height);
  width = widget->allocation.width;
  height = widget->allocation.height;

  draw_test();
  
  return TRUE;
}
/**
 * Just the current frame in the display.
 */
static void engine_draw_frame(struct engine* engine)
{
    if (engine->app->window != NULL) {
        suseconds_t t1, t2;

        ANativeWindow_Buffer buffer;
        ANativeWindow_lock(engine->app->window, &buffer, 0);
        engine->canvas = ps_canvas_replace_data(engine->canvas, 
                (uint8_t*)buffer.bits, engine->fmt, engine->width, engine->height, buffer.stride * engine->bpp); 

        memset((uint8_t*)buffer.bits, 0xFF, engine->height * buffer.stride * engine->bpp);
        t1 = get_time();
        draw_test(0, engine->context);
        t2 = get_time();

        LOGI("draw a frame use %.4f ms", ((double)t2 - (double)t1)/1000);
        ANativeWindow_unlockAndPost(engine->app->window);
    }
}
Example #7
0
File: core.cpp Project: sgedev/sge
void end(void)
{
	SGE_ASSERT(details::g_window != NULL);
	SGE_ASSERT(details::g_gl_context != NULL);

	ImGui::Render();

	SDL_GL_MakeCurrent(details::g_window, details::g_gl_context);

	glViewport(0, 0, details::g_window_rect[2], details::g_window_rect[3]);
	glClear(GL_COLOR_BUFFER_BIT);

	s_program.Use();

	commit_uniforms();

	draw_test();

	ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
	ImGui::SetCurrentContext(NULL);

	SDL_GL_SwapWindow(details::g_window);
}
Example #8
0
static gint motion_notify_event( GtkWidget *widget,
                                 GdkEventMotion *event )
{
  static GdkGC *copy_gc = NULL;
  int x, y;
  GdkModifierType state;

  if (event->is_hint) {
    gdk_window_get_pointer (event->window, &x, &y, &state);
  } else {
    x = event->x;
    y = event->y;
    state = event->state;
  }

  if (state & GDK_BUTTON1_MASK && rgbdata != NULL) {
    
    pos_x[(pos_nr+1) % 2] = (double) x;
    pos_y[(pos_nr+1) % 2] = (double) y;
    
    draw_test();
    
    if (copy_gc == NULL) {
      copy_gc = gdk_gc_new(widget->window);
    }
    
    gdk_draw_rgb_image(widget->window,
		       copy_gc,
		       0, 0,
		       width, height,
		       GDK_RGB_DITHER_NONE,
		       rgbdata, width*3 );
  }
  
  return TRUE;
}
Example #9
0
int main (int argc, char *argv[])
{
    if (sdl_init () != 0)
        return 1;

    if (textures_init ())
        return 1;
    if (audio_init ())
    {
        fprintf (stderr, "Error loading SFX: %s\n", SDL_GetError());
        return 1;
    }
    if (music_init ())
    {
        fprintf (stderr, "Error loading SFX: %s\n", SDL_GetError());
        return 1;
    }

    if (config_load ())
    {
        fprintf (stderr, "Error loading config\n");
    }

    hiscore_init ();
    //gamestate = GAME_DEMO;
    running = 1;
    while (running)
    {
        sdl_read_input ();
        if (!paused)
        {
            SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0);
            if (gamestate != GAME_OVER)
                SDL_RenderClear (renderer);

            switch (gamestate)
            {
                case GAME_DEMO:
                    draw_test ();
                    break;
                case GAME_RUNNING:
                    game_loop ();
                    break;
                case GAME_AMODE:
                default:
                    amode_loop ();
                    break;
                case GAME_OVER:
                    gameover_loop ();
                    break;
                case GAME_HSENTRY:
                    hsentry_loop ();
                    break;
                case GAME_CONFIG:
                case GAME_CONFIG_INPUT:
                    config_loop ();
                    break;
                case GAME_SELECT_RECORD:
                    playback_loop ();
                    break;
            }
        }

        SDL_RenderPresent (renderer);
    }

    hiscore_save ();
    sdl_close ();
    return 0;
}