ViewBackendIntelCE::ViewBackendIntelCE()
    : m_width(WIDTH)
    , m_height(HEIGHT)
{
    gdl_plane_id_t plane = GDL_PLANE_ID_UPP_C;
    gdl_init(0);
    setup_plane(plane);
}
示例#2
0
static void IntelCE_InitCursor()
{
	/* Initialize the gdl layer */
	gdl_plane_id_t plane = GDL_PLANE_ID_IAP_B;
    gdl_init(0);
    setup_plane(plane);
	return;
}
示例#3
0
int main(int argc, char *argv[])
{
  EGLDisplay display = EGL_NO_DISPLAY;
  EGLSurface surface = EGL_NO_SURFACE;
  EGLContext context = EGL_NO_CONTEXT;
  GLfloat rotation_x = 0;       /* angle for rotation in x direction */
  GLfloat rotation_y = 0;       /* angle for rotation in y direction */

  GLuint vertexShaderId = 0;     /* vertex shader id */
  GLuint fragmentShaderId = 0;   /* fragment shader id */
  GLuint programId = 0;          /* program id */
  int mvpLoc = 0;               /* for the uniform varible index value of  mvp matrix */
  int status;                    /* function call's return value */
  unsigned int frame_count = 0;

  gdl_init(0);

  setup_plane(GDL_PLANE_ID_UPP_B, true);
  status = setup_egl(GDL_PLANE_ID_UPP_B, &display, &surface, &context);
  if (status != GL_TRUE)
  {
    printf("error setting egl\n");
    return 1;
  }

  status = setup_gl(&programId, &vertexShaderId, &fragmentShaderId, &mvpLoc);
  if (status != GL_TRUE)
  {
    printf("error setting gl\n");
    return 1;
  }

  int frame = 0;

  struct timeval start;
  gettimeofday(&start, NULL);
  struct timeval now;
  struct timeval sub;
  int duration;

  while (1)
  {
    render(rotation_x, rotation_y, mvpLoc);
    eglSwapBuffers(display, surface);
    frame++;

    rotation_x += 5.0f;
    if (rotation_x > 360.0f)
    {
      rotation_x = 0.0f;
    }

    rotation_y += 2.0f;
    if (rotation_y > 360.0f)
    {
      rotation_y = 0.0f;
    }

    gettimeofday(&now, NULL);
 
    timeval_subtract(&sub, &now, &start);
    duration = (sub.tv_usec + sub.tv_sec*1000000) / 1000;

    if (duration > 5000)
    {    
        printf("CUBE FPS = %d\n", duration / frame);
        frame = 0;
        start = now;
    }
  }
}
示例#4
0
文件: map.c 项目: joshb/jabheightmap
/*
 * create an octree, load the heightmap, load all
 * map quads into object structures and place them
 * in the appropriate leaf nodes of the octree
 */
struct map *
load_map(const char *filename)
{
	unsigned int i, j, k;
	unsigned char *data;
	unsigned int width, height;
	int type;
	unsigned int tilesize = 8;
	float xydiv = 1.0f;
	float zdiv = 9.0f;
	static struct map map_structure;
	struct vertex vertices[4];
	struct object *o;
	struct plane_object *p;
	struct octree_node *on;

	/* data is a pointer to the raw rgb data of the heightmap */
	data = (unsigned char *)read_png(filename, &width, &height, &type);
	if(!data) {
		fprintf(stderr, "Error: Couldn't load heightmap %s\n", filename);
		return NULL;
	}

	map_structure.octree = new_octree_branch(NULL, -((float)width / xydiv), (float)width / xydiv, -((float)height / xydiv), (float)height / xydiv, -255.0f, 255.0f);
	if(!map_structure.octree) {
		fprintf(stderr, "Error: Couldn't create octree\n");
		free(data);
		return NULL;
	}

	snprintf(map_structure.skypic, 256, "data/sky.png");

	/*
	 * create map quads from heightmap; the z value of each
	 * point is taken from the pixel corresponding to the
	 * current position on the heightmap using the get_pixel
	 * function
	 */
	k = 0;
	for(i = 0; i < height - tilesize; i+= tilesize) {
		for(j = 0; j < width - tilesize; j += tilesize) {
			vertices[k].texcoord[0] = 0.25f * (j/tilesize % 4);
			vertices[k].texcoord[1] = 0.25f * (i/tilesize % 4);
			vertices[k].point[0] = (float)j / xydiv - (float)(width / 2) / xydiv;
			vertices[k].point[1] = (float)(i + tilesize) / xydiv - (float)(height / 2) / xydiv;
			vertices[k].point[2] = (float)get_pixel(data, j, i + tilesize, width) / zdiv;
			k++;

			vertices[k].texcoord[0] = 0.25f * ((j/tilesize % 4) + 1.0f);
			vertices[k].texcoord[1] = 0.25f * (i/tilesize % 4);
			vertices[k].point[0] = (float)(j + tilesize) / xydiv - (float)(width / 2) / xydiv;
			vertices[k].point[1] = (float)(i + tilesize) / xydiv - (float)(height / 2) / xydiv;
			vertices[k].point[2] = (float)get_pixel(data, j + tilesize, i + tilesize, width) / zdiv;
			k++;

			vertices[k].texcoord[0] = 0.25f * ((j/tilesize % 4) + 1.0f);
			vertices[k].texcoord[1] = 0.25f * ((i/tilesize % 4) + 1.0f);
			vertices[k].point[0] = (float)(j + tilesize) / xydiv - (float)(width / 2) / xydiv;
			vertices[k].point[1] = (float)i / xydiv - (float)(height / 2) / xydiv;
			vertices[k].point[2] = (float)get_pixel(data, j + tilesize, i, width) / zdiv;
			k++;

			vertices[k].texcoord[0] = 0.25f * (j/tilesize % 4);
			vertices[k].texcoord[1] = 0.25f * ((i/tilesize % 4) + 1.0f);
			vertices[k].point[0] = (float)j / xydiv - (float)(width / 2) / xydiv;
			vertices[k].point[1] = (float)i / xydiv - (float)(height / 2) / xydiv;
			vertices[k].point[2] = (float)get_pixel(data, j, i, width) / zdiv;
			k = 0;

			o = create_object(OBJ_PLANE);
			if(!o) {
				free(data);
				free_octree_branch(map_structure.octree);
				return NULL;
			}

			o->render_separately = 0;
			o->vertices = malloc(sizeof(struct vertex) * 4);
			if(!o->vertices) {
				fprintf(stderr, "Error: Couldn't allocate memory for heightmap vertices\n");	
				free(data);
				free_octree_branch(map_structure.octree);
				return NULL;
			}
			o->num_vertices = 4;
			memcpy(o->vertices, vertices, sizeof(struct vertex) * 4);

			p = (struct plane_object *)(o->aux);
			setup_plane(p->plane, o->vertices[0].point, o->vertices[1].point, o->vertices[2].point);
			p->minx = lowest(o->vertices[0].point[0], o->vertices[1].point[0],
			                 o->vertices[2].point[0], o->vertices[3].point[0]);
			p->maxx = highest(o->vertices[0].point[0], o->vertices[1].point[0],
			                 o->vertices[2].point[0], o->vertices[3].point[0]);
			p->miny = lowest(o->vertices[0].point[1], o->vertices[1].point[1],
			                 o->vertices[2].point[1], o->vertices[3].point[1]);
			p->maxy = highest(o->vertices[0].point[1], o->vertices[1].point[1],
			                 o->vertices[2].point[1], o->vertices[3].point[1]);
			p->minz = lowest(o->vertices[0].point[2], o->vertices[1].point[2],
			                 o->vertices[2].point[2], o->vertices[3].point[2]);
			p->maxz = highest(o->vertices[0].point[2], o->vertices[1].point[2],
			                 o->vertices[2].point[2], o->vertices[3].point[2]);

			on = get_octree_leaf_from_point(map_structure.octree, o->vertices[0].point);
			add_object_to_octree_node(on, o);
		}
	}

	free(data);
	fprintf(stderr, "%s loaded\n", filename);
	return &map_structure;
}