当前位置: 首页>>代码示例>>C++>>正文


C++ draw_grid函数代码示例

本文整理汇总了C++中draw_grid函数的典型用法代码示例。如果您正苦于以下问题:C++ draw_grid函数的具体用法?C++ draw_grid怎么用?C++ draw_grid使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了draw_grid函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main(int argc, const char *argv[])
{
	int ret;
	char ch;
	
	srand(time(NULL));
	ret = fb_open();
	key_init();	
	draw_back();
	draw_grid();
	signal(SIGALRM, sig_handler);
	alarm(1);

	while (1) {
		ch = getchar();
		switch (ch) {
			case 'a':
				if(canleft(pos_x, pos_y, cur_type, arr)) {
					draw_type(pos_x, pos_y, cur_type, BACK);
					pos_x--;
				}
				break;
			case 'd':
				if(canright(pos_x, pos_y, cur_type, arr)) {
					draw_type(pos_x, pos_y, cur_type, BACK);
					pos_x++;
				}
				break;	
			case 's':
				if(candown(pos_x, pos_y, cur_type, arr)) {
					draw_type(pos_x, pos_y, cur_type, BACK);
					pos_y++;
				}
				break;
			case 'w':
				if(canchange(pos_x,pos_y,cur_type,arr)) {
					draw_type(pos_x, pos_y, cur_type, BACK);
					type_chg(&cur_type);
				}
				break;
			default :
				break;
		}
		draw_type(pos_x, pos_y, cur_type, COLOR);
		draw_grid();
		if(!candown(pos_x, pos_y, cur_type, arr)) {
			draw_flag(pos_x, pos_y, cur_type, arr);
			if(gameover(arr)) {
				exit(0);
			}
			deleteone(arr);
			pos_x = XNUM/2; pos_y = 0;
			cur_type = rand()%14;
		}
	}

	fb_close();

	return 0;
}
开发者ID:wcybxzj,项目名称:shangguan,代码行数:60,代码来源:main.c

示例2: draw_ui

int draw_ui()
{

	int menubuffer_location_x = 0, menubuffer_location_y = 0;
	//draw the tile grid around the map
	if (draw_grid_on_map==1)
	draw_grid(0,0,639,639, tile_width, map_buffer, makecol(255,255,255));

	if (draw_grid_on_tiles==1)
	draw_grid(0,0,tilebuffer_width_in_tiles * tile_width , tilebuffer_height_in_tiles * tile_width, tile_width, tile_buffer, makecol(255,255,255));


	// when changing the names of buttons, remember to make sure they call the corresponding function in get_user_input()
	rect(menu_buffer,5,5,90,40,makecol(255,255,255));	//fill button
	textprintf_ex(menu_buffer, font, 30 , 20, makecol(255,255,255), -1, "Fill" );
	rect(menu_buffer,5,45,90,80,makecol(255,255,255));	//fill area button
	textprintf_ex(menu_buffer, font, 30 , 50, makecol(255,255,255), -1, "Fill" );
	textprintf_ex(menu_buffer, font, 30 , 60, makecol(255,255,255), -1, "area" );
	rect(menu_buffer,5,85,90,120,makecol(255,255,255));// copy button
	textprintf_ex(menu_buffer, font, 30 , 100, makecol(255,255,255), -1, "Copy" );
	rect(menu_buffer,5,125,90,160,makecol(255,255,255)); // repeat copy button
	textprintf_ex(menu_buffer, font, 25 , 130, makecol(255,255,255), -1, "Repeat" );
	textprintf_ex(menu_buffer, font, 30 , 140, makecol(255,255,255), -1, "copy" );
	rect(menu_buffer,5,165,90,200,makecol(255,255,255)); // mirror x copy button
	textprintf_ex(menu_buffer, font, 20 , 170, makecol(255,255,255), -1, "Mirror H" );
	textprintf_ex(menu_buffer, font, 30 , 180, makecol(255,255,255), -1, "copy" );
	rect(menu_buffer,5,205,90,240,makecol(255,255,255)); // mirror y copy button
	textprintf_ex(menu_buffer, font, 20 , 210, makecol(255,255,255), -1, "Mirror V" );
	textprintf_ex(menu_buffer, font, 30 , 220, makecol(255,255,255), -1, "copy" );

	rect(menu_buffer,5,245,90,280,makecol(255,255,255));
	rect(menu_buffer,5,285,90,320,makecol(255,255,255));

	rect(menu_buffer,5,325,90,360,makecol(255,255,255)); // toggle grids button
	textprintf_ex(menu_buffer, font, 25 , 330, makecol(255,255,255), -1, "Toggle" );
	textprintf_ex(menu_buffer, font, 30 , 340, makecol(255,255,255), -1, "grids" );
	rect(menu_buffer,5,365,90,400,makecol(255,255,255)); // reload map
	textprintf_ex(menu_buffer, font, 25 , 380, makecol(255,255,255), -1, "Reload" );	
	rect(menu_buffer,5,405,90,440,makecol(255,255,255)); // save map
	textprintf_ex(menu_buffer, font, 30 , 420, makecol(255,255,255), -1, "Save" );


	//here's where the layers all get flattened onto screen_buffer
	blit (menu_buffer, screen_buffer, 0,0,0,0,100,768);
	blit (map_buffer, screen_buffer, 0,0,mapbuffer_location_x,mapbuffer_location_y,641,641);
	blit (tile_buffer, screen_buffer, 0,0,tilebuffer_location_x,tilebuffer_location_y,255,768);
	destroy_bitmap (tile_buffer);
	tile_buffer=load_bitmap("tiles.bmp",0);

	//then I draw the mouse and I'm done.
	line (screen_buffer,	mouse_x-11,	mouse_y-9,	mouse_x+9,	mouse_y+11,	makecol(0,0,0));	//draw the cursor
	line (screen_buffer,	mouse_x-11,	mouse_y-11,	mouse_x+11,	mouse_y+11,	makecol(0,0,0));	//draw the cursor
	line (screen_buffer,	mouse_x-8,	mouse_y-8,	mouse_x+8,	mouse_y+8,	makecol(255,255,255));	//draw the cursor
	line (screen_buffer,	mouse_x-9,	mouse_y-11,	mouse_x+11,	mouse_y+9,	makecol(0,0,0));	//draw the cursor
	line (screen_buffer,	mouse_x-11,	mouse_y+9,	mouse_x+9,	mouse_y-11,	makecol(0,0,0));	//draw the cursor
	line (screen_buffer,	mouse_x-11,	mouse_y+11,	mouse_x+11,	mouse_y-11,	makecol(0,0,0));	//draw the cursor
	line (screen_buffer,	mouse_x-8,	mouse_y+8,	mouse_x+8,	mouse_y-8,	makecol(255,255,255));	//draw the cursor
	line (screen_buffer,	mouse_x-9,	mouse_y+11,	mouse_x+11,	mouse_y-9,	makecol(0,0,0));	//draw the cursor
	return 0;
}
开发者ID:SamPearson,项目名称:game-engine,代码行数:60,代码来源:gfx.cpp

示例3: switch

/*!
	@brief 描画プロシージャ
*/
void mine_tile::paint(Graphics* g){
	switch(state){
	case init:
	case init_lock:
		draw_frame(g);
		break;
	case opened:
		draw_grid(g);
		draw_number(g);
		break;
	case marked:
	case mark_lock:
		draw_frame(g);
		draw_flag(g);
		break;
	case bomb:
		draw_grid(g);
		draw_bomb(g);
		break;
	case exploded:
		draw_grid(g);
		draw_bomb(g);
		draw_cross(g);
		break;
	case missmark:
		draw_frame(g);
		draw_flag(g);
		draw_cross(g);
		break;
	default:
		break;
	}
}
开发者ID:ShotaroTsuji,项目名称:mona,代码行数:36,代码来源:tile.cpp

示例4: jit_gl_videoplane_draw

t_jit_err jit_gl_videoplane_draw(t_jit_gl_videoplane *x)
{
	t_jit_err result = JIT_ERR_NONE;
	GLenum prim;
	
	CLIP (x->nudge,0.,0.5);
	prim = (x->gridmode) ? GL_TRIANGLE_STRIP : GL_QUAD_STRIP;
	
	if (x->recalc) {
		jit_gl_videoplane_recalc(x);
		if (x->displaylist) 
		{
			t_jit_gl_context ctx;
			
			// cache/restore context in case in capture mode
			ctx = jit_gl_get_context();			
			jit_ob3d_set_context(x);
			
			if (x->dlref) {
				glDeleteLists(x->dlref,1);
				x->dlref = 0;
			}
			if (x->dlref=glGenLists(1)) {
				glNewList(x->dlref, GL_COMPILE);
				if (x->chunk&&x->chunk->m_vertex) 
					draw_grid(x,x->chunk->m_vertex, prim);
				glEndList();
			}
		
			jit_gl_set_context(ctx);
		}		
		x->recalc = 0;
	}
	
	// draw our chunk of OpenGL geometry. 
	if (x->chunk&&x->chunk->m_vertex) {
		if (!jit_attr_getlong(x,gensym("matrixoutput"))) {
			if (x->displaylist&&x->dlref)
				glCallList(x->dlref);
			else 
				draw_grid(x,x->chunk->m_vertex, prim);
			if(jit_attr_getlong(x, _jit_sym_boundcalc))
				jit_object_method(x, gensym("calcbounds"), x->chunk, NULL);				
		} else{
			color_surface(x);
			result = jit_ob3d_draw_chunk(x->ob3d, x->chunk); //output matrix
		}
	}	
	
	return result;
}
开发者ID:pukulsesuatu,项目名称:max6-sdk,代码行数:51,代码来源:jit.gl.videoplane.c

示例5: draw

static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
    cairo_surface_t *source;
    cairo_pattern_t *pattern;

    cairo_paint (cr);

    source = create_source (cairo_get_target (cr), 2560, 1280);
    pattern = cairo_pattern_create_for_surface (source);
    cairo_surface_destroy (source);

    cairo_pattern_set_filter (pattern, CAIRO_FILTER_NEAREST);
    cairo_pattern_set_extend (pattern, CAIRO_EXTEND_NONE);

    draw_grid (cr, pattern, 50, 0);
    draw_grid (cr, pattern, 130, 0);
    draw_grid (cr, pattern, 210, 0);
    draw_grid (cr, pattern, 290, 0);

    draw_grid (cr, pattern, 50,  230);
    draw_grid (cr, pattern, 130, 230);
    draw_grid (cr, pattern, 210, 230);
    draw_grid (cr, pattern, 290, 230);

    cairo_pattern_destroy (pattern);

    return CAIRO_TEST_SUCCESS;
}
开发者ID:AliYousuf,项目名称:cairo,代码行数:29,代码来源:scale-offset-similar.c

示例6: run_test

static bool
run_test(const struct image_target_info *target,
         const struct image_extent size)
{
        const struct grid_info grid = {
                GL_FRAGMENT_SHADER_BIT,
                get_image_format(GL_RGBA32F),
                image_optimal_extent(size)
        };
        const struct image_info img = {
                target, grid.format, size,
                image_format_epsilon(grid.format)
        };
        GLuint prog = generate_program(
                grid, GL_FRAGMENT_SHADER,
                concat(image_hunk(img, ""),
                       hunk("readonly uniform IMAGE_T src_img;\n"
                            "writeonly uniform IMAGE_T dst_img;\n"
                            "\n"
                            "GRID_T op(ivec2 idx, GRID_T x) {\n"
                            "        imageStore(dst_img, IMAGE_ADDR(idx),"
                            "                imageLoad(src_img, IMAGE_ADDR(idx)));\n"
                            "        return x;\n"
                            "}\n"), NULL));
        bool ret = prog && init_fb(grid) &&
                init_image(img, 0) &&
                init_image(img, 1) &&
                set_uniform_int(prog, "src_img", 0) &&
                set_uniform_int(prog, "dst_img", 1)  &&
                draw_grid(grid, prog) &&
                check(img);

        glDeleteProgram(prog);
        return ret;
}
开发者ID:Jul13t,项目名称:piglit,代码行数:35,代码来源:max-size.c

示例7: GLDraw

//! LA fonction d'affichage
void GLDraw(void)
{
    // Efface la couleur et le ZBuffer
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glLightfv(GL_LIGHT1, GL_POSITION, LightPosition);

    // Place la scène comme on veut
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    camSetGL(cam);

    glPushAttrib( GL_ENABLE_BIT);
    glPointSize(18);
    glColor3f(1,1,1);
    glDisable(GL_TEXTURE_2D);
    glDisable(GL_LIGHTING);
    glBegin(GL_POINTS);
    glVertex3f( LightPosition[0], LightPosition[1], LightPosition[2]  );
    glEnd();

    if (bAxe) draw_axes();
    if (bGrid) draw_grid();
    if (bAnim) animDraw(scene.anim);

    glPopAttrib();
    sceneDraw(scene);


    // since this is double buffered, swap the buffers to display what just got drawn.
    glutSwapBuffers();
}
开发者ID:dtbinh,项目名称:opengl_scene,代码行数:34,代码来源:opengl.cpp

示例8: run_test

static bool
run_test(GLbitfield shaders)
{
        const struct grid_info grid = {
                shaders,
                get_image_format(GL_R32UI),
                { W, H, 1, 1 }
        };
        const struct image_info img = image_info_for_grid(grid);
        GLuint prog = generate_program(
                grid,
                GL_VERTEX_SHADER,
                generate_source(grid, img, GL_VERTEX_SHADER),
                GL_TESS_CONTROL_SHADER,
                generate_source(grid, img, GL_TESS_CONTROL_SHADER),
                GL_TESS_EVALUATION_SHADER,
                generate_source(grid, img, GL_TESS_EVALUATION_SHADER),
                GL_GEOMETRY_SHADER,
                generate_source(grid, img, GL_GEOMETRY_SHADER),
                GL_FRAGMENT_SHADER,
                generate_source(grid, img, GL_FRAGMENT_SHADER),
                GL_COMPUTE_SHADER,
                generate_source(grid, img, GL_COMPUTE_SHADER));
        bool ret = prog && init_fb(grid) &&
                init_images(img) &&
                bind_images(grid, prog) &&
                draw_grid(grid, prog) &&
                check(grid, img);

        glDeleteProgram(prog);
        return ret;
}
开发者ID:Jul13t,项目名称:piglit,代码行数:32,代码来源:max-images.c

示例9: expose_callback

static gboolean
expose_callback (GtkWidget      *event_box,
                 GdkEventButton *,
                 TSignalData    *sigdata)
{
    cairo_t *cr;
    if (sigdata->event_box != NULL)
        cr = gdk_cairo_create (GDK_DRAWABLE (sigdata->event_box->window));
    else
    {
        cr = gdk_cairo_create (GDK_DRAWABLE (event_box->window));
        sigdata->event_box = event_box;
    }


    if (sigdata->image != NULL)
    {
        GdkPixbuf *pxbf = gtk_image_get_pixbuf(GTK_IMAGE(sigdata->image));

        gdk_cairo_set_source_pixbuf (cr, pxbf, 0,0);

        cairo_paint (cr);

        draw_grid(cr, sigdata->idata);
    }


    return TRUE;
}
开发者ID:Pitel,项目名称:morphing,代码行数:29,代码来源:gui_setgridwnd.cpp

示例10: run_test

/**
 * Copy from a source image into a destination image of the specified
 * format and check the result.
 *
 * If \a strict_layout_qualifiers is false, uniform layout qualifiers
 * will be omitted where allowed by the spec.  If \a
 * strict_access_qualifiers is false, the "readonly" and "writeonly"
 * qualifiers will be omitted.  If \a strict_binding is false, the
 * image will be bound as READ_WRITE, otherwise only the required
 * access type will be used.
 */
static bool
run_test(const struct image_format_info *format,
         bool strict_layout_qualifiers,
         bool strict_access_qualifiers,
         bool strict_binding)
{
        const struct grid_info grid =
                grid_info(GL_FRAGMENT_SHADER,
                          image_base_internal_format(format), W, H);
        const struct image_info img =
                image_info(GL_TEXTURE_2D, format->format, W, H);
        GLuint prog = generate_program(
                grid, GL_FRAGMENT_SHADER,
                concat(image_hunk(img, ""),
                       test_hunk(strict_layout_qualifiers,
                                 strict_access_qualifiers),
                       hunk("SRC_IMAGE_Q uniform IMAGE_BARE_T src_img;\n"
                            "DST_IMAGE_Q uniform IMAGE_BARE_T dst_img;\n"
                            "\n"
                            "GRID_T op(ivec2 idx, GRID_T x) {\n"
                            "        imageStore(dst_img, IMAGE_ADDR(idx),"
                            "                   imageLoad(src_img, IMAGE_ADDR(idx)));\n"
                            "        return x;\n"
                            "}\n"), NULL));
        bool ret = prog && init_fb(grid) &&
                init_image(img, 0, strict_binding) &&
                init_image(img, 1, strict_binding) &&
                set_uniform_int(prog, "src_img", 0) &&
                set_uniform_int(prog, "dst_img", 1) &&
                draw_grid(grid, prog) &&
                check(grid, img);

        glDeleteProgram(prog);
        return ret;
}
开发者ID:BNieuwenhuizen,项目名称:piglit,代码行数:46,代码来源:qualifiers.c

示例11: run_test

static bool
run_test(const struct image_op_info *op,
         unsigned w, unsigned h,
         bool (*check)(const struct grid_info grid,
                       const struct image_info img,
                       unsigned w, unsigned h),
         const char *body)
{
        const struct grid_info grid =
                grid_info(GL_FRAGMENT_SHADER, GL_R32UI, W, H);
        const struct image_info img = image_info_for_grid(grid);
        GLuint prog = generate_program(
                grid, GL_FRAGMENT_SHADER,
                concat(image_hunk(img, ""),
                       hunk("uniform IMAGE_T img;\n"),
                       hunk(op->hunk),
                       hunk(body), NULL));
        bool ret = prog &&
                init_fb(grid) &&
                init_image(img) &&
                set_uniform_int(prog, "img", 0) &&
                draw_grid(set_grid_size(grid, w, h), prog) &&
                check(grid, img, w, h);

        glDeleteProgram(prog);
        return ret;
}
开发者ID:Jul13t,项目名称:piglit,代码行数:27,代码来源:dead-fragments.c

示例12: render_editor

bool render_editor()
{
    cursor c = cursor_get();
    map_view v = view_get();
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    update_view(v.x, v.y, v.zoom);
    /*update_cursor_data(&selected_map, &selected_tile_x, &selected_tile_y);*/
    bool can_place = cursor_in_bounds(c.selected_tile_x, c.selected_tile_y);

    mat4 t = ident;
    mat4 cursor_pos = ident;
    uint16_t tile_w = (TILE_WIDTH * v.zoom);
    uint16_t tile_h = (TILE_HEIGHT * v.zoom);
    if(tile_w == 0)
        tile_w = 1;
    if(tile_h == 0)
        tile_h = 1;
    mat4_translate(&cursor_pos, c.selected_tile_x * TILE_WIDTH + (c.selected_map % 3 * TILEMAP_DIMS * TILE_WIDTH), c.selected_tile_y * TILE_HEIGHT + (c.selected_map / 3 * TILEMAP_DIMS * TILE_HEIGHT), 0);
    draw_maps(t);
    if(can_place) {
        draw_single_tile(get_tileset_texture(), c.set_id, c.current_id, cursor_pos);
    }
    for(int i = 0; i < 3; ++i)
        for(int j = 0; j < 3; ++j) {
            mat4_translate(&t, TILEMAP_DIMS * TILE_WIDTH * i, TILEMAP_DIMS * TILE_HEIGHT * j, 0);
            draw_grid(t);
        }
    
    glFlush();

    return true;
}
开发者ID:Df458,项目名称:Halberd,代码行数:32,代码来源:editor-render.c

示例13: test_image

void test_image(void)
{
     int x, y;
     int fntWidth;
     int fntHeight;
     const int height = 10;
     const int width = 30;

     ruint16* fontbuf;
     int byteWidth;

     draw_grid();
     FntSetFont(&FntGlobalContext, FntIDAlpha);

     byteWidth = FntGetByteWidth(&FntGlobalContext);
     fntHeight = FntGetTextHeight(&FntGlobalContext);
     fntWidth = FntGetTextWidth(&FntGlobalContext, "abcdefg", 4);
     fontbuf = FntGetStrImage(&FntGlobalContext, 0, 0, fntWidth, fntHeight, "abcdefg", 4, 0);

     draw_red_frame(0, 0, fntWidth, fntHeight);

     for ( y = 0 ; y < fntHeight ; y++ )
     {
	  for ( x = 0 ; x < fntWidth ; x++ )
	  {
	       if ( fontbuf[ fntWidth*y + x ] ) draw_box(x, y);
	  }
     }
}
开发者ID:jmjeong-nemus,项目名称:rexy-embedded,代码行数:29,代码来源:startup.c

示例14: tetris_update

void tetris_update() {
	int i;
	for(i = 0; i < MAX_PLAYERS; i++) {
		update_grid(&grids[i]);
		draw_grid(&grids[i]);
	}
}
开发者ID:Lachmoewe,项目名称:lun1k,代码行数:7,代码来源:tetris.c

示例15: glClear

void GLWidget::paintGL(){
	glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluPerspective(60.0f,(GLfloat)width/(GLfloat)height,0.01f,650.0f);

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	gluLookAt(
		0.0, cam_radius, cam_radius,
		0.0, 0.0, 0.0,
		0.0, 0.0, 1.0);
	glViewport(0, 0, width, height);
	glRotatef( rotate_x, 1.0, 0.0, 0.0 );
	glRotatef( rotate_y, 0.0, 0.0, 1.0 );

	draw_layers();
	if (show_grid)
		draw_grid(-0.5,-0.5,0.1,0.1,11,11,&guide_z,&guide_col);
	if (show_axis)
		draw_axis();

	glFlush();
}
开发者ID:viclib,项目名称:3d_multilayer_viewer,代码行数:25,代码来源:glwidget.cpp


注:本文中的draw_grid函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。