本文整理汇总了C++中create_texture函数的典型用法代码示例。如果您正苦于以下问题:C++ create_texture函数的具体用法?C++ create_texture怎么用?C++ create_texture使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_texture函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:nobled,项目名称:piglit,代码行数:31,代码来源:s3tc-texsubimage.c
示例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);
}
开发者ID:gaoguanglei,项目名称:Android-OpenGL-ES-2.0-Effects,代码行数:50,代码来源:main.cpp
示例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;
}
开发者ID:BNieuwenhuizen,项目名称:piglit,代码行数:26,代码来源:cube.c
示例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;
}
开发者ID:MASHinfo,项目名称:mame,代码行数:34,代码来源:texturemanager.cpp
示例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);
}
}
开发者ID:noctare,项目名称:NoctareEngine,代码行数:26,代码来源:opengl.cpp
示例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);
}
开发者ID:telenc,项目名称:wolf3d,代码行数:25,代码来源:menu.c
示例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();
}
开发者ID:docwhite,项目名称:appleseed,代码行数:34,代码来源:texturecollectionitem.cpp
示例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);
}
开发者ID:kwiessle,项目名称:wolf3d,代码行数:28,代码来源:init_env.c
示例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;
}
}
开发者ID:caomw,项目名称:iPhone-3D-scanner,代码行数:29,代码来源:PointCloudApplication.cpp
示例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;
}
开发者ID:solsword,项目名称:elf_forest,代码行数:7,代码来源:txg_plants.c
示例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;
}
开发者ID:chemecse,项目名称:piglit,代码行数:26,代码来源:max-dimensions.c
示例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;
}
开发者ID:BNieuwenhuizen,项目名称:piglit,代码行数:31,代码来源:generatemipmap.c
示例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);
}
}
开发者ID:solsword,项目名称:elf_forest,代码行数:60,代码来源:txgen.c
示例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();
}
开发者ID:fordream,项目名称:Project-Nintendo-Smack-down,代码行数:7,代码来源:ParticleController.cpp
示例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;
}
开发者ID:Jackeagle,项目名称:frameworks_base,代码行数:25,代码来源:tritex.c
示例16: st_resize_framebuffer
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);
}
开发者ID:emcmanus,项目名称:FlashMesa3D,代码行数:59,代码来源:vg_tracker.c
示例17: main
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);
}
开发者ID:deltaluca,项目名称:glfw,代码行数:59,代码来源:sharing.c
示例18: initGl
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);
}
开发者ID:LCAD-UFES,项目名称:carmen_lcad,代码行数:59,代码来源:GLDraw.c
示例19: load_texture_asset
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);
}
}
开发者ID:noctare,项目名称:NoctareEngine,代码行数:8,代码来源:opengl.cpp
示例20: create_texture
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;
}
开发者ID:fordream,项目名称:pxl2D,代码行数:11,代码来源:PXL_Texture.cpp
注:本文中的create_texture函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论