Ejemplo n.º 1
0
void vsx_widget_profiler_plot::i_draw()
{
  vsx_vector3<> parentpos = get_pos_p();
  glBegin(GL_QUADS);
    vsx_widget_skin::get_instance()->set_color_gl(1);
    glVertex3f(parentpos.x-size.x*0.5f, parentpos.y+size.y*0.5f,pos.z);
    glVertex3f(parentpos.x+size.x*0.5f, parentpos.y+size.y*0.5f,pos.z);
    glVertex3f(parentpos.x+size.x*0.5f, parentpos.y+-size.y*0.5f,pos.z);
    glVertex3f(parentpos.x-size.x*0.5f, parentpos.y+-size.y*0.5f,pos.z);
  glEnd();
  vsx_widget_skin::get_instance()->set_color_gl(0);
  draw_box_border(vsx_vector3<>(parentpos.x-size.x*0.5,parentpos.y-size.y*0.5f), vsx_vector3<>(size.x,size.y), dragborder);

  glColor4f(1,1,1,1);
  glMatrixMode(GL_MODELVIEW);
  glPushMatrix();
    glLoadIdentity();

    glTranslatef( 0, parentpos.y + size.y * 0.5, 0.0 );
    profiler->sub_begin("draw vbo bucket");

    draw_bucket_a.output();
    draw_bucket_b.output();
    profiler->sub_end();


  glPopMatrix();
  vsx_widget::i_draw();
}
Ejemplo n.º 2
0
void vsx_widget_profiler_thread::i_draw()
{
  vsx_vector3<> parentpos = get_pos_p();
  glBegin(GL_QUADS);
    vsx_widget_skin::get_instance()->set_color_gl(1);
    glVertex3f(parentpos.x-size.x*0.5f, parentpos.y+size.y*0.5f,pos.z);
    glVertex3f(parentpos.x+size.x*0.5f, parentpos.y+size.y*0.5f,pos.z);
    glVertex3f(parentpos.x+size.x*0.5f, parentpos.y+-size.y*0.5f,pos.z);
    glVertex3f(parentpos.x-size.x*0.5f, parentpos.y+-size.y*0.5f,pos.z);
  glEnd();
  vsx_widget_skin::get_instance()->set_color_gl(0);
  draw_box_border(vsx_vector3<>(parentpos.x-size.x*0.5,parentpos.y-size.y*0.5f), vsx_vector3<>(size.x,size.y), dragborder);

  glColor4f(1,1,1,1);
  glMatrixMode(GL_MODELVIEW);
  glPushMatrix();
    glLoadIdentity();

    glTranslatef( 0, parentpos.y + size.y * 0.5, 0.0 );
    profiler->sub_begin("draw vbo bucket");

    draw_bucket.output();
    profiler->sub_end();

    // green timeline
    glColor4f(0,1,0,1);
    glBegin(GL_LINES);
      glVertex2f( - 1000.0, -chunk_height + 0.001);
      glVertex2f(   1000.0, -chunk_height + 0.001);
    glEnd();



  if (selected_chunk != 0x0)
  {
    float depth = -(selected_chunk->depth + 1.0) * chunk_height;

    float cts = (selected_chunk->time_start ) * time_scale::get_instance()->time_scale_x + time_scale::get_instance()->time_offset;
    float cte = (selected_chunk->time_end )   * time_scale::get_instance()->time_scale_x + time_scale::get_instance()->time_offset;

    glColor4f(1, 0.25,0.25,0.95);
    glBegin(GL_LINES);
      glVertex2f( cts, depth);
      glVertex2f( cts, depth - chunk_height );

      glVertex2f( cts, depth - chunk_height );
      glVertex2f( cte, depth - chunk_height );

      glVertex2f( cte, depth - chunk_height );
      glVertex2f( cte, depth );

      glVertex2f( cte, depth );
      glVertex2f( cts, depth);
    glEnd();

  }
  draw_tags();
  glPopMatrix();
  vsx_widget::i_draw();
}
Ejemplo n.º 3
0
void vsx_widget_sequence_editor::i_draw()
{
  parentpos = get_pos_p();
  glBegin(GL_QUADS);
  vsx_widget_skin::get_instance()->set_color_gl(1);
    glVertex3f(parentpos.x-size.x*0.5f, parentpos.y+size.y*0.5f,pos.z);
    glVertex3f(parentpos.x+size.x*0.5f, parentpos.y+size.y*0.5f,pos.z);
    glVertex3f(parentpos.x+size.x*0.5f, parentpos.y+-size.y*0.5f,pos.z);
    glVertex3f(parentpos.x-size.x*0.5f, parentpos.y+-size.y*0.5f,pos.z);
  glEnd();
  vsx_widget_skin::get_instance()->set_color_gl(0);

  draw_box_border(vsx_vector3<>(parentpos.x-size.x*0.5,parentpos.y-size.y*0.5f), vsx_vector3<>(size.x,size.y), dragborder);

  font.color = vsx_color<>(1.0f,1.0f,1.0f,0.7f);
//  font.print(vsx_vector3<>(parentpos.x-size.x*0.5+0.3f,parentpos.y+size.y*0.5f-0.018f), name,0.01);
  font.color = vsx_color<>(1.0f,1.0f,1.0f,1.0f);

  vsx_widget::i_draw();
}
Ejemplo n.º 4
0
void vsx_widget_timeline::i_draw() {
  parentpos = parent->get_pos_p();
	float time_diff = owner->tend - owner->tstart;
  totalsize = (owner->tend - owner->tstart);

  float y_mid = parentpos.y+pos.y;
  float y_size = size.y;
  if (a_focus == this) y_size *= 3.0f;
  float y_size_half = y_size * 0.5f;

  if (auto_move_dir) {
    //float c_time = owner->curtime;
    float curtime = owner->curtime + auto_move_dir*dtime*time_diff*10.0f*a_dist;//totalsize*0.01;
    float tstart = owner->tstart + auto_move_dir*dtime*time_diff*10.0f*a_dist;//totalsize*0.01;
    float tend = owner->tend + auto_move_dir*dtime*time_diff*10.0f*a_dist;//totalsize*0.01;
    if (curtime >= 0) {
      owner->curtime = curtime;
      owner->tstart = tstart;
      owner->tend = tend;
    }
    command_q_b.add_raw("time_set "+f2s(owner->curtime));
    parent->vsx_command_queue_b(this);
  }

 	glBegin(GL_QUADS);
    if (owner->tstart < 0) {
   	  glColor4f(0.4,0.3,0.3f,0.5f);
   	  ff = size.x*(fabs(owner->tstart)/totalsize);
  		glVertex2f(parentpos.x+pos.x-size.x*0.5f, y_mid+y_size_half);
  		glVertex2f(parentpos.x+pos.x-size.x*0.5f+ff, y_mid+y_size_half);
  		glVertex2f(parentpos.x+pos.x-size.x*0.5f+ff, y_mid-y_size_half);
  		glVertex2f(parentpos.x+pos.x-size.x*0.5f, y_mid-y_size_half);
      if (owner->tend > 0) {
    	  glColor4f(0.3,0.4,0.3,0.5f);
    		glVertex2f(parentpos.x+pos.x-size.x*0.5f+ff, y_mid+y_size_half);
    		glVertex2f(parentpos.x+pos.x+size.x*0.5f, y_mid+y_size_half);
    		glVertex2f(parentpos.x+pos.x+size.x*0.5f, y_mid-y_size_half);
    		glVertex2f(parentpos.x+pos.x-size.x*0.5f+ff, y_mid-y_size_half);
      }
    } else {
   	  glColor4f(0.3,0.4,0.3,0.5f);
  		glVertex2f(parentpos.x+pos.x-size.x*0.5f, y_mid+y_size_half);
  		glVertex2f(parentpos.x+pos.x+size.x*0.5f, y_mid+y_size_half);
  		glVertex2f(parentpos.x+pos.x+size.x*0.5f, y_mid-y_size_half);
  		glVertex2f(parentpos.x+pos.x-size.x*0.5f, y_mid-y_size_half);
    }
	glEnd();

  if (a_focus == this) {
 	  glColor3f(1.0f,1.0f,1.0f);
  } else
  glColor3f(0.5f,0.5f,0.5f);
  draw_box_border(vsx_vector(parentpos.x+pos.x-size.x*0.5,y_mid-y_size_half), vsx_vector(size.x,y_size), dragborder*0.5);

  levelstart = ((float)z_round(owner->tstart) - owner->tstart)/totalsize;
  //printf("levelstart: %f\n",levelstart);
  levelstart = 0;

  myf.color.a = 0.8f;

  float one_div_totalsize_times_sizex = 1.0f / totalsize * size.x;
	for (int i = (int)owner->tstart; i < (int)(owner->tend)+1; ++i)
	{
    glColor3f(0.5,0.5,0.5);
    float x =  (float)(i-owner->tstart) * one_div_totalsize_times_sizex;
    if (x > 0)
    {
      x += parentpos.x+pos.x - size.x*0.5f+levelstart*size.x;
      glBegin(GL_LINES);
        glVertex2f(x,y_mid+y_size*0.416666667f);
        glVertex2f(x,y_mid-y_size*0.416666667f);
      glEnd();
      myf.print_center(vsx_vector(x,y_mid), i2s(i),0.005);
    }
	}

  glColor3f(1,1,1);
  float f = ((owner->curtime-owner->tstart)/(owner->tend-owner->tstart))*size.x;
  glBegin(GL_LINES);
    glVertex2f(parentpos.x+pos.x-size.x*0.5f+f,y_mid+y_size*0.416666667);
    glVertex2f(parentpos.x+pos.x-size.x*0.5f+f,y_mid-y_size*0.416666667);
  glEnd();

  // ************************************************************
  // sound waveform display
	// ************************************************************
  if (show_wave_data)
  {
		vsx_widget_server* server = (vsx_widget_server*)owner->get_server();
		vsx_engine* engine = (vsx_engine*)(server->engine);

		if (engine->engine_info.param_float_arrays.size() >= 4 && a_focus == this)
		{
			vsx_engine_float_array *full_pcm_data_l;
			vsx_engine_float_array *full_pcm_data_r;
			full_pcm_data_l = engine->engine_info.param_float_arrays[2];
			full_pcm_data_r = engine->engine_info.param_float_arrays[3];
			if (full_pcm_data_l->array.size() > 0)
			{
				// assuming we have 44100 samples per second
				float x_start = parentpos.x+pos.x-size.x*0.5f;
				float x_end   = parentpos.x+pos.x+size.x*0.5f;
				float t_start = owner->tstart;
				float t_end = owner->tend;
				size_t data_end = (size_t) (t_end * 44100.0f);
				if (owner->tstart < 0)
				{
					x_start += fabs(t_start / (t_end - t_start)) * size.x;
					//data_end -= fabs(t_start) * 44100.0f;
					t_start = 0.0f;
				}
				size_t data_start = (size_t) (t_start * 44100.0f);

				size_t data_count = data_end - data_start;
				float x_dist = x_end - x_start;
				double x_diff = (double)x_dist / (double)data_count;

	//			printf("data_start: %d\n", data_start);
				//printf("data_end: %d\n", data_end);
				//printf("data_count: %d\n", data_count);

				glColor4f(1.0f,0.2f,0.2f,0.15f);
				double x_pos = x_start;
				glBegin(GL_LINE_STRIP);
					for (
								size_t i = data_start;
								i < data_end;
								i++
							)
					{
						glVertex2f(x_pos, y_mid + (*full_pcm_data_l).array[i] * y_size_half );
						x_pos += x_diff;
					}
				glEnd();


				glColor4f(0.2f,1.0f,0.2f,0.1f);
				x_pos = x_start;
				glBegin(GL_LINE_STRIP);
					for (
								size_t i = data_start;
								i < data_end;
								i++
							)
					{
						glVertex2f(x_pos, y_mid + (*full_pcm_data_r).array[i] * y_size_half );
						x_pos += x_diff;
					}
				glEnd();
			} // pcm data pool size
		}
  }

	vsx_widget::i_draw();
}
Ejemplo n.º 5
0
int main (int argc, char ** argv) {
	init_sprite_png(0, "/usr/share/logo_login.png");
	init_shmemfonts();

	while (1) {
		syscall_print("Setup...\n");
		setup_windowing();

		int width  = wins_globals->server_width;
		int height = wins_globals->server_height;

		win_width = width;
		win_height = height;

		/* Do something with a window */
		window_t * wina = window_create(0,0, width, height);
		assert(wina);
		window_reorder (wina, 0); /* Disables movement */
		ctx = init_graphics_window_double_buffer(wina);

		for (int i = 0; i < LOGO_FINAL_OFFSET; ++i) {
			draw_fill(ctx, rgb(39,55,113));
			draw_sprite(ctx, sprites[0], center_x(sprites[0]->width), center_y(sprites[0]->height) - i);
			flip(ctx);
		}

		size_t buf_size = wina->width * wina->height * sizeof(uint32_t);
		char * buf = malloc(buf_size);

		uint32_t i = 0;

		uint32_t black = rgb(0,0,0);
		uint32_t white = rgb(255,255,255);
		uint32_t red   = rgb(240, 20, 20);

		int x_offset = 65;
		int y_offset = 64;

		int fuzz = 3;

		char username[INPUT_SIZE] = {0};
		char password[INPUT_SIZE] = {0};
		char hostname[512];

		{
			char _hostname[256];
			syscall_gethostname(_hostname);

			struct tm * timeinfo;
			struct timeval now;
			syscall_gettimeofday(&now, NULL); //time(NULL);
			timeinfo = localtime((time_t *)&now.tv_sec);

			char _date[256];
			strftime(_date, 256, "%a %B %d %Y", timeinfo);

			sprintf(hostname, "%s // %s", _hostname, _date);
		}

		char kernel_v[512];

		{
			struct utsname u;
			uname(&u);
			/* UTF-8 Strings FTW! */
			uint8_t * os_name_ = "PonyOS";
			uint32_t l = snprintf(kernel_v, 512, "%s %s", os_name_, u.release);
		}

		uid = 0;

#define BOX_WIDTH  272
#define BOX_HEIGHT 104
#define USERNAME_BOX 1
#define PASSWORD_BOX 2
#define EXTRA_TEXT_OFFSET 12
#define TEXTBOX_INTERIOR_LEFT 4
#define LEFT_OFFSET 80
		int box_x = center_x(BOX_WIDTH);
		int box_y = center_y(0) + 8;

		int focus = USERNAME_BOX;

		set_font_size(11);

		int username_label_left = LEFT_OFFSET - 2 - draw_string_width("Username:"******"Password:"******"");
				for (int i = 0; i < strlen(password); ++i) {
					strcat(password_circles, "●");
				}

				/* Redraw the background */
				draw_fill(ctx, rgb(39,55,113));
				draw_sprite(ctx, sprites[0], center_x(sprites[0]->width), center_y(sprites[0]->height) - LOGO_FINAL_OFFSET);

				draw_string(ctx, hostname_label_left, height - 12, white, hostname);
				draw_string(ctx, kernel_v_label_left, height - 12, white, kernel_v);

				/* Draw backdrops */
				draw_box(ctx, box_x, box_y, BOX_WIDTH, BOX_HEIGHT, rgb(180,124,205));
				draw_box(ctx, box_x + LEFT_OFFSET, box_y + 32, 168, 16, rgb(255,255,255));
				draw_box(ctx, box_x + LEFT_OFFSET, box_y + 56, 168, 16, rgb(255,255,255));

				/* Draw labels */
				draw_string(ctx, box_x + username_label_left, box_y + 32 + EXTRA_TEXT_OFFSET, white, "Username:"******"Password:"******"Incorrect username or password.";
					
					draw_string(ctx, box_x + (BOX_WIDTH - draw_string_width(error_message)) / 2, box_y + 8 + EXTRA_TEXT_OFFSET, red, error_message);
				}

				if (focus == USERNAME_BOX) {
					draw_box_border(ctx, box_x + LEFT_OFFSET, box_y + 32, 168, 16, rgb(229, 68, 138));
				} else if (focus == PASSWORD_BOX) {
					draw_box_border(ctx, box_x + LEFT_OFFSET, box_y + 56, 168, 16, rgb(229, 68, 138));
				}

				flip(ctx);

				w_keyboard_t * kbd = NULL;
				do {
					kbd = poll_keyboard();
				} while (!kbd);

				if (kbd->key == '\n') {
					if (focus == USERNAME_BOX) {
						free(kbd);
						focus = PASSWORD_BOX;
						continue;
					} else if (focus == PASSWORD_BOX) {
						free(kbd);
						break;
					}
				}

				if (kbd->key == '\t') {
					if (focus == USERNAME_BOX) {
						focus = PASSWORD_BOX;
					} else if (focus == PASSWORD_BOX) {
						focus = USERNAME_BOX;
					}
					free(kbd);
					continue;
				}

				if (focus == USERNAME_BOX) {
					buffer_put(username, kbd->key);
				} else if (focus == PASSWORD_BOX) {
					buffer_put(password, kbd->key);
				}
				free(kbd);

			}

			uid = checkUserPass(username, password);

			if (uid >= 0) {
				break;
			}
			show_error = 1;
		}

		draw_fill(ctx, rgb(39,55,113));
		draw_sprite(ctx, sprites[0], center_x(sprites[0]->width), center_y(sprites[0]->height) - LOGO_FINAL_OFFSET);
		flip(ctx);

		teardown_windowing();

		pid_t _session_pid = fork();
		if (!_session_pid) {
			setenv("PATH", "/usr/bin:/bin", 0);
			syscall_setuid(uid);
			char * args[] = {"/bin/gsession", NULL};
			execvp(args[0], args);
		}

		free(buf);
		free(ctx->backbuffer);
		free(ctx);

		syscall_wait(_session_pid);
	}

	return 0;
}