示例#1
0
文件: atlas.cpp 项目: pelmenka/131
bool textureAtlas::load(const std::string &path, bool smooth)
{
    _log::out("Loading texture atlas : %s\n", path.c_str());
    XMLDocument document;

    if(document.LoadFile(path.c_str()))
        return 0;
    free();

    XMLElement *element = document.FirstChildElement("data");
    uint elCount = 0;
    element->QueryAttribute("size", &elCount);
    elements.reserve(elCount);

    if(!texture::load(path.substr(0,path.rfind('/')+1)+element->Attribute("source"), smooth))
        return 0;
    parameteri(GL_TEXTURE_WRAP_S, GL_CLAMP);
    parameteri(GL_TEXTURE_WRAP_T, GL_CLAMP);
    element = element->FirstChildElement("sprite");

    for(int i = 0;element; i++, element = element->NextSiblingElement())
    {
        textureAtlasNode temp;
        temp.angle = 0;
        temp.scale = vec2f(1);
        temp.color = rgba(1);


        CheckAttribute("x", &temp.pos.x, element);
        CheckAttribute("y", &temp.pos.y, element);
        CheckAttribute("w", &temp.size.x, element);
        CheckAttribute("h", &temp.size.y, element);
        CheckAttribute("pX", &temp.center.x, element);
        CheckAttribute("pY", &temp.center.y, element);

        const char *name = element->Attribute("n");
        if(name)
            temp.name = name;
        else _log::out("[WARNING] Can't find attribute \"n\"\n");

        temp.size += vec2f(1);
        elements.push_back(temp);
    }
    _log::out("Elements count: %d\n", elements.size());
    return 1;
}
示例#2
0
int
main(int argc, char **argv)
{
  if (argc < 4) {
    std::cerr << "Usage: test_image_rgb_mask " <<
                 "<ifile> <mfile> <ofile> [r] [g] [b]" << std::endl;
    exit(1);
  }

  CFile ifile(argv[1]);
  CFile mfile(argv[2]);
  CFile ofile(argv[3]);

  double r, g, b;

  if (argc >= 5 && ! CStrUtil::toReal(argv[4], &r)) exit(1);
  if (argc >= 6 && ! CStrUtil::toReal(argv[5], &g)) exit(1);
  if (argc >= 7 && ! CStrUtil::toReal(argv[6], &b)) exit(1);

  CImageFileSrc src1(ifile);

  CImagePtr src_image = CImageMgrInst->createImage(src1);

  CImageFileSrc src2(mfile);

  CImagePtr merge_image = CImageMgrInst->createImage(src2);

  CImagePtr merge_image1;

  if (argc >= 5) {
    CRGBA rgba(r, g, b);

    merge_image1 = merge_image->createRGBAMask(rgba);
  }
  else
    merge_image1 = merge_image->createRGBAMask();

  src_image->combineAlpha(merge_image1);

  CFileType type = CFileUtil::getImageTypeFromName(argv[3]);

  src_image->write(&ofile, type);

  exit(0);
}
示例#3
0
extern "C" void reductionKernel(const Range& globalID,const Range& localID,const CPUImage<Vec<3,float>>& input,CPUImage<unsigned>& output){
	Vec<3,float> val{ 0,0,0 };
	if(MULTISAMPLING_ENABLED){
		for(int i = 0; i < MULTISAMPLING_SIZE; i++){
			for(int j = 0; j < MULTISAMPLING_SIZE; j++){
				int xpos = globalID.x * MULTISAMPLING_SIZE + i;
				int ypos = globalID.y * MULTISAMPLING_SIZE + j;
				val += input.at(xpos,ypos);
			}
		}
		val /= (MULTISAMPLING_SIZE * MULTISAMPLING_SIZE);
	}else{
		val = input.at(globalID.x,globalID.y);
	}
	Vec<4,uint8_t> rgba(255 * val);
	rgba[3] = 255; //making the color opaque
	output.at(globalID.x,globalID.y) = reinterpret_cast<uint32_t&>(rgba);
}
示例#4
0
raster::color_t color_utils::fixup_color_for_background(PixelFormat format, raster::color_t color)
{
  switch (format) {
    case IMAGE_RGB:
      if (rgba_geta(color) < 255) {
        return rgba(rgba_getr(color),
                    rgba_getg(color),
                    rgba_getb(color), 255);
      }
      break;
    case IMAGE_GRAYSCALE:
      if (graya_geta(color) < 255) {
        return graya(graya_getv(color), 255);
      }
      break;
  }
  return color;
}
示例#5
0
int main(int argc, char * argv[])
{
    if (argc < 3) {
        std::cerr<<"usage: "<<argv[0]<<" rgba.tif region.tif"<<std::endl;
        return EXIT_FAILURE;
    }
    gdalwrap::gdal rgba  (argv[1]);
    gdalwrap::gdal region;
    region.names = {"NO_3D_CLASS", "FLAT", "OBSTACLE", "ROUGH"};
    region.copy_meta(rgba, region.names.size());
    color_to_proba(rgba.bands[0], region.get_band("OBSTACLE")); // red
    color_to_proba(rgba.bands[1], region.get_band("FLAT"));     // green
    color_to_proba(rgba.bands[2], region.get_band("ROUGH"));    // blue

    region.save(argv[2]);

    return EXIT_SUCCESS;
}
示例#6
0
文件: youmu.c 项目: nexAkari/taisei
int youmu_common_particle_slice_logic(Projectile *p, int t) {
    if(t < 0) {
        return 1;
    }

    p->color = rgba(1, 1, 1, 1 - p->args[2]/p->args[0]*20.0);

    if(t < creal(p->args[0])/20.0) {
        p->args[1] += 1;
    }

    if(t > creal(p->args[0])-10) {
        p->args[1] += 3;
        p->args[2] += 1;
    }

    return timeout(p, t);
}
示例#7
0
void renderTexture::grapicalPrintf(char* str,   void* fontData, int rasterposx, int rasterposy)
{
    unsigned char c;
    int x = 0;
    int xx = 0;

    while ((c = (unsigned char) * str++))
    {

        x = xx;
        unsigned char* fontPtr = (unsigned char*) fontData;
        char ch = c - 32;

        int sx = ch % 16;
        int sy = ch / 16;


        for (int i = sx * 16; i < (sx * 16 + 16); i++)
        {
            int y = 0;

            for (int j = sy * 16; j < (sy * 16 + 16); j++)
            {
                unsigned char packedColor = (fontPtr[i * 3 + 255 * 256 * 3 - (256 * j) * 3]);
                //float colorf = packedColor ? 0.f : 1.f;
                float colorf = packedColor / 255.f; // ? 0.f : 1.f;
                btVector4 rgba(colorf, colorf, colorf, 1.f);
                //if (colorf)
                {
                    //setPixel(rasterposx+x,rasterposy+y,rgba);
                    addPixel(rasterposx + x, rasterposy + y, rgba);
                }
                //bit >>=1;
                y++;
            }

            x++;
        }

        //xx+=16;
        xx += 10;
    }
}
示例#8
0
Sprite::Sprite(PixelFormat format, int width, int height, int ncolors)
  : Object(OBJECT_SPRITE)
  , m_format(format)
  , m_width(width)
  , m_height(height)
  , m_frames(1)
{
  ASSERT(width > 0 && height > 0);

  m_frlens.push_back(100);      // First frame with 100 msecs of duration
  m_stock = new Stock(format);
  m_folder = new LayerFolder(this);

  // Generate palette
  Palette pal(FrameNumber(0), ncolors);

  switch (format) {

    // For colored images
    case IMAGE_RGB:
    case IMAGE_INDEXED:
      pal.resize(ncolors);
      break;

    // For black and white images
    case IMAGE_GRAYSCALE:
    case IMAGE_BITMAP:
      for (int c=0; c<ncolors; c++) {
        int g = 255 * c / (ncolors-1);
        g = MID(0, g, 255);
        pal.setEntry(c, rgba(g, g, g, 255));
      }
      break;
  }

  // Initial RGB map
  m_rgbMap = NULL;

  // The transparent color for indexed images is 0 by default
  m_transparentColor = 0;

  setPalette(&pal, true);
}
示例#9
0
Sprite::Sprite(PixelFormat format, int width, int height, int ncolors)
  : Object(ObjectType::Sprite)
  , m_document(NULL)
  , m_format(format)
  , m_width(width)
  , m_height(height)
  , m_frames(1)
  , m_frameTags(this)
{
  ASSERT(width > 0 && height > 0);

  m_frlens.push_back(100);      // First frame with 100 msecs of duration
  m_folder = new LayerFolder(this);

  // Generate palette
  switch (format) {
    case IMAGE_GRAYSCALE: ncolors = 256; break;
    case IMAGE_BITMAP: ncolors = 2; break;
  }

  Palette pal(frame_t(0), ncolors);

  switch (format) {

    // For black and white images
    case IMAGE_GRAYSCALE:
    case IMAGE_BITMAP:
      for (int c=0; c<ncolors; c++) {
        int g = 255 * c / (ncolors-1);
        g = MID(0, g, 255);
        pal.setEntry(c, rgba(g, g, g, 255));
      }
      break;
  }

  // Initial RGB map
  m_rgbMap = NULL;

  // The transparent color for indexed images is 0 by default
  m_transparentColor = 0;

  setPalette(&pal, true);
}
示例#10
0
 // traverse tree and search for nodes with count!=0, that represent single color.
 // clip extreme alfa values
 void create_palette_rek(std::vector<rgba> & palette, node * itr) const
 {
     if (itr->count >= 3)
     {
         unsigned count = itr->count;
         byte a = byte(itr->alphas/float(count));
         if (a > InsertPolicy::MAX_ALPHA) a = 255;
         if (a < InsertPolicy::MIN_ALPHA) a = 0;
         palette.push_back(rgba((byte)round(gamma(itr->reds   / count, gamma_)),
                                (byte)round(gamma(itr->greens / count, gamma_)),
                                (byte)round(gamma(itr->blues  / count, gamma_)), a));
     }
     for (unsigned idx=0; idx < 16; ++idx)
     {
         if (itr->children_[idx] != 0)
         {
             create_palette_rek(palette, itr->children_[idx]);
         }
     }
 }
示例#11
0
void
shRefract::Shade(const Ray &r, rgba* result) const
{
	rgba Kr;
	mValue->Shade(r, &Kr);
	if (Kr.Luminance() != channel(0.0)) {
		rgba N;
		mCoeficient->Shade(r, &N);

		const real n1 = r.cState.refrN;
		const real n2 = N.Luminance();

		const real n = (r.gState.inside)?(n2/n1):(n1/n2);

		real sin;
		if (n >= real(0.99) && n <= real(0.001)) {
			sin = real(100.0);
		} else {
			sin = real(1.0) - Square(n) * (real(1.0) - Square(r.gState.cosND));
		}


		vec3 refrDir;
		if (n >= real(0.99) && n <= real(0.001)) {
			refrDir = r.dir;
		} else {
			refrDir = r.dir * n + r.gState.normal * (r.gState.cosND * n - sin.Sqrt());
		}


		Ray rayRefr(r.scene, r.gState.point, refrDir, r.cState.depth-1, (r.gState.inside) ? r.parent : &r);
		rayRefr.cState.refrN = n2;
		r.scene->Trace(rayRefr, result);
		if(!r.gState.inside) {
			*result *= Kr;
		}

	} else {
		*result = rgba(0.0);
	}
}
示例#12
0
文件: light.cpp 项目: jtalbot/fungi
void InfiniteAreaLight::buildDistribution() {
    float ccdf = 0;
    for (int y = 0; y < height; ++y) {
        std::vector<float> row;
        row.reserve(width);

        float cdf = 0;
        for (int x = 0; x < width; ++x) {
            int index = (y * width + x) * 4;
            auto color =
                rgba(data[index + 0], data[index + 1], data[index + 2], 1);
            float w = (color.r + color.g + color.b) / 3.0 + 0.00001;
            cdf += w;
            row.push_back(cdf);
        }

        cdf_columns.push_back(std::move(row));
        ccdf += cdf;
        cdf_rows.push_back(ccdf);
    }
}
示例#13
0
	void wsad_character_corpse(const entity_handle e) {
		auto& sprite = e += components::sprite();
		auto& render = e += components::render();

		sprite.set(assets::texture_id::DEAD_TORSO, rgba(255, 255, 255, 255));
		render.layer = render_layer::CORPSES;

		components::physics body;
		components::fixtures colliders;

		auto& info = colliders.new_collider();

		info.shape.from_renderable(e);

		info.filter = filters::corpse();
		info.density = 1.0;

		body.linear_damping = 6.5;

		e += body;
		e += colliders;
		e.get<components::fixtures>().set_owner_body(e);
	}
示例#14
0
// Changes a color of the current system palette
void set_current_color(int index, int r, int g, int b)
{
  int c;

  ASSERT(index >= 0 && index <= 255);
  ASSERT(r >= 0 && r <= 255);
  ASSERT(g >= 0 && g <= 255);
  ASSERT(b >= 0 && b <= 255);

  c = ase_current_palette->getEntry(index);

  if (rgba_getr(c) != r ||
      rgba_getg(c) != g ||
      rgba_getb(c) != b) {
    RGB rgb;

    ase_current_palette->setEntry(index, rgba(r, g, b, 255));

    rgb.r = r>>2;
    rgb.g = g>>2;
    rgb.b = b>>2;

    set_color(index, &rgb);
  }
示例#15
0
// Creates a linear ramp in the palette.
void Palette::makeGradient(int from, int to)
{
  int r, g, b, a;
  int r1, g1, b1, a1;
  int r2, g2, b2, a2;
  int i, n;

  ASSERT(from >= 0 && from <= 255);
  ASSERT(to >= 0 && to <= 255);

  if (from > to)
    std::swap(from, to);

  n = to - from;
  if (n < 2)
    return;

  r1 = rgba_getr(getEntry(from));
  g1 = rgba_getg(getEntry(from));
  b1 = rgba_getb(getEntry(from));
  a1 = rgba_geta(getEntry(from));

  r2 = rgba_getr(getEntry(to));
  g2 = rgba_getg(getEntry(to));
  b2 = rgba_getb(getEntry(to));
  a2 = rgba_geta(getEntry(to));

  for (i=from+1; i<to; ++i) {
    r = r1 + (r2-r1) * (i-from) / n;
    g = g1 + (g2-g1) * (i-from) / n;
    b = b1 + (b2-b1) * (i-from) / n;
    a = a1 + (a2-a1) * (i-from) / n;

    setEntry(i, rgba(r, g, b, a));
  }
}
示例#16
0
static void
render_gradient_rect_without_gamma_correction(render_context *ctx, rect2 rect) {
    i32 minx = (i32) (rect.min.x);
    i32 miny = (i32) (rect.min.y);
    i32 maxx = (i32) (rect.max.x);
    i32 maxy = (i32) (rect.max.y);

    if (minx < 0) { minx = 0; }
    if (maxx >= ctx->width) { maxx = ctx->width; }
    if (miny < 0) { miny = 0; }
    if (maxy >= ctx->height) { maxy = ctx->height; }

    u32 *row = ctx->buf + (ctx->height - 1 - miny) * ctx->width + minx;
    i32 size = maxx - minx;
    for (i32 y = miny; y < maxy; ++y) {
        u32 *pixel = row;
        for (i32 x = minx; x < maxx; ++x) {
            f32 intensity = (x - minx) * 1.0f / size;
            u32 color = rgba_to_u32(rgba(intensity, intensity, intensity, 1.0f));
            *pixel++ = color;
        }
        row -= ctx->width;
    }
}
示例#17
0
raster::color_t color_utils::color_for_image(const app::Color& color, PixelFormat format)
{
  if (color.getType() == app::Color::MaskType)
    return 0;

  raster::color_t c = -1;

  switch (format) {
    case IMAGE_RGB:
      c = rgba(color.getRed(), color.getGreen(), color.getBlue(), 255);
      break;
    case IMAGE_GRAYSCALE:
      c = graya(color.getGray(), 255);
      break;
    case IMAGE_INDEXED:
      if (color.getType() == app::Color::IndexType)
        c = color.getIndex();
      else
        c = get_current_palette()->findBestfit(color.getRed(), color.getGreen(), color.getBlue());
      break;
  }

  return c;
}
示例#18
0
    void create_palette(std::vector<rgba> & palette)
    {
        sorted_pal_.clear();
        if (has_holes_)
        {
            max_colors_--;
            sorted_pal_.push_back(rgba(0,0,0,0));
        }
        assign_node_colors();

        sorted_pal_.reserve(colors_);
        create_palette_rek(sorted_pal_, root_.get());

        // sort palette for binary searching in quantization
        std::sort(sorted_pal_.begin(), sorted_pal_.end(), rgba::mean_sort_cmp());
        // returned palette is rearanged, so that colors with a<255 are at the begining
        pal_remap_.resize(sorted_pal_.size());
        palette.clear();
        palette.reserve(sorted_pal_.size());
        for (unsigned i=0; i<sorted_pal_.size(); ++i)
        {
            if (sorted_pal_[i].a<255)
            {
                pal_remap_[i] = static_cast<unsigned>(palette.size());
                palette.push_back(sorted_pal_[i]);
            }
        }
        for (unsigned i=0; i<sorted_pal_.size(); ++i)
        {
            if (sorted_pal_[i].a==255)
            {
                pal_remap_[i] = static_cast<unsigned>(palette.size());
                palette.push_back(sorted_pal_[i]);
            }
        }
    }
示例#19
0
文件: color.hpp 项目: duzy/ds.ge
 static inline color bgr( float b, float g, float r )
 {
   return rgba( r, g, b, 1.0 );
 }
示例#20
0
文件: color.hpp 项目: duzy/ds.ge
 static inline color rgb( float r, float g, float b )
 {
   return rgba( r, g, b, 1.0 );
 }
示例#21
0
文件: color.hpp 项目: duzy/ds.ge
 static inline color argb( float a, float r, float g, float b )
 {
   return rgba( r, g, b, a );
 }
示例#22
0
文件: gui.cpp 项目: rtmpnewbie/gnash
bool
Gui::display(movie_root* m)
{
    assert(m == _stage); // why taking this arg ??

    assert(_started);
    
    InvalidatedRanges changed_ranges;
    bool redraw_flag;
    
    // Should the frame be rendered completely, even if it did not change?
#ifdef FORCE_REDRAW
    redraw_flag = true;
#else	
    redraw_flag = _redraw_flag || want_redraw();
#endif	
    
    // reset class member if we do a redraw now
    if (redraw_flag) _redraw_flag=false;
    
    // Find out the surrounding frame of all characters which
    // have been updated. This just checks what region of the stage has changed
    // due to ActionScript code, the timeline or user events. The GUI can still
    // choose to render a different part of the stage. 
    //
    if (!redraw_flag) {
        
        // choose snapping ranges factor 
        changed_ranges.setSnapFactor(1.3f);  
	
        // Use multi ranges only when GUI/Renderer supports it
        // (Useless CPU overhead, otherwise)
        changed_ranges.setSingleMode(!want_multiple_regions());
        
        // scan through all sprites to compute invalidated bounds  
        m->add_invalidated_bounds(changed_ranges, false);
	
        // grow ranges by a 2 pixels to avoid anti-aliasing issues		
        changed_ranges.growBy(40.0f / _xscale);
	
        // optimize ranges
        changed_ranges.combineRanges();	
    }
    
    // TODO: Remove this and want_redraw to avoid confusion!?
    if (redraw_flag)  {
        changed_ranges.setWorld();
    }
    
    // DEBUG ONLY:
    // This is a good place to inspect the invalidated bounds state. Enable
    // the following block (and parts of it) if you need to. 
#if 0
    {
        // This may print a huge amount of information, but is useful to analyze
        // the (visible) object structure of the movie and the flags of the
        // characters. For example, a characters should have set the 
        // m_child_invalidated flag if at least one of it's childs has the
        // invalidated flag set.
        log_debug("DUMPING CHARACTER TREE"); 
        
        InfoTree tr;
        InfoTree::iterator top = tr.begin();
        _stage->getMovieInfo(tr, top);
        
        for (InfoTree::iterator i = tr.begin(), e = tr.end();
             i != e; ++i) {
            std::cout << std::string(tr.depth(i) * 2, ' ') << i->first << ": " << 
                i->second << std::endl;
        }
        
        
        // less verbose, and often necessary: see the exact coordinates of the
        // invalidated bounds (mainly to see if it's NULL or something else).	
        std::cout << "Calculated changed ranges: " << changed_ranges << "\n";
    }
#endif
    
    // Avoid drawing of stopped movies
    if ( ! changed_ranges.isNull() ) { // use 'else'?
        // Tell the GUI(!) that we only need to update this
        // region. Note the GUI can do whatever it wants with
        // this information. It may simply ignore the bounds
        // (which will normally lead into a complete redraw),
        // or it may extend or shrink the bounds as it likes. So,
        // by calling set_invalidated_bounds we have no guarantee
        // that only this part of the stage is rendered again.
#ifdef REGION_UPDATES_DEBUGGING_FULL_REDRAW
        // redraw the full screen so that only the
        // *new* invalidated region is visible
        // (helps debugging)
        InvalidatedRanges world_ranges;
        world_ranges.setWorld();
        setInvalidatedRegions(world_ranges);
#else
        setInvalidatedRegions(changed_ranges);
#endif
        
        // TODO: should this be called even if we're late ?
        beforeRendering();
        
        // Render the frame, if not late.
        // It's up to the GUI/renderer combination
        // to do any clipping, if desired.     
        m->display();
        
        // show invalidated region using a red rectangle
        // (Flash debug style)
        IF_DEBUG_REGION_UPDATES (
            if (_renderer.get() && !changed_ranges.isWorld()) {
                for (size_t rno = 0; rno < changed_ranges.size(); rno++) {
                    const geometry::Range2d<int>& bounds = 
                        changed_ranges.getRange(rno);
                    
                    float xmin = bounds.getMinX();
                    float xmax = bounds.getMaxX();
                    float ymin = bounds.getMinY();
                    float ymax = bounds.getMaxY();
                    
                    const std::vector<point> box = {
                        point(xmin, ymin),
                        point(xmax, ymin),
                        point(xmax, ymax),
                        point(xmin, ymax)
                    };
                    
                    _renderer->draw_poly(box, rgba(0,0,0,0), rgba(255,0,0,255),
                                         SWFMatrix(), false);
                    
                }
            }
        );
示例#23
0
uint32_t color::rgb(int r, int g, int b) {
	return rgba(r, g, b, 0xff);
}
示例#24
0
void wuline(SDL_Surface *surface,int x1,int y1,int x2,int y2, Uint32 pixel)
{
    double dx,dy,xend,yend,xgap,ygap,xpxl1,ypxl1,xpxl2,ypxl2,intery,interx,gradient, f;
    Uint8 alph;
    dx = x2-x1;
    dy = y2-y1;
    int ax,ay,a,b;
    Uint32 pixnoalph=(pixel&0x00FFFFFF);
    if(abs(dx) > abs(dy))
    {
        if(x2<x1)
        {
            ax=x1;
            x1= x2;
            x2 = ax;
            ay = y1;
            y1 = y2;
            y2 = ay;
        }
        gradient=dy/dx;
        xend=ceil(x1);
        yend=y1+gradient*(xend-x1);
        xgap = 1.0-fract(x1 + 0.5);
        xpxl1 = xend;
        ypxl1 = floor(yend);
        f=1.0-fract(yend)*xgap;
        alph=lerp(rgba(get_dot(surface,xpxl1,ypxl1)),rgba(pixel),f);
        dot(surface,xpxl1,ypxl1,pixnoalph|(alph<<24));
        f = fract(yend)*xgap;
        alph=lerp(rgba(get_dot(surface,xpxl1,ypxl1+1)),rgba(pixel),f);
        dot(surface,xpxl1,ypxl1+1,pixnoalph|(alph<<24));
        intery = yend + gradient;
        xend = ceil(x2);
        yend = y2 + gradient * (xend-x2);
        xgap = 1.0 - fract(x2 + 0.5);
        xpxl2 = xend;
        ypxl2 = (int)(yend);
        f = 1.0-fract(yend)*xgap;
        alph=lerp(rgba(get_dot(surface,xpxl2,ypxl2)),rgba(pixel),f);
        dot(surface,xpxl2,ypxl2,pixnoalph|(alph<<24));
        f = fract(yend)*xgap;
        alph=lerp(rgba(get_dot(surface,xpxl2,ypxl2+1)),rgba(pixel),f);
        dot(surface,xpxl2,ypxl2+1,pixnoalph|(alph<<24));


        a = xpxl1+1;
        b = xpxl2-1;
        for(int x=a;x<=b;x++)
        {

            f = 1.0-fract(intery);
            alph=lerp(rgba(get_dot(surface,x,intery)),rgba(pixel),f);
            dot(surface,x,intery,pixnoalph|(alph<<24));


            f = fract(intery);
            alph=lerp(rgba(get_dot(surface,x,intery+1)),rgba(pixel),f);
            dot(surface,x,intery+1,pixnoalph|(alph<<24));

            intery = intery + gradient;

        }

    }else{
        if(y2 < y1)
        {

            ax = x1;
            x1 = x2;
            x2 = ax;
            ay = y1;
            y1 = y2;
            y2 = ay;
        }

        gradient = dx / dy;

        yend = ceil(y1);
        xend = x1 + gradient * (yend-y1);
        ygap = 1.0 - fract(y1 + 0.5);
        xpxl1 = (int)(xend);
        ypxl1 = yend;
        f = 1.0-fract(xend)*ygap;
        alph=lerp(rgba(get_dot(surface,xpxl1, ypxl1)),rgba(pixel),f);
        dot(surface,xpxl1, ypxl1,pixnoalph|(alph<<24));

        f = fract(xend)*ygap;
        alph=lerp(rgba(get_dot(surface,xpxl1, ypxl1+1)),rgba(pixel),f);
        dot(surface,xpxl1, ypxl1+1,pixnoalph|(alph<<24));

        interx = xend + gradient;

        yend = ceil(y2);
        xend = x2 + gradient * (yend-y2);
        ygap = fract(y2 + 0.5);
        xpxl2 = (int)(xend);
        ypxl2 = yend;
        f = 1.0-fract(xend)*ygap;
        alph=lerp(rgba(get_dot(surface,xpxl2, ypxl2)),rgba(pixel),f);
        dot(surface,xpxl2, ypxl2,pixnoalph|(alph<<24));

        f = fract(xend)*ygap;
        alph=lerp(rgba(get_dot(surface,xpxl2, ypxl2+1)),rgba(pixel),f);
        dot(surface,xpxl2, ypxl2+1,pixnoalph|(alph<<24));


        a = ypxl1+1;
        b = ypxl2-1;
        for(int y=a;y<=b;y++)
        {

            f = 1.0-fract(interx);
            alph=lerp(rgba(get_dot(surface,interx,y)),rgba(pixel),f);
            dot(surface,interx,y,pixnoalph|(alph<<24));

            f = fract(interx);
            alph=lerp(rgba(get_dot(surface,interx+1,y)),rgba(pixel),f);
            dot(surface,interx+1,y,pixnoalph|(alph<<24));
            interx = interx + gradient;
        }
    }
}
示例#25
0
文件: osgvolume.cpp 项目: ChrisWC/osg
 inline void alpha(float a) const { rgba(1.0f,1.0f,1.0f,a); }
示例#26
0
void rgba::set(const rgba_channel red, const rgba_channel green, const rgba_channel blue, const rgba_channel alpha) {
	*this = rgba(red, green, blue, alpha);
}
示例#27
0
int main (int argc, char ** argv) {
	init_shmemfonts();

	yutani_t * y = yutani_init();

	if (!y) {
		fprintf(stderr, "[glogin] Connection to server failed.\n");
		return 1;
	}

	/* Load config */
	{
		confreader_t * conf = confreader_load("/etc/glogin.conf");

		LOGO_FINAL_OFFSET = confreader_intd(conf, "style", "logo_padding", LOGO_FINAL_OFFSET);
		BOX_WIDTH = confreader_intd(conf, "style", "box_width", BOX_WIDTH);
		BOX_HEIGHT = confreader_intd(conf, "style", "box_height", BOX_HEIGHT);
		BOX_ROUNDNESS = confreader_intd(conf, "style", "box_roundness", BOX_ROUNDNESS);
		CENTER_BOX_X = confreader_intd(conf, "style", "center_box_x", CENTER_BOX_X);
		CENTER_BOX_Y = confreader_intd(conf, "style", "center_box_y", CENTER_BOX_Y);
		BOX_LEFT = confreader_intd(conf, "style", "box_left", BOX_LEFT);
		BOX_RIGHT = confreader_intd(conf, "style", "box_right", BOX_RIGHT);
		BOX_TOP = confreader_intd(conf, "style", "box_top", BOX_TOP);
		BOX_BOTTOM = confreader_intd(conf, "style", "box_bottom", BOX_BOTTOM);
		BOX_COLOR_R = confreader_intd(conf, "style", "box_color_r", BOX_COLOR_R);
		BOX_COLOR_G = confreader_intd(conf, "style", "box_color_g", BOX_COLOR_G);
		BOX_COLOR_B = confreader_intd(conf, "style", "box_color_b", BOX_COLOR_B);
		BOX_COLOR_A = confreader_intd(conf, "style", "box_color_a", BOX_COLOR_A);

		WALLPAPER = confreader_getd(conf, "image", "wallpaper", WALLPAPER);
		LOGO = confreader_getd(conf, "image", "logo", LOGO);

		confreader_free(conf);

		TRACE("Loading complete");
	}

	TRACE("Loading logo...");
	load_sprite_png(&logo, LOGO);
	TRACE("... done.");

	/* Generate surface for background */
	sprite_t * bg_sprite;

	int width  = y->display_width;
	int height = y->display_height;
	int skip_animation = 0;

	/* Do something with a window */
	TRACE("Connecting to window server...");
	yutani_window_t * wina = yutani_window_create(y, width, height);
	assert(wina);
	yutani_set_stack(y, wina, 0);
	ctx = init_graphics_yutani_double_buffer(wina);
	draw_fill(ctx, rgba(0,0,0,255));
	yutani_flip(y, wina);
	TRACE("... done.");


redo_everything:
	win_width = width;
	win_height = height;

	cairo_surface_t * cs = cairo_image_surface_create_for_data((void*)ctx->backbuffer, CAIRO_FORMAT_ARGB32, ctx->width, ctx->height, cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, ctx->width));
	cairo_t * cr = cairo_create(cs);


	TRACE("Loading wallpaper...");
	{
		sprite_t * wallpaper = malloc(sizeof(sprite_t));
		load_sprite_png(wallpaper, WALLPAPER);

		float x = (float)width  / (float)wallpaper->width;
		float y = (float)height / (float)wallpaper->height;

		int nh = (int)(x * (float)wallpaper->height);
		int nw = (int)(y * (float)wallpaper->width);;

		bg_sprite = create_sprite(width, height, ALPHA_OPAQUE);
		gfx_context_t * bg = init_graphics_sprite(bg_sprite);

		if (nw > width) {
			draw_sprite_scaled(bg, wallpaper, (width - nw) / 2, 0, nw, height);
		} else {
			draw_sprite_scaled(bg, wallpaper, 0, (height - nh) / 2, width, nh);
		}

		/* Three box blurs = good enough approximation of a guassian, but faster*/
		blur_context_box(bg, 20);
		blur_context_box(bg, 20);
		blur_context_box(bg, 20);

		free(bg);
		free(wallpaper);
	}
	TRACE("... done.");

	while (1) {

		yutani_set_stack(y, wina, 0);
		yutani_focus_window(y, wina->wid);

		draw_fill(ctx, rgb(0,0,0));
		draw_sprite(ctx, bg_sprite, center_x(width), center_y(height));
		flip(ctx);
		yutani_flip(y, wina);

		char * foo = malloc(sizeof(uint32_t) * width * height);
		memcpy(foo, ctx->backbuffer, sizeof(uint32_t) * width * height);

		TRACE("Begin animation.");
		if (!skip_animation) {
			struct timeval start;
			gettimeofday(&start, NULL);

			while (1) {
				uint32_t tick;
				struct timeval t;
				gettimeofday(&t, NULL);

				uint32_t sec_diff = t.tv_sec - start.tv_sec;
				uint32_t usec_diff = t.tv_usec - start.tv_usec;

				if (t.tv_usec < start.tv_usec) {
					sec_diff -= 1;
					usec_diff = (1000000 + t.tv_usec) - start.tv_usec;
				}

				tick = (uint32_t)(sec_diff * 1000 + usec_diff / 1000);
				int i = (float)LOGO_FINAL_OFFSET * (float)tick / 700.0f;
				if (i >= LOGO_FINAL_OFFSET) break;

				memcpy(ctx->backbuffer, foo, sizeof(uint32_t) * width * height);
				draw_sprite(ctx, &logo, center_x(logo.width), center_y(logo.height) - i);
				flip(ctx);
				yutani_flip_region(y, wina, center_x(logo.width), center_y(logo.height) - i, logo.width, logo.height + 5);
				usleep(10000);
			}
		}
		TRACE("End animation.");
		skip_animation = 0;

		size_t buf_size = wina->width * wina->height * sizeof(uint32_t);
		char * buf = malloc(buf_size);

		uint32_t i = 0;

		uint32_t black = rgb(0,0,0);
		uint32_t white = rgb(255,255,255);

		int x_offset = 65;
		int y_offset = 64;

		int fuzz = 3;

		char username[INPUT_SIZE] = {0};
		char password[INPUT_SIZE] = {0};
		char hostname[512];

		// we do it here to calculate the final string position
		get_updated_hostname_with_time_info(hostname);

		char kernel_v[512];

		{
			struct utsname u;
			uname(&u);
			/* UTF-8 Strings FTW! */
			uint8_t * os_name_ = "とあるOS";
			uint32_t l = snprintf(kernel_v, 512, "%s %s", os_name_, u.release);
		}

		uid = 0;

		int box_x, box_y;

		if (CENTER_BOX_X) {
			box_x = center_x(BOX_WIDTH);
		} else if (BOX_LEFT == -1) {
			box_x = win_width - BOX_RIGHT - BOX_WIDTH;
		} else {
			box_x = BOX_LEFT;
		}
		if (CENTER_BOX_Y) {
			box_y = center_y(0) + 8;
		} else if (BOX_TOP == -1) {
			box_y = win_width - BOX_BOTTOM - BOX_HEIGHT;
		} else {
			box_y = BOX_TOP;
		}

		int focus = 0;

		set_font_size(11);
		int hostname_label_left = width - 10 - draw_string_width(hostname);
		int kernel_v_label_left = 10;

		struct text_box username_box = { (BOX_WIDTH - 170) / 2, 30, 170, 20, rgb(0,0,0), NULL, 0, 0, 0, username, "Username" };
		struct text_box password_box = { (BOX_WIDTH - 170) / 2, 58, 170, 20, rgb(0,0,0), NULL, 0, 1, 0, password, "Password" };

		struct login_container lc = { box_x, box_y, BOX_WIDTH, BOX_HEIGHT, &username_box, &password_box, 0 };

		username_box.parent = &lc;
		password_box.parent = &lc;

		while (1) {
			focus = 0;
			memset(username, 0x0, INPUT_SIZE);
			memset(password, 0x0, INPUT_SIZE);

			while (1) {

				// update time info
				get_updated_hostname_with_time_info(hostname);

				memcpy(ctx->backbuffer, foo, sizeof(uint32_t) * width * height);
				draw_sprite(ctx, &logo, center_x(logo.width), center_y(logo.height) - LOGO_FINAL_OFFSET);

				set_font_size(11);
				draw_string_shadow(ctx, hostname_label_left, height - 12, white, hostname, rgb(0,0,0), 2, 1, 1, 3.0);
				draw_string_shadow(ctx, kernel_v_label_left, height - 12, white, kernel_v, rgb(0,0,0), 2, 1, 1, 3.0);

				if (focus == USERNAME_BOX) {
					username_box.is_focused = 1;
					password_box.is_focused = 0;
				} else if (focus == PASSWORD_BOX) {
					username_box.is_focused = 0;
					password_box.is_focused = 1;
				} else {
					username_box.is_focused = 0;
					password_box.is_focused = 0;
				}

				draw_login_container(cr, &lc);

				flip(ctx);
				yutani_flip(y, wina);

				struct yutani_msg_key_event kbd;
				struct yutani_msg_window_mouse_event mou;
				int msg_type = 0;
collect_events:
				do {
					yutani_msg_t * msg = yutani_poll(y);
					switch (msg->type) {
						case YUTANI_MSG_KEY_EVENT:
							{
								struct yutani_msg_key_event * ke = (void*)msg->data;
								if (ke->event.action == KEY_ACTION_DOWN) {
									memcpy(&kbd, ke, sizeof(struct yutani_msg_key_event));
									msg_type = 1;
								}
							}
							break;
						case YUTANI_MSG_WINDOW_MOUSE_EVENT:
							{
								struct yutani_msg_window_mouse_event * me = (void*)msg->data;
								memcpy(&mou, me, sizeof(struct yutani_msg_mouse_event));
								msg_type = 2;
							}
							break;
						case YUTANI_MSG_WELCOME:
							{
								struct yutani_msg_welcome * mw = (void*)msg->data;
								yutani_window_resize(y, wina, mw->display_width, mw->display_height);
							}
							break;
						case YUTANI_MSG_RESIZE_OFFER:
							{
								struct yutani_msg_window_resize * wr = (void*)msg->data;
								width = wr->width;
								height = wr->height;
								yutani_window_resize_accept(y, wina, width, height);
								reinit_graphics_yutani(ctx, wina);
								yutani_window_resize_done(y, wina);

								sprite_free(bg_sprite);
								cairo_destroy(cr);
								cairo_surface_destroy(cs);

								skip_animation = 1;
								goto redo_everything;
							}
							break;
					}
					free(msg);
				} while (!msg_type);

				if (msg_type == 1) {

					if (kbd.event.keycode == '\n') {
						if (focus == USERNAME_BOX) {
							focus = PASSWORD_BOX;
							continue;
						} else if (focus == PASSWORD_BOX) {
							break;
						} else {
							focus = USERNAME_BOX;
							continue;
						}
					}

					if (kbd.event.keycode == '\t') {
						if (focus == USERNAME_BOX) {
							focus = PASSWORD_BOX;
						} else {
							focus = USERNAME_BOX;
						}
						continue;
					}

					if (kbd.event.key) {

						if (!focus) {
							focus = USERNAME_BOX;
						}

						if (focus == USERNAME_BOX) {
							buffer_put(username, kbd.event.key);
						} else if (focus == PASSWORD_BOX) {
							buffer_put(password, kbd.event.key);
						}

					}

				} else if (msg_type == 2) {

					if ((mou.command == YUTANI_MOUSE_EVENT_DOWN
					     && mou.buttons & YUTANI_MOUSE_BUTTON_LEFT)
					    || (mou.command == YUTANI_MOUSE_EVENT_CLICK)) {
						/* Determine if we were inside of a text box */

						if (mou.new_x >= lc.x + username_box.x &&
						    mou.new_x <= lc.x + username_box.x + username_box.width &&
						    mou.new_y >= lc.y + username_box.y &&
						    mou.new_y <= lc.y + username_box.y + username_box.height) {
							/* Ensure this box is focused. */
							focus = USERNAME_BOX;
							continue;
						} else if (mou.new_x >= lc.x + password_box.x &&
						    mou.new_x <= lc.x + password_box.x + password_box.width &&
						    mou.new_y >= lc.y + password_box.y &&
						    mou.new_y <= lc.y + password_box.y + password_box.height) {
							/* Ensure this box is focused. */
							focus = PASSWORD_BOX;
							continue;
						} else {
							focus = 0;
							continue;
						}

					} else {
						goto collect_events;
					}
				}

			}

			uid = toaru_auth_check_pass(username, password);

			if (uid >= 0) {
				break;
			}
			lc.show_error = 1;
		}

		memcpy(ctx->backbuffer, foo, sizeof(uint32_t) * width * height);
		flip(ctx);
		yutani_flip(y, wina);
		syscall_yield();

		pid_t _session_pid = fork();
		if (!_session_pid) {
			setuid(uid);
			toaru_auth_set_vars();
			char * args[] = {"/bin/gsession", NULL};
			execvp(args[0], args);
		}

		free(foo);
		free(buf);

		waitpid(_session_pid, NULL, 0);
	}

	yutani_close(y, wina);


	return 0;
}
示例#28
0
文件: osgvolume.cpp 项目: ChrisWC/osg
 inline void rgb(float r,float g,float b) const { rgba(r,g,b,1.0f); }
示例#29
0
文件: osgvolume.cpp 项目: ChrisWC/osg
 inline void luminance_alpha(float l,float a) const { rgba(l,l,l,a);  }
示例#30
0
void Raytracer::displayCallback() 
{

	updateCamera();

	for (int i=0;i<numObjects;i++)
	{
		transforms[i].setIdentity();
		btVector3	pos(0.f,0.f,-(2.5* numObjects * 0.5)+i*2.5f);
		transforms[i].setOrigin( pos );
		btQuaternion orn;
		if (i < 2)
		{
			orn.setEuler(yaw,pitch,roll);
			transforms[i].setRotation(orn);
		}
	}

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
	glDisable(GL_LIGHTING);
	if (!m_initialized)
	{
		m_initialized = true;
		glGenTextures(1, &glTextureId);
	}
	
	glBindTexture(GL_TEXTURE_2D,glTextureId );
	
	glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	
	glDisable(GL_TEXTURE_2D);
	glDisable(GL_BLEND);


	btVector4 rgba(1.f,0.f,0.f,0.5f);

	float top = 1.f;
	float bottom = -1.f;
	float nearPlane = 1.f;

	float tanFov = (top-bottom)*0.5f / nearPlane;

	float fov = 2.0 * atanf (tanFov);


	btVector3	rayFrom = getCameraPosition();
	btVector3 rayForward = getCameraTargetPosition()-getCameraPosition();
	rayForward.normalize();
	float farPlane = 600.f;
	rayForward*= farPlane;

	btVector3 rightOffset;
	btVector3 vertical(0.f,1.f,0.f);
	btVector3 hor;
	hor = rayForward.cross(vertical);
	hor.normalize();
	vertical = hor.cross(rayForward);
	vertical.normalize();

	float tanfov = tanf(0.5f*fov);

	hor *= 2.f * farPlane * tanfov;
	vertical *= 2.f * farPlane * tanfov;

	btVector3 rayToCenter = rayFrom + rayForward;

	btVector3 dHor = hor * 1.f/float(screenWidth);
	btVector3 dVert = vertical * 1.f/float(screenHeight);

	btTransform rayFromTrans;
	rayFromTrans.setIdentity();
	rayFromTrans.setOrigin(rayFrom);

	btTransform rayFromLocal;
	btTransform	rayToLocal;




	int x;

	///clear texture
	for (x=0;x<screenWidth;x++)
	{
		for (int y=0;y<screenHeight;y++)
		{
			btVector4 rgba(0.2f,0.2f,0.2f,1.f);
			raytracePicture->setPixel(x,y,rgba);
		}
	}

#if 1
	btVector3 rayTo;
	btTransform colObjWorldTransform;
	colObjWorldTransform.setIdentity();

	int	mode = 0;

	for (x=0;x<screenWidth;x++)
	{
		for (int y=0;y<screenHeight;y++)
		{

			rayTo = rayToCenter - 0.5f * hor + 0.5f * vertical;
			rayTo += x * dHor;
			rayTo -= y * dVert;
			btVector3	worldNormal(0,0,0);
			btVector3	worldPoint(0,0,0);



			bool hasHit = false;
			int mode = 0;
			switch (mode)
			{
			case 0:
				hasHit = lowlevelRaytest(rayFrom,rayTo,worldNormal,worldPoint);
				break;
			case 1:
				hasHit = singleObjectRaytest(rayFrom,rayTo,worldNormal,worldPoint);
				break;
			case 2:
				hasHit = worldRaytest(rayFrom,rayTo,worldNormal,worldPoint);
				break;
			default:
				{
				}
			}

			if (hasHit)
			{
				float lightVec0 = worldNormal.dot(btVector3(0,-1,-1));//0.4f,-1.f,-0.4f));
				float lightVec1= worldNormal.dot(btVector3(-1,0,-1));//-0.4f,-1.f,-0.4f));


				rgba = btVector4(lightVec0,lightVec1,0,1.f);
				rgba.setMin(btVector3(1,1,1));
				rgba.setMax(btVector3(0.2,0.2,0.2));
				rgba[3] = 1.f;
				raytracePicture->setPixel(x,y,rgba);
			} else
				btVector4 rgba = raytracePicture->getPixel(x,y);
			if (!rgba.length2())
			{
				raytracePicture->setPixel(x,y,btVector4(1,1,1,1));
			}
		}
	}
#endif

extern unsigned char sFontData[];
	if (0)
	{

		const char* text="ABC abc 123 !@#";
			int x=0;
		for (int cc = 0;cc<strlen(text);cc++)
		{
		
			char testChar = text[cc];//'b';
			char ch = testChar-32;
			int startx=ch%16;
			int starty=ch/16;


			//for (int i=0;i<256;i++)
			for (int i=startx*16;i<(startx*16+16);i++)
			{
				int y=0;
				//for (int j=0;j<256;j++)
				//for (int j=0;j<256;j++)
				for (int j=starty*16;j<(starty*16+16);j++)
				{
					
					btVector4 rgba(0,0,0,1);
					rgba[0] = (sFontData[i*3+255*256*3-(256*j)*3])/255.f;
					//rgba[0] += (sFontData[(i+1)*3+255*256*3-(256*j)*3])/255.*0.25f;
					//rgba[0] += (sFontData[(i)*3+255*256*3-(256*j+1)*3])/255.*0.25f;
					//rgba[0] += (sFontData[(i+1)*3+255*256*3-(256*j+1)*3])/255.*0.25;

					//if (rgba[0]!=0.f)
					{
						rgba[1]=rgba[0];
						rgba[2]=rgba[0];
						rgba[3]=1.f;

						//raytracePicture->setPixel(x,y,rgba);
						raytracePicture->addPixel(x,y,rgba);
					}
					y++;
				}
				x++;
			}
		}
	}


	//raytracePicture->grapicalPrintf("CCD RAYTRACER",sFontData);
	char buffer[256];
	sprintf(buffer,"%d rays",screenWidth*screenHeight*numObjects);
	//sprintf(buffer,"Toggle",screenWidth*screenHeight*numObjects);
	//sprintf(buffer,"TEST",screenWidth*screenHeight*numObjects);
	//raytracePicture->grapicalPrintf(buffer,sFontData,0,10);//&BMF_font_helv10,0,10);
	raytracePicture->grapicalPrintf(buffer,sFontData,0,0);//&BMF_font_helv10,0,10);


	glMatrixMode(GL_PROJECTION);
	glPushMatrix();
	glLoadIdentity();
	glFrustum(-1.0,1.0,-1.0,1.0,3,2020.0);

	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();
	glLoadIdentity();									// reset The Modelview Matrix
	glTranslatef(0.0f,0.0f,-3.1f);						// Move Into The Screen 5 Units



	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D,glTextureId );

	const unsigned char *ptr = raytracePicture->getBuffer();
	glTexImage2D(GL_TEXTURE_2D, 
		0, 
		GL_RGBA, 
		raytracePicture->getWidth(),raytracePicture->getHeight(), 
		0, 
		GL_RGBA, 
		GL_UNSIGNED_BYTE, 
		ptr);


	glEnable (GL_BLEND);
	glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glColor4f (1,1,1,1); // alpha=0.5=half visible

	glBegin(GL_QUADS);
	glTexCoord2f(0.0f, 0.0f);
	glVertex2f(-1,1);
	glTexCoord2f(1.0f, 0.0f);
	glVertex2f(1,1);
	glTexCoord2f(1.0f, 1.0f);
	glVertex2f(1,-1);
	glTexCoord2f(0.0f, 1.0f);
	glVertex2f(-1,-1);
	glEnd();



	glMatrixMode(GL_MODELVIEW);
	glPopMatrix();
	glMatrixMode(GL_PROJECTION);
	glPopMatrix();
	glMatrixMode(GL_MODELVIEW);


	glDisable(GL_TEXTURE_2D);
	glDisable(GL_DEPTH_TEST);

	GL_ShapeDrawer::drawCoordSystem();



	{
		for (int i=0;i<numObjects;i++)
		{
			btVector3 aabbMin,aabbMax;
			shapePtr[i]->getAabb(transforms[i],aabbMin,aabbMax);
		}
	}

	glPushMatrix();




	glPopMatrix();

	pitch += 0.005f;
	yaw += 0.01f;
	m_azi += 1.f;

	glFlush();
	glutSwapBuffers();
}