Bool NV10EXAPrepareComposite(int op, PicturePtr pict_src, PicturePtr pict_mask, PicturePtr pict_dst, PixmapPtr src, PixmapPtr mask, PixmapPtr dst) { ScrnInfoPtr pScrn = xf86Screens[dst->drawable.pScreen->myNum]; NVPtr pNv = NVPTR(pScrn); struct nouveau_channel *chan = pNv->chan; if (MARK_RING(chan, 128, 5)) return FALSE; pNv->alu = op; pNv->pspict = pict_src; pNv->pmpict = pict_mask; pNv->pdpict = pict_dst; pNv->pspix = src; pNv->pmpix = mask; pNv->pdpix = dst; /* Set dst format */ if (!setup_render_target(pNv, pict_dst, dst)) goto fail; /* Set src format */ if (!setup_texture(pNv, 0, pict_src, src)) goto fail; /* Set mask format */ if (mask && !setup_texture(pNv, 1, pict_mask, mask)) goto fail; /* Set the register combiners up. */ setup_combiners(pNv, pict_src, pict_mask); /* Set PictOp */ setup_blend_function(pNv); chan->flush_notify = NV10StateCompositeReemit; return TRUE; fail: MARK_UNDO(chan); return FALSE; }
/****************************************************************** * create_board * * creates a bill board in direction of XY plane between diagonal points * (x1, y1, z1) and (x2, y2, z2) *******************************************************************/ object_gl* create_board(float x1, float y1, float z1, float x2, float y2, float z2){ object_gl* board = NULL; // Initialize a new board board = init_board(); if (board == NULL) return NULL; // Define vertexes board->vertx_buffer_data[ 0] = x1; board->vertx_buffer_data[ 1] = y1; board->vertx_buffer_data[ 2] = z1; board->vertx_buffer_data[ 3] = x2; board->vertx_buffer_data[ 4] = y2; board->vertx_buffer_data[ 5] = z2; board->vertx_buffer_data[ 6] = x1; board->vertx_buffer_data[ 7] = y2; board->vertx_buffer_data[ 8] = z1; board->vertx_buffer_data[ 9] = x2; board->vertx_buffer_data[10] = y1; board->vertx_buffer_data[11] = z1; // Define normals for (int i = 0; i < board->num_vertx; i++){ board->normal_buffer_data[i*3 + 0] = 0.0; board->normal_buffer_data[i*3 + 1] = 0.0; board->normal_buffer_data[i*3 + 2] = 1.0; } // Define UV coordinates for each vertex board->color_buffer_data[0] = 0.0 + UV_OFFSET; board->color_buffer_data[1] = 0.66; board->color_buffer_data[2] = 0.25 + UV_OFFSET; board->color_buffer_data[3] = 0.99; board->color_buffer_data[4] = 0.0 + UV_OFFSET; board->color_buffer_data[5] = 0.99; board->color_buffer_data[6] = 0.25 + UV_OFFSET; board->color_buffer_data[7] = 0.66; // Define index board->index_buffer_data[0] = 0; board->index_buffer_data[1] = 2; board->index_buffer_data[2] = 3; board->index_buffer_data[3] = 1; board->index_buffer_data[4] = 2; board->index_buffer_data[5] = 3; // Load texture setup_texture(board, "data/dance.bmp"); return board; }
void GLUI_Rotation::iaction_draw_active_area_persp( void ) { if ( NOT can_draw() ) return; copy_float_array_to_ball(); setup_texture(); setup_lights(); glEnable(GL_CULL_FACE ); glMatrixMode( GL_MODELVIEW ); glPushMatrix(); mat4 tmp_rot = *ball->rot_ptr; glMultMatrixf( (float*) &tmp_rot[0][0] ); /*** Draw the checkered box ***/ /*glDisable( GL_TEXTURE_2D ); */ draw_ball( 1.96 ); glPopMatrix(); glDisable( GL_TEXTURE_2D ); glDisable( GL_LIGHTING ); glDisable( GL_CULL_FACE ); }
int init(int w, int h) { int ret = setup_shm(w, h); if (ret != 0) { return ret; } setup_texture(w, h); setup_viewport(w, h); // Set the clear color to black glClearColor(0.0f, 0.0f, 0.0f, 1); // Create the shaders int vertex_shader = load_shader(GL_VERTEX_SHADER, vs_image); int fragment_shader = load_shader(GL_FRAGMENT_SHADER, fs_image); sp_image = glCreateProgram(); // create empty OpenGL ES Program glAttachShader(sp_image, vertex_shader); // add the vertex shader to program glAttachShader(sp_image, fragment_shader); // add the fragment shader to program glLinkProgram(sp_image); // creates OpenGL ES program executables // Set our shader program glUseProgram(sp_image); width = w; height = h; return 0; // do we need more error handling code?? }
void GLUI_Rotation::iaction_draw_active_area_persp( void ) { /********** arcball *******/ copy_float_array_to_ball(); setup_texture(); setup_lights(); glEnable(GL_CULL_FACE ); glMatrixMode( GL_MODELVIEW ); glPushMatrix(); mat4 tmp_rot = *ball->rot_ptr; glMultMatrixf( (float*) &tmp_rot[0][0] ); /*** Draw the checkered box ***/ /*glDisable( GL_TEXTURE_2D ); */ draw_ball(1.35); // 1.96 ); glPopMatrix(); glBindTexture(GL_TEXTURE_2D,0); /* unhook our checkerboard texture */ glDisable( GL_TEXTURE_2D ); glDisable( GL_LIGHTING ); glDisable( GL_CULL_FACE ); }
void piglit_init(int argc, char **argv) { int i; Tests = 0; for (i = 1; i < argc; i++) { if (strcmp(argv[i], "fixed") == 0) { Tests |= TEST_FIXED_FUNC; } else if (strcmp(argv[i], "arb_fp") == 0) { Tests |= TEST_ARB_FP; } else if (strcmp(argv[i], "glsl") == 0) { Tests |= TEST_GLSL; } else if (strcmp(argv[i], "all") == 0) { Tests |= TEST_ALL; } else { printf("Usage:\n"); printf(" incomplete-texture fixed | arb_fp | glsl | all\n"); piglit_report_result(PIGLIT_SKIP); } } setup_texture(); }
void MeshPara::setup() { MeshViewer::setup(); // add menu item add_draw_mode("Texture"); // setup texture setup_texture(); }
void init_sles_gain_focus(struct android_app* state) { create_sl_engine(); init_all_voices(); start_loop(); int i; for(i=0;i<sizeof_textures_elements;i++) { struct texture_file* tf = textures+i; setup_texture(tf, 0.0f); } }
int init_ogl_video(Displaydata_t * displaydata, Sourceparams_t * sourceparams) { int status; glClearColor(0.0, 0.0, 0.0, 1.0); glClear(GL_COLOR_BUFFER_BIT); glFinish(); glutSwapBuffers(); status = setup_texture(displaydata, sourceparams); return(status); }
void load_textures(void) { char filename[256]; GLenum minFilter, maxFilter; int id = 1, i; glPixelStorei(GL_UNPACK_ALIGNMENT, 1); if (useMipmaps) { minFilter = GL_LINEAR_MIPMAP_LINEAR; maxFilter = GL_LINEAR; } else { minFilter = GL_LINEAR; maxFilter = GL_LINEAR; } logoTex = id; setup_texture("OpenGL.bw", logoTex, minFilter, maxFilter); id++; if (!useMipmaps) { minFilter = GL_NEAREST; maxFilter = GL_NEAREST; } for (i = 0; i < 10; i++) { shineTex[i] = id; sprintf(filename, "Shine%d.bw", i); setup_texture(filename, shineTex[i], minFilter, maxFilter); id++; } for (i = 0; i < 6; i++) { flareTex[i] = id; sprintf(filename, "Flare%d.bw", i + 1); setup_texture(filename, flareTex[i], minFilter, maxFilter); id++; } }
GLFluids::GLFluids(QWidget *parent) : QGLWidget(parent), QGLFunctions() { vbo = 0; wWidth = qMax(512, DIM); wHeight = qMax(512, DIM); hvfield = (float2 *)malloc(sizeof(float2) * DS); memset(hvfield, 0, sizeof(float2) * DS); // Allocate and initialize device data cudaMallocPitch((void **)&dvfield, &tPitch, sizeof(float2)*DIM, DIM); cudaMemcpy(dvfield, hvfield, sizeof(float2) * DS, cudaMemcpyHostToDevice); // Temporary complex velocity field data cudaMalloc((void **)&vxfield, sizeof(float2) * PDS); cudaMalloc((void **)&vyfield, sizeof(float2) * PDS); setup_texture(DIM, DIM); bind_texture(); // Create particle array particles = (float2 *)malloc(sizeof(float2) * DS); memset(particles, 0, sizeof(float2) * DS); initParticles(particles, DIM, DIM); // Create CUFFT transform plan configuration cufftPlan2d(&planr2c, DIM, DIM, CUFFT_R2C); cufftPlan2d(&planc2r, DIM, DIM, CUFFT_C2R); // TODO: update kernels to use the new unpadded memory layout for perf // rather than the old FFTW-compatible layout cufftSetCompatibilityMode(planr2c, CUFFT_COMPATIBILITY_FFTW_PADDING); cufftSetCompatibilityMode(planc2r, CUFFT_COMPATIBILITY_FFTW_PADDING); QTimer *timer = new QTimer(this); connect(timer, &QTimer::timeout, [&](){ simulateFluids(); updateGL(); }); timer->start(0); }
void load_tile_from_cache( image_tile_t * image_tile) { char filename[MAX_FILENAME_LENGTH]; filename_of_ix_iy_zoom(filename, image_tile->ix, image_tile->iy, image_tile->zoom_level); FILE * imagefile; if ((imagefile = fopen(filename,"r")) == NULL){ printf("this file was supposed to be available but it's not\n"); fclose(imagefile); exit(1); } fclose(imagefile); if ( ( image_tile->image = imlib_load_image(filename) ) != 0){ image_tile->status = TILE_READY; setup_texture( image_tile ); } else { printf("imlib_load_image fail\n"); exit(1); } }
static int hap_decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { HapContext *ctx = avctx->priv_data; ThreadFrame tframe; int ret, length; int blocks = avctx->coded_width * avctx->coded_height / (TEXTURE_BLOCK_W * TEXTURE_BLOCK_H); bytestream2_init(&ctx->gbc, avpkt->data, avpkt->size); /* Check for section header */ length = parse_section_header(avctx); if (length < 0) { av_log(avctx, AV_LOG_ERROR, "Frame is too small.\n"); return length; } /* Prepare the texture buffer and decompress function */ ret = setup_texture(avctx, length); if (ret < 0) return ret; /* Get the output frame ready to receive data */ tframe.f = data; ret = ff_thread_get_buffer(avctx, &tframe, 0); if (ret < 0) return ret; if (avctx->codec->update_thread_context) ff_thread_finish_setup(avctx); /* Use the decompress function on the texture, one block per thread */ avctx->execute2(avctx, decompress_texture_thread, tframe.f, NULL, blocks); /* Frame is ready to be output */ tframe.f->pict_type = AV_PICTURE_TYPE_I; tframe.f->key_frame = 1; *got_frame = 1; return avpkt->size; }
void load_objects_gl(Object *objs) { Object *o; iMesh *m; for (o = objs; o != NULL; o = o->next) { setup_texture(o); switch (o->type) { case V_TRIMESH: if (mesh_(o)->nv == NULL) imesh_compute_normals(mesh_(o)); vbo_store_mesh_gl(o, mesh_(o)); break; case V_PRIM: m = prim_mesh(prim_(o), prim_uv_decomp(prim_(o), 1.)); vbo_store_mesh_gl(o, m); break; case V_GROUP: load_objects_gl(children_(o)); break; default: error("(load_obj_gl) wrong type"); } } }
static Bool setup_picture(NVPtr pNv, PicturePtr pict, PixmapPtr pixmap, int unit, uint32_t *color, uint32_t *alpha) { struct nouveau_pushbuf *push = pNv->pushbuf; uint32_t shift, source; if (pict && pict->pDrawable) { if (!setup_texture(pNv, unit, pict, pixmap)) return FALSE; source = RCSRC_TEX(unit); } else if (pict) { BEGIN_NV04(push, NV10_3D(RC_COLOR(unit)), 1); PUSH_DATA (push, pict->pSourcePict->solidFill.color); source = RCSRC_COL(unit); } if (pict && PICT_FORMAT_RGB(pict->format)) *color = RCSEL_COLOR | source; else *color = RCSEL_ALPHA | RCINP_ZERO; if (pict && PICT_FORMAT_A(pict->format)) *alpha = RCSEL_ALPHA | source; else *alpha = RCSEL_ALPHA | RCINP_ONE; if (unit) shift = RCINP_B__SHIFT; else shift = RCINP_A__SHIFT; *color <<= shift; *alpha <<= shift; return TRUE; }
ENTRYPOINT void init_planet (ModeInfo * mi) { planetstruct *gp; int screen = MI_SCREEN(mi); Bool wire = MI_IS_WIREFRAME(mi); MI_INIT (mi, planets); gp = &planets[screen]; gp->window = MI_WINDOW(mi); if ((gp->glx_context = init_GL(mi)) != NULL) { reshape_planet(mi, MI_WIDTH(mi), MI_HEIGHT(mi)); } { char *f = get_string_resource(mi->dpy, "imageForeground", "Foreground"); char *b = get_string_resource(mi->dpy, "imageBackground", "Background"); char *s; if (!f) f = strdup("white"); if (!b) b = strdup("black"); for (s = f + strlen(f)-1; s > f; s--) if (*s == ' ' || *s == '\t') *s = 0; for (s = b + strlen(b)-1; s > b; s--) if (*s == ' ' || *s == '\t') *s = 0; free (f); free (b); } { double spin_speed = 0.1; double wander_speed = 0.005; gp->rot = make_rotator (do_roll ? spin_speed : 0, do_roll ? spin_speed : 0, 0, 1, do_wander ? wander_speed : 0, True); gp->z = frand (1.0); gp->tilt = frand (23.4); gp->trackball = gltrackball_init (True); } if (!wire && !do_texture) { GLfloat pos[4] = {1, 1, 1, 0}; GLfloat amb[4] = {0, 0, 0, 1}; GLfloat dif[4] = {1, 1, 1, 1}; GLfloat spc[4] = {0, 1, 1, 1}; glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glLightfv(GL_LIGHT0, GL_POSITION, pos); glLightfv(GL_LIGHT0, GL_AMBIENT, amb); glLightfv(GL_LIGHT0, GL_DIFFUSE, dif); glLightfv(GL_LIGHT0, GL_SPECULAR, spc); } if (wire) do_texture = False; if (do_texture) setup_texture (mi); if (do_stars) init_stars (mi); /* construct the polygons of the planet */ gp->platelist = glGenLists(1); glNewList (gp->platelist, GL_COMPILE); glFrontFace(GL_CCW); glPushMatrix(); glRotatef (90, 1, 0, 0); unit_sphere (resolution, resolution, wire); glPopMatrix(); glEndList(); gp->shadowlist = glGenLists(1); glNewList (gp->shadowlist, GL_COMPILE); glFrontFace(GL_CCW); if (wire) glColor4f (0.5, 0.5, 0, 1); # ifdef BLENDED_TERMINATOR else { GLfloat c[] = { 0, 0, 0, 1 }; glColor4fv (c); if (!do_texture) glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, c); } # endif glPushMatrix(); glScalef (1.01, 1.01, 1.01); unit_dome (resolution, resolution, wire); # ifdef BLENDED_TERMINATOR terminator_tube (mi, resolution); if (!wire) { /* We have to draw the transparent side of the mask too, though I'm not sure why. */ GLfloat c[] = { 0, 0, 0, 0 }; glColor4fv (c); if (!do_texture) glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, c); glRotatef (180, 1, 0, 0); unit_dome (resolution, resolution, wire); } # endif glPopMatrix(); glEndList(); /* construct the polygons of the latitude/longitude/axis lines. */ gp->latlonglist = glGenLists(1); glNewList (gp->latlonglist, GL_COMPILE); glPushMatrix (); glRotatef (90, 1, 0, 0); /* unit_sphere is off by 90 */ glRotatef (8, 0, 1, 0); /* line up the time zones */ unit_sphere (12, 24, 1); unit_sphere (12, 24, 1); glBegin(GL_LINES); glVertex3f(0, -2, 0); glVertex3f(0, 2, 0); glEnd(); glPopMatrix (); glEndList(); }
ENTRYPOINT void init_planet (ModeInfo * mi) { planetstruct *gp; int screen = MI_SCREEN(mi); Bool wire = MI_IS_WIREFRAME(mi); if (planets == NULL) { if ((planets = (planetstruct *) calloc(MI_NUM_SCREENS(mi), sizeof (planetstruct))) == NULL) return; } gp = &planets[screen]; if ((gp->glx_context = init_GL(mi)) != NULL) { reshape_planet(mi, MI_WIDTH(mi), MI_HEIGHT(mi)); } { //char *f = get_string_resource(mi->dpy, "imageForeground", "Foreground"); //char *b = get_string_resource(mi->dpy, "imageBackground", "Background"); char *f = _strdup(imageForeground); char *b = _strdup(imageBackground); char *s; if (!f) f = _strdup("white"); if (!b) b = _strdup("black"); for (s = f + strlen(f)-1; s > f; s--) if (*s == ' ' || *s == '\t') *s = 0; for (s = b + strlen(b)-1; s > b; s--) if (*s == ' ' || *s == '\t') *s = 0; if (!XParseColor(mi->dpy, mi->xgwa.colormap, f, &gp->fg)) { fprintf(stderr, "%s: unparsable color: \"%s\"\n", progname, f); exit(1); } if (!XParseColor(mi->dpy, mi->xgwa.colormap, b, &gp->bg)) { fprintf(stderr, "%s: unparsable color: \"%s\"\n", progname, f); exit(1); } free (f); free (b); } { double spin_speed = 0.5; double wander_speed = 0.02; gp->rot = make_rotator (do_roll ? spin_speed : 0, do_roll ? spin_speed : 0, 0, 1, do_wander ? wander_speed : 0, True); gp->z = frand (1.0); gp->trackball = gltrackball_init (); } if (wire) { do_texture = False; do_light = False; } if (do_texture) setup_texture (mi); if (do_light) init_sun (mi); if (do_stars) init_stars (mi); if (random() & 1) star_spin = -star_spin; /* construct the polygons of the planet */ gp->platelist = glGenLists(1); glNewList (gp->platelist, GL_COMPILE); glColor3f (1,1,1); glPushMatrix (); glScalef (RADIUS, RADIUS, RADIUS); glRotatef (90, 1, 0, 0); glFrontFace(GL_CCW); unit_sphere (resolution, resolution, wire); glPopMatrix (); glEndList(); /* construct the polygons of the latitude/longitude/axis lines. */ gp->latlonglist = glGenLists(1); glNewList (gp->latlonglist, GL_COMPILE); glPushMatrix (); glDisable (GL_TEXTURE_2D); glDisable (GL_LIGHTING); glDisable (GL_LINE_SMOOTH); glColor3f (0.1, 0.3, 0.1); glScalef (RADIUS, RADIUS, RADIUS); glScalef (1.01, 1.01, 1.01); glRotatef (90, 1, 0, 0); unit_sphere (12, 24, 1); glBegin(GL_LINES); glVertex3f(0, -2, 0); glVertex3f(0, 2, 0); glEnd(); glPopMatrix (); glEndList(); }
ENTRYPOINT void init_planet (ModeInfo * mi) { planetstruct *gp; int screen = MI_SCREEN(mi); Bool wire = MI_IS_WIREFRAME(mi); if (planets == NULL) { if ((planets = (planetstruct *) calloc(MI_NUM_SCREENS(mi), sizeof (planetstruct))) == NULL) return; } gp = &planets[screen]; if ((gp->glx_context = init_GL(mi)) != NULL) { reshape_planet(mi, MI_WIDTH(mi), MI_HEIGHT(mi)); } gp->state = STARTUP; gp->ratio = 0; gp->font_data = load_texture_font (mi->dpy, "labelFont"); { double spin_speed = 0.1; double wander_speed = 0.002; gp->rot = make_rotator (do_roll ? spin_speed : 0, do_roll ? spin_speed : 0, 0, 1, do_wander ? wander_speed : 0, False); gp->trackball = gltrackball_init (True); } if (wire) do_texture = False; if (do_texture) setup_texture (mi); if (do_stars) init_stars (mi); glEnable (GL_DEPTH_TEST); glEnable (GL_NORMALIZE); glEnable (GL_CULL_FACE); if (!wire) { GLfloat pos[4] = {0.4, 0.2, 0.4, 0.0}; GLfloat amb[4] = {0.4, 0.4, 0.4, 1.0}; GLfloat dif[4] = {1.0, 1.0, 1.0, 1.0}; GLfloat spc[4] = {1.0, 1.0, 1.0, 1.0}; glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glLightfv(GL_LIGHT0, GL_POSITION, pos); glLightfv(GL_LIGHT0, GL_AMBIENT, amb); glLightfv(GL_LIGHT0, GL_DIFFUSE, dif); glLightfv(GL_LIGHT0, GL_SPECULAR, spc); } }
int main(int argc, char **argv) { atexit(cleanup); // parse arguments char *model_path = NULL; char *vertexshader_path = NULL; char *fragmentshader_path = NULL; char *texture_path = NULL; bool use_smoothed_normals; if (argc >= 6) { texture_path = argv[5]; useTexture = 1; } if (argc >= 5) { model_path = argv[1]; vertexshader_path = argv[2]; fragmentshader_path = argv[3]; use_smoothed_normals = *argv[4] != '0'; } else { std::cerr << "Usage:" << std::endl; std::cerr << argv[0] << " <model::path> " << " <vertex-shader::path> " << " <fragment-shader::path> " << " <smooth-normals::{0,1}>" << " (<texture::path>)" << std::endl; exit(1); } // initialise OpenGL glutInit(&argc, argv); glutInitWindowSize(windowX, windowY); glutCreateWindow("CG-CW1"); glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH); glEnable(GL_DEPTH_TEST); // set display and keyboard callbacks glutDisplayFunc(display_handler); glutKeyboardFunc(keyboard_handler); // initialise the OpenGL Extension Wrangler library for VBOs GLenum err = glewInit(); if (err != GLEW_OK){ std::cerr << "Error!" << std::endl; exit(1); } if (!GLEW_VERSION_2_1) { std::cerr << "Error 2.1!" << std::endl; exit(1); } // create shader, prepare data for OpenGL trig.LoadFile(model_path); shader.Init(vertexshader_path, fragmentshader_path); setup_texture(texture_path, &textureID); setup_vertex_position_buffer_object(); setup_vertex_uv_buffer_object(); setup_vertex_normal_buffer_object(use_smoothed_normals); // set up camera and object transformation matrices projectionMatrix = get_default_projectionMatrix(); viewMatrix = get_default_viewMatrix(); modelMatrix = get_default_modelMatrix(); normalMatrix = get_default_normalMatrix(); glutMainLoop(); }