本文整理汇总了C++中create_texture函数的典型用法代码示例。如果您正苦于以下问题:C++ create_texture函数的具体用法?C++ create_texture怎么用?C++ create_texture使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_texture函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: piglit_display
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;
}
示例2: opengl_init
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);
}
示例3: piglit_display
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;
}
示例4: file
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;
}
示例5: draw_text
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);
}
}
示例6: init_load
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);
}
示例7: get_open_filenames
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();
}
示例8: return
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);
}
示例9: assert
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;
}
}
示例10: gen_bush_fruiting_branches_texture
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;
}
示例11: is_resource_supported
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;
}
示例12: piglit_display
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;
}
示例13: run_grammar
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);
}
}
示例14: ParticleRenderer
ParticleController::ParticleController(ParticleEmitter* emitter, ParticleType c_type)
: ParticleRenderer(), ParticleEmitter(*emitter) {
set_emitter_parent(this);
set_renderer_parent(this);
type = c_type;
create_texture();
}
示例15: main
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;
}