Esempio n. 1
0
enum piglit_result
piglit_display(void)
{
	GLuint tex;
	GLboolean pass = GL_TRUE;

	glClearColor(0, 0, 0, 0);
	glClear(GL_COLOR_BUFFER_BIT);

	tex = create_texture(GL_COMPRESSED_RGB_S3TC_DXT1_EXT);
	display_mipmaps(10, 10 + (10 + SIZE) * 0);
	glDeleteTextures(1, &tex);
	tex = create_texture(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT);
	display_mipmaps(10, 10 + (10 + SIZE) * 1);
	glDeleteTextures(1, &tex);
	tex = create_texture(GL_COMPRESSED_RGBA_S3TC_DXT3_EXT);
	display_mipmaps(10, 10 + (10 + SIZE) * 2);
	glDeleteTextures(1, &tex);
	tex = create_texture(GL_COMPRESSED_RGBA_S3TC_DXT5_EXT);
	display_mipmaps(10, 10 + (10 + SIZE) * 3);
	glDeleteTextures(1, &tex);

	pass = pass && check_resulting_mipmaps(10, 10 + (10 + SIZE) * 0);
	pass = pass && check_resulting_mipmaps(10, 10 + (10 + SIZE) * 1);
	pass = pass && check_resulting_mipmaps(10, 10 + (10 + SIZE) * 2);
	pass = pass && check_resulting_mipmaps(10, 10 + (10 + SIZE) * 3);

	glutSwapBuffers();

	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
void opengl_init(int w, int h)
{
	/* init statue *********************************************************************************/
	LOGI("begin load shader");
	shader_loader vs, ps;
	quad_mesh.program = new shader_program;
	if(!quad_mesh.program->build(vs.load_shader_source("media/flame.vs"),ps.load_shader_source("media/flame.ps")))
	{
		LOGI("build shader failed");
		return;
	}

	quad_mesh.texs_idxs[0] = create_texture("media/FireBase.tga", GL_CLAMP_TO_EDGE);
	quad_mesh.texs_idxs[1] = create_texture("media/FireDistortion.tga",GL_REPEAT);
	quad_mesh.texs_idxs[2] = create_texture("media/FireOpacity.tga",GL_CLAMP_TO_EDGE);

	quad_mesh.attribute_locations[static_mesh::POSITION] = glGetAttribLocation(quad_mesh.program->get_program(),"rm_Vertex");
	quad_mesh.attribute_locations[static_mesh::TEXCOORD] = glGetAttribLocation(quad_mesh.program->get_program(),"rm_TexCoord0");

	quad_mesh.loc_time = glGetUniformLocation(quad_mesh.program->get_program(),"time_0_X");
	quad_mesh.texs_locs[0] = glGetUniformLocation(quad_mesh.program->get_program(),"fire_base");
	quad_mesh.texs_locs[1] = glGetUniformLocation(quad_mesh.program->get_program(),"fire_distortion");
	quad_mesh.texs_locs[2] = glGetUniformLocation(quad_mesh.program->get_program(),"fire_opacity");

	float*pos, *texcoord;
	unsigned short *indx;
	GLuint num_vertexs;
	GLuint num_index;

	num_index = shape::create_plane(1, &pos, NULL, &texcoord, &indx, num_vertexs);

	glGenBuffers(4, quad_mesh.attribute_vbos);

	glBindBuffer(GL_ARRAY_BUFFER, quad_mesh.attribute_vbos[static_mesh::POSITION]);
	glBufferData(GL_ARRAY_BUFFER, 4*3*num_vertexs, pos, GL_STATIC_DRAW);

	glBindBuffer(GL_ARRAY_BUFFER, quad_mesh.attribute_vbos[static_mesh::TEXCOORD]);
	glBufferData(GL_ARRAY_BUFFER, 4*2*num_vertexs, texcoord, GL_STATIC_DRAW);

	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, quad_mesh.attribute_vbos[static_mesh::INDEX]);
	glBufferData(GL_ELEMENT_ARRAY_BUFFER, 2*num_index, indx, GL_STATIC_DRAW);

	quad_mesh.num_faces = num_index/3;

	delete []pos;
	delete []texcoord;
	delete []indx;

	glViewport(0,0,w,h);
}
Esempio n. 3
0
enum piglit_result
piglit_display(void)
{
	bool pass = true;
	GLuint tex;
	int i;

	tex = create_texture();

	clear_texture(tex);

	glBindTexture(GL_TEXTURE_CUBE_MAP, tex);

	draw_faces();

	glBindTexture(GL_TEXTURE_CUBE_MAP, 0);

	glDeleteTextures(1, &tex);

	for (i = 0; i < 6; i++)
		pass &= piglit_probe_pixel_rgb(i, 0, faces[i].color);

	piglit_present_results();

	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
Esempio n. 4
0
bgfx_texture* texture_manager::create_png_texture(std::string path, std::string file_name, std::string texture_name, uint32_t flags, uint32_t screen)
{
	bitmap_argb32 bitmap;
	emu_file file(path.c_str(), OPEN_FLAG_READ);
	render_load_png(bitmap, file, nullptr, file_name.c_str());

	if (bitmap.width() == 0 || bitmap.height() == 0)
	{
		printf("Unable to load PNG '%s' from path '%s'\n", path.c_str(), file_name.c_str());
		return nullptr;
	}

	uint8_t *data = new uint8_t[bitmap.width() * bitmap.height() * 4];
	uint32_t *data32 = reinterpret_cast<uint32_t *>(data);

	const uint32_t width = bitmap.width();
	const uint32_t height = bitmap.height();
	const uint32_t rowpixels = bitmap.rowpixels();
	uint32_t* base = reinterpret_cast<uint32_t *>(bitmap.raw_pixptr(0));
	for (int y = 0; y < height; y++)
	{
		copy_util::copyline_argb32(data32 + y * width, base + y * rowpixels, width, nullptr);
	}

	if (screen >= 0)
	{
		texture_name += std::to_string(screen);
	}
	bgfx_texture* texture = create_texture(texture_name, bgfx::TextureFormat::RGBA8, width, height, data, flags);

	delete [] data;

	return texture;
}
Esempio n. 5
0
NE_API void draw_text(font_text* text) {
	if (current_font_asset && text->text[0] != '\0') {
		font_asset* font = get_font(current_font_asset);
		SDL_Color color = { 255, 255, 255, 255 };
		SDL_Surface* surface = nullptr;
		TTF_Font* ttf = (TTF_Font*) font->resource_handle;
		if (text->wrap_length == 0) {
			surface = TTF_RenderUTF8_Blended(ttf, text->text.c_str(), color);
		} else {
			surface = TTF_RenderUTF8_Blended_Wrapped(ttf, text->text.c_str(), color, text->wrap_length);
		}
		if (text->texture.resource_handle == 0) {
			text->texture.resource_handle = create_texture();
		}
		load_texture_from_pixels(&text->texture, (uint32*) surface->pixels, surface->w, surface->h);
		text->old_text = text->text;
		text->text[0] = '\0';
		text->transform.scale = { (float) surface->w, (float) surface->h, 0.0f };
		SDL_FreeSurface(surface);
	}
	if (text->texture.resource_handle != 0 && text->old_text[0] != '\0' && text->text[0] == '\0') {
		set_model_matrix(&text->transform);
		bind_texture(&text->texture);
		draw_vertex_array(&shapes[current_shape].vertex_array);
	} 
}
Esempio n. 6
0
File: menu.c Progetto: telenc/wolf3d
void	init_load(t_wolf *wolf)
{
  void	*img;
  int	w;
  int	h;
  int	bpp;
  int	size_line;
  int	endian;

  wolf->screen = 1;
  w = 1000;
  h = 800;
  if (wolf->texture == NULL)
    {
      wolf->texture = my_malloc(sizeof(t_texture));
      wolf->texture->load = NULL;
      wolf->texture->wall_one = NULL;
    }
  if (wolf->texture->load == NULL)
    wolf->texture->load = create_texture("texture/load.xpm", wolf);
  if (wolf->texture->wall_one == NULL)
    init_texture(wolf);
  mlx_put_image_to_window(wolf->mlx, wolf->win,
			  wolf->texture->load->image, 0, 0);
}
void TextureCollectionItem::slot_import_textures()
{
    const QStringList filepaths =
        get_open_filenames(
            treeWidget(),
            "Import Textures...",
            g_bitmap_files_filter,
            m_editor_context.m_settings,
            SETTINGS_FILE_DIALOG_PROJECTS);

    if (filepaths.empty())
        return;

    const filesystem::path path(
        QDir::toNativeSeparators(filepaths.first()).toStdString());

    // todo: schedule creation of texture and texture instances when rendering.
    for (int i = 0; i < filepaths.size(); ++i)
    {
        const string filepath = QDir::toNativeSeparators(filepaths[i]).toStdString();

        auto_release_ptr<Texture> texture = create_texture(filepath);
        auto_release_ptr<TextureInstance> texture_instance = create_texture_instance(texture->get_name());

        m_parent_item->add_item(texture.get());
        m_parent_item->add_item(texture_instance.get());

        m_parent.textures().insert(texture);
        m_parent.texture_instances().insert(texture_instance);

    }

    m_editor_context.m_project_builder.notify_project_modification();
}
Esempio n. 8
0
t_env			*init_env(void)
{
	t_env		*e;

	if (!(e = (t_env *)malloc(sizeof(t_env))))
		return (NULL);
	new_window(e);
	e->music = 0;
	e->posx = 3;
	e->posy = 5;
	e->dirx = -1;
	e->diry = 0;
	e->xmax = 0;
	e->ymax = 0;
	e->planex = 0;
	e->planey = 0.66;
	e->time = 0;
	e->oldtime = e->time;
	e->time = clock();
	e->fps = (e->time - e->oldtime) / 1000.0;
	e->movespeed = e->fps * 0.001;
	e->rotspeed = e->fps * 0.0005;
	e->tab = (int *)mlx_get_data_addr(e->img->img, &e->img->bpp, \
			&e->img->size_line, &e->img->endian);
	e->buffer = init_tab(e);
	e->texture = create_texture(e);
	return (e);
}
void PointCloudApplication::setup_video_texture() {
	assert(context.video_format == POINTCLOUD_BGRA_8888);
	
	video_texture = create_texture(NULL, context.video_width, context.video_height, true, GL_BGRA);

	// Setup geometry for the video overlay
	video_vertices[0] = 0;
	video_vertices[1] = context.viewport_height;
	video_vertices[2] = context.viewport_width;
	video_vertices[3] = context.viewport_height;
	video_vertices[4] = context.viewport_width;
	video_vertices[5] = 0;
	video_vertices[6] = 0;
	video_vertices[7] = 0;
	
	video_texcoords[0] = context.video_width  - context.video_crop_x;
	video_texcoords[1] = context.video_height - context.video_crop_y;
	video_texcoords[2] = context.video_width  - context.video_crop_x;
	video_texcoords[3] = context.video_crop_y;
	video_texcoords[4] = context.video_crop_x;
	video_texcoords[5] = context.video_crop_y;
	video_texcoords[6] = context.video_crop_x;
	video_texcoords[7] = context.video_height - context.video_crop_y;

	for (int i = 0; i < 8; i += 2) {
		video_texcoords[i] /= context.video_width;
		video_texcoords[i+1] /= context.video_height;
	}
}
Esempio n. 10
0
texture* gen_bush_fruiting_branches_texture(bush_appearance *appearance) {
  texture *result = create_texture(BLOCK_TEXTURE_SIZE, BLOCK_TEXTURE_SIZE);
  fltr_branches(result, &(appearance->thick_branches));
  fltr_leaves(result, &(appearance->leaves));
  fltr_leaves(result, &(appearance->fruit));
  return result;
}
Esempio n. 11
0
static bool
is_resource_supported(const test_data *data,
                      const GLenum pname,
                      const GLenum target,
                      const GLenum internalformat)
{
        GLuint tex;
        GLuint buffer;

        if (!check_query2_dependencies(pname, target))
                return false;

        if (!test_data_check_supported(data, target, internalformat))
                return false;

        if (target == GL_RENDERBUFFER)
                return is_supported_renderbuffer(target, internalformat);

        if (!create_texture(target, internalformat, &tex, &buffer))
                return false;

        glDeleteTextures(1, &tex);
        glDeleteBuffers(1, &buffer);

        return true;
}
Esempio n. 12
0
enum piglit_result
piglit_display(void)
{
	GLboolean pass = GL_TRUE;
	int dim;
	GLuint tex;
	int x;

	glClearColor(0.5, 0.5, 0.5, 0.5);
	glClear(GL_COLOR_BUFFER_BIT);

	tex = create_texture();

	x = 1;
	for (dim = TEX_WIDTH; dim > 1; dim /= 2) {
		draw_mipmap(x, 1, dim);
		x += dim + 1;
	}

	x = 1;
	for (dim = TEX_WIDTH; dim > 1; dim /= 2) {
		pass &= test_mipmap_drawing(x, 1, dim);
		x += dim + 1;
	}

	glDeleteTextures(1, &tex);

	piglit_present_results();

	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
Esempio n. 13
0
void run_grammar(tx_grammar_literal *lit) {
  size_t i;
  int row, col;
  pixel px;
  tx_grammar_literal *chosen = NULL;
  tx_grammar_expansion_site *ges = NULL;
  // Create a list of expansion sites:
  list *expansion_sites = create_list();
  // Start by loading our source file into our result texture and calling our
  // pre-processing filter if we have one:
  if (lit->filename == NULL) {
    if (lit->anchor_x == 0 || lit->anchor_y == 0) {
      fprintf(
        stderr,
        "Error: grammar with NULL filename must have nonzero anchor values.\n"
      );
      fprintf(stderr, "(found: %zu, %zu)\n", lit->anchor_x, lit->anchor_y);
      exit(EXIT_FAILURE);
    }
    lit->result = create_texture(lit->anchor_x, lit->anchor_y);
  } else {
    lit->result = load_texture_from_png(lit->filename);
  }
  if (lit->preprocess != NULL) {
    (*(lit->preprocess))(lit->result, lit->preargs);
  }
  // Now expand each child reference at random. Note that due to the low
  // resolution of the pseudo-random process, any item with a weight of less
  // than 1/65536th of the total weight of all items in a disjunction will
  // never be picked.
  for (col = 0; col < lit->result->width; ++col) {
    for (row = 0; row < lit->result->height; ++row) {
      px = tx_get_px(lit->result, col, row);
      for (i = 0; i < N_GRAMMAR_KEYS; ++i) {
        if (px == GRAMMAR_KEYS[i] && lit->children[i] != NULL) {
          chosen = choose_child(
            lit->children[i],
            hash_3d(hash_2d(hash_1d((ptrdiff_t) lit), i), col, row)
          );
          if (chosen->result == NULL) {
            run_grammar(chosen);
          }
          ges = create_expansion_site();
          ges->col = col;
          ges->row = row;
          ges->literal = chosen;
          l_append_element(expansion_sites, ges);
          ges = NULL; // destroy_list later on takes care of the memory used.
        }
      }
    }
  }
  l_witheach(expansion_sites, (void *) lit, expand_literal_into);
  // Clean up our list of expansion sites:
  destroy_list(expansion_sites);
  // Before wrapping up call our post-processing function if it exists:
  if (lit->postprocess != NULL) {
    (*(lit->postprocess))(lit->result, lit->postargs);
  }
}
ParticleController::ParticleController(ParticleEmitter* emitter, ParticleType c_type)
    : ParticleRenderer(), ParticleEmitter(*emitter) {
    set_emitter_parent(this);
    set_renderer_parent(this);
    type = c_type;
    create_texture();
}
Esempio n. 15
0
int main(int argc, char **argv)
{
    int q;
    int start, end;

    printf("Initializing EGL...\n");

    if(!init_gl_surface())
    {
        printf("GL initialisation failed - exiting\n");
        return 0;
    }

    init_scene();

    create_texture();

    printf("Start test...\n");

    render(argc==2 ? atoi(argv[1]) : ITERATIONS);

    free_gl_surface();

    return 0;
}
Esempio n. 16
0
void st_resize_framebuffer(struct st_framebuffer *stfb,
                           uint width, uint height)
{
   struct vg_context *ctx = vg_current_context();
   struct st_renderbuffer *strb = stfb->strb;
   struct pipe_framebuffer_state *state;

   if (!ctx)
      return;

   state = &ctx->state.g3d.fb;

   /* If this is a noop, exit early and don't do the clear, etc below.
    */
   if (strb->width == width &&
       strb->height == height &&
       state->zsbuf)
      return;

   if (strb->width != width || strb->height != height)
      st_renderbuffer_alloc_storage(ctx, strb,
                                 width, height);

   if (stfb->dsrb->width != width || stfb->dsrb->height != height)
      st_renderbuffer_alloc_storage(ctx, stfb->dsrb,
                                 width, height);

   {
      VGuint i;

      memset(state, 0, sizeof(struct pipe_framebuffer_state));

      state->width  = width;
      state->height = height;

      state->nr_cbufs = 1;
      state->cbufs[0] = strb->surface;
      for (i = 1; i < PIPE_MAX_COLOR_BUFS; ++i)
         state->cbufs[i] = 0;

      state->zsbuf = stfb->dsrb->surface;

      cso_set_framebuffer(ctx->cso_context, state);
   }

   ctx->state.dirty |= VIEWPORT_DIRTY;
   ctx->state.dirty |= DEPTH_STENCIL_DIRTY;/*to reset the scissors*/

   ctx->pipe->clear(ctx->pipe, PIPE_CLEAR_DEPTHSTENCIL,
                    NULL, 0.0, 0);

   /* we need all the other state already set */

   setup_new_alpha_mask(ctx, stfb, width, height);

   pipe_texture_reference( &stfb->blend_texture, NULL );
   stfb->blend_texture = create_texture(ctx->pipe, PIPE_FORMAT_A8R8G8B8_UNORM,
                                        width, height);
}
Esempio n. 17
0
int main(int argc, char** argv)
{
    int x, y, width;
    GLuint texture;

    glfwSetErrorCallback(error_callback, NULL);

    if (!glfwInit())
        exit(EXIT_FAILURE);

    windows[0] = open_window("First", NULL, OFFSET, OFFSET);
    if (!windows[0])
    {
        glfwTerminate();
        exit(EXIT_FAILURE);
    }

    // This is the one and only time we create a texture
    // It is created inside the first context, created above
    // It will then be shared with the second context, created below
    texture = create_texture();

    glfwGetWindowPos(windows[0], &x, &y);
    glfwGetWindowSize(windows[0], &width, NULL);

    // Put the second window to the right of the first one
    windows[1] = open_window("Second", windows[0], x + width + OFFSET, y);
    if (!windows[1])
    {
        glfwTerminate();
        exit(EXIT_FAILURE);
    }

    // Set drawing color for both contexts
    glfwMakeContextCurrent(windows[0]);
    glColor3f(0.6f, 0.f, 0.6f);
    glfwMakeContextCurrent(windows[1]);
    glColor3f(0.6f, 0.6f, 0.f);

    glfwMakeContextCurrent(windows[0]);

    while (!glfwWindowShouldClose(windows[0]) &&
           !glfwWindowShouldClose(windows[1]))
    {
        glfwMakeContextCurrent(windows[0]);
        draw_quad(texture);

        glfwMakeContextCurrent(windows[1]);
        draw_quad(texture);

        glfwSwapBuffers(windows[0]);
        glfwSwapBuffers(windows[1]);

        glfwWaitEvents();
    }

    glfwTerminate();
    exit(EXIT_SUCCESS);
}
Esempio n. 18
0
void
initGl ()
{
    int zero = 0;
    glutInit (&zero, NULL);
    glewInit ();

    glClearColor (0.0f, 0.0f, 0.0f, 0.0f);
    glClearDepth (1.0);
    glDepthFunc (GL_LESS);
    glEnable (GL_DEPTH_TEST);
    glShadeModel (GL_SMOOTH);

    GLfloat light_ambient[] = {0.5f, 0.5f, 0.5f, 1.0f};
    GLfloat light_diffuse[] = {0.4f, 0.4f, 0.3f, 1.0f};
    GLfloat light_position[] = {0.0f, 1.0f, 2.0f, 1.0f};

    glLightfv (GL_LIGHT1, GL_AMBIENT, light_ambient);
    glLightfv (GL_LIGHT1, GL_DIFFUSE, light_diffuse);
    glLightfv (GL_LIGHT1, GL_POSITION, light_position);
    glEnable (GL_LIGHT1);
    glEnable (GL_LIGHTING);

    glColorMaterial (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
    glEnable (GL_COLOR_MATERIAL);

    map_image_texture_id = create_texture ();

    glGenBuffers (1, &laser_buffer_id);
    glBindBuffer (GL_ARRAY_BUFFER, laser_buffer_id);

    laser_pos_buffer = NULL;

    glMatrixMode (GL_PROJECTION);
    glLoadIdentity ();

    gluPerspective (45.0f, WINDOW_WIDTH / WINDOW_HEIGHT, 0.1f, 4000.0f); // Calculate The Aspect Ratio Of The Window

    carmen_pose_3D_t zero_pose;
    zero_pose.position.x = 0.0;
    zero_pose.position.y = 0.0;
    zero_pose.position.z = 0.0;
    zero_pose.orientation.roll = 0.0;
    zero_pose.orientation.pitch = 0.0;
    zero_pose.orientation.yaw = 0.0;

    camera_pose = zero_pose;
    camera_offset = zero_pose;

    camera_pose.position.z = 30.0;
    camera_pose.orientation.pitch = carmen_degrees_to_radians (90.0);

    background_r = 0.0;
    background_g = 0.0;
    background_b = 0.0;

    glMatrixMode (GL_MODELVIEW);

}
Esempio n. 19
0
NE_API void load_texture_asset(texture_asset* texture) {
	texture->resource_handle = create_texture();
	if (texture->pixels) {
		load_texture_from_pixels(texture, texture->pixels, texture->size.x, texture->size.y);
	} else {
		load_texture_from_file(texture);
	}
}
Esempio n. 20
0
bool PXL_Texture::create_texture(std::string file_path) {
	//creates a bitmap from the specified file path and checks if it is valid
	PXL_Bitmap bitmap;
	if (bitmap.create_bitmap(file_path)) {
		//if valid, create the texture from the bitmap and delete it afterwards
		bool success = create_texture(&bitmap);
		delete &bitmap;
		return success;
	}
	return false;
}
Esempio n. 21
0
bool PXL_Texture::create_texture(PXL_Bitmap* bitmap) {
	texture_created = false;
	if (bitmap != NULL) {
        has_transparency = bitmap->has_transparency;
		create_texture(bitmap->get_width(), bitmap->get_height(), bitmap->get_pixels(), bitmap->get_channel());
		texture_created = true;
	}else {
		PXL_show_exception("Could not create texture, specified bitmap is NULL", PXL_ERROR_TEXTURE_CREATION_FAILED);
	}
	return texture_created;
}
Esempio n. 22
0
void rows_init(void)
{
	create_texture(&row_texes[0], width, height, create_row0);
	create_texture(&row_texes[1], width, height, create_row1);
	create_texture(&row_texes[2], width, height, create_row2);
	create_texture(&row_texes[3], width, height, create_row3);
	create_texture(&row_texes[4], width, height, create_row4);
	create_texture(&row_texes[5], width, height, create_row5);
	create_texture(&row_texes[6], width, height, create_row6);
	register_event("draw opaque", draw_rows);
}
Esempio n. 23
0
BC_Texture::BC_Texture(int w, int h, int colormodel)
{
	this->w = w;
	this->h = h;
	this->colormodel = colormodel;
	texture_id = -1;
	texture_id = -1;
	texture_w = 0;
	texture_h = 0;
	texture_components = 0;
	window_id = -1;
	create_texture(w, h, colormodel);
}
Esempio n. 24
0
void init(const char *sphereFile)
{
  static GLfloat lightpos[] = {.5, .75, 1.5, 1};

  glEnable(GL_DEPTH_TEST); 
  glEnable(GL_LIGHTING);
  glEnable(GL_LIGHT0);

  glLightfv(GL_LIGHT0, GL_POSITION, lightpos);

    create_texture(sphereFile, &sphereTexW, &sphereTexH, 
		   &padSphereTexW, &padSphereTexH, &sphereTexComp);
}
Esempio n. 25
0
enum piglit_result
piglit_display(void)
{
	bool pass = true;
	GLuint tex;

	tex = create_texture();

	clear_texture(tex);

	draw_tex(tex);

	glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, 0);

	glDeleteTextures(1, &tex);

	pass &= piglit_probe_rect_rgb(VALUE_CLEAR_X * 2,
				      VALUE_CLEAR_Y * 2,
				      VALUE_CLEAR_WIDTH * 2,
				      VALUE_CLEAR_HEIGHT * 2,
				      green);

	pass &= piglit_probe_rect_rgb(ZERO_CLEAR_X * 2,
				      ZERO_CLEAR_Y * 2,
				      ZERO_CLEAR_WIDTH * 2,
				      ZERO_CLEAR_HEIGHT * 2,
				      black);

	/* Everything else should be red */

	pass &= probe_tex(0, 0,
			  TEX_WIDTH, ZERO_CLEAR_Y);
	pass &= probe_tex(0, ZERO_CLEAR_Y,
			  ZERO_CLEAR_X, ZERO_CLEAR_HEIGHT);
	pass &= probe_tex(ZERO_CLEAR_X + ZERO_CLEAR_WIDTH, ZERO_CLEAR_Y,
			  TEX_WIDTH - ZERO_CLEAR_X - ZERO_CLEAR_WIDTH,
			  ZERO_CLEAR_HEIGHT);
	pass &= probe_tex(0, VALUE_CLEAR_Y,
			  VALUE_CLEAR_X, VALUE_CLEAR_HEIGHT);
	pass &= probe_tex(VALUE_CLEAR_X + VALUE_CLEAR_WIDTH, VALUE_CLEAR_Y,
			  TEX_WIDTH - VALUE_CLEAR_X - VALUE_CLEAR_WIDTH,
			  VALUE_CLEAR_HEIGHT);
	pass &= probe_tex(0, VALUE_CLEAR_Y + VALUE_CLEAR_HEIGHT,
			  TEX_WIDTH,
			  TEX_HEIGHT - VALUE_CLEAR_Y - VALUE_CLEAR_HEIGHT);

	piglit_present_results();

	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
}
Esempio n. 26
0
static GLuint
create_fbo(const struct fmt_test *test, GLuint *tex)
{
	GLuint fbo;
	GLuint fbo_tex = create_texture(test);

	*tex = fbo_tex;

	glGenFramebuffers(1, &fbo);
	glBindFramebuffer(GL_FRAMEBUFFER, fbo);
	glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
			       GL_TEXTURE_2D, fbo_tex, 0);
	return fbo;
}
Esempio n. 27
0
void
test_alpha_test (void)
{
    CoglTexture *tex = COGL_TEXTURE (create_texture (test_ctx));
    CoglPipeline *pipeline = cogl_pipeline_new (test_ctx);
    int fb_width = cogl_framebuffer_get_width (test_fb);
    int fb_height = cogl_framebuffer_get_height (test_fb);
    CoglColor clear_color;

    cogl_pipeline_set_layer_texture (pipeline, 0, tex);
    cogl_pipeline_set_layer_filters (pipeline, 0,
                                     COGL_PIPELINE_FILTER_NEAREST,
                                     COGL_PIPELINE_FILTER_NEAREST);
    cogl_pipeline_set_alpha_test_function (pipeline,
                                           COGL_PIPELINE_ALPHA_FUNC_GEQUAL,
                                           254 / 255.0f /* alpha reference */);

    cogl_color_init_from_4ub (&clear_color, 0x00, 0x00, 0xff, 0xff);
    cogl_framebuffer_clear (test_fb,
                            COGL_BUFFER_BIT_COLOR,
                            &clear_color);

    cogl_framebuffer_draw_rectangle (test_fb,
                                     pipeline,
                                     -1, -1,
                                     1, 1);

    cogl_object_unref (pipeline);
    cogl_object_unref (tex);

    /* The left side of the framebuffer should use the first pixel from
     * the texture which is red */
    test_utils_check_region (test_fb,
                             2, 2,
                             fb_width / 2 - 4,
                             fb_height - 4,
                             0xff0000ff);
    /* The right side of the framebuffer should use the clear color
     * because the second pixel from the texture is clipped from the
     * alpha test */
    test_utils_check_region (test_fb,
                             fb_width / 2 + 2,
                             2,
                             fb_width / 2 - 4,
                             fb_height - 4,
                             0x0000ffff);

    if (cogl_test_verbose ())
        g_print ("OK\n");
}
Esempio n. 28
0
/*
 * Creates and returns a texture based on a bundled image filename
 */
GLuint read_png_texture(const char *name, bool pixel_texture) {
	char *data = NULL;
	int width = 0; 
	int height= 0;
	
	bool success = read_png_image(name,&data,&width,&height);
	
	if (!success)
		return 0;
	
	GLuint texture_object = create_texture(data, width, height, pixel_texture);
	delete data;
	
	return texture_object;
}
Esempio n. 29
0
enum piglit_result
piglit_display(void)
{
	GLuint tex;
	GLboolean pass = GL_TRUE;
	const GLfloat *expected;
	int i, j;

	glClear(GL_COLOR_BUFFER_BIT);

	glEnableClientState(GL_VERTEX_ARRAY);
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);

	/* Do glCopyPixels and draw a textured rectangle for each format
	 * and each texture target
	 */
	for (j = 0; j < ARRAY_SIZE(target); j++) {
		if (test_target != -1 && test_target != j)
			continue;
		if (!supported_target(j))
			continue;

		printf("Testing %s\n", piglit_get_gl_enum_name(target[j].target));

		if (target[j].target == GL_TEXTURE_1D_ARRAY) {
			printf("NOTE: We use glCopyTexSubImage2D to set 4 texture layers at once.\n");
		}

		tex = create_texture(target[j].target);

		for (i = 0; i < ARRAY_SIZE(test_vectors); i++) {
			GLint x = IMAGE_SIZE * (i + 1);
			GLint y = 0;
			expected = (const float*)test_vectors[i].expected;

			if (!test_target_and_format(x, y, target[j].target,
						    test_vectors[i].format,
						    expected)) {
				pass = GL_FALSE;
			}
		}

		glDeleteTextures(1, &tex);
	}
	if (!piglit_automatic)
		piglit_present_results();
	return (pass ? PIGLIT_PASS : PIGLIT_FAIL);
}
Esempio n. 30
0
bool renderer::create()
{
	m_vformat_ID = m_video.spawn(m_vformat);
	m_memreader_ID = m_video.spawn(m_memreader);
	m_vbuffer_ID = m_video.spawn(m_vbuffer);
	m_video.get_<vo::vbuffer>(m_vbuffer_ID).set_source(m_memreader_ID);
	m_vshader_ID = m_video.spawn(m_vshader);
	m_pshader_ID = m_video.spawn(m_pshader);
	m_vbufset_ID = m_video.spawn(m_vbufset);
	m_video.get_<vo::vbufset>(m_vbufset_ID).set_vformat(m_vformat_ID);
	m_video.get_<vo::vbufset>(m_vbufset_ID).set_vbuffer(0, m_vbuffer_ID, 0, 4);
	m_states_ID = m_video.spawn(m_states);

	m_texset_ID = m_deftexset_ID = create_texture(video::tf::a8r8g8b8, &bad_ID, 1, 1, 4);

	return true;
}