コード例 #1
0
int main( int argc, char* args[] )
{
    Render render;
    
    render.init();
    
    int i = 0;
    
    while(render.running)
    {
        render.event();
        render.draw();
        
        if((render.checkNow)&&(i == render.speed))
        {
            render.check();
        }
        
        i++;
        if(i > render.speed) i = 0;
    }
    
    
    //Quit SDL
    SDL_Quit();
    
    return 0;
}
コード例 #2
0
ファイル: render.cpp プロジェクト: tempbottle/kj2
/*! jesli widoczny to go narysuje
*/
void SpriteCmp::draw( Entity e , const ShapeDef& shapeDef)
{
  SpriteInfo * spriteInfo = 0;
  if(e.getId() == 0)
  {
    spriteInfo = &untexturedSprite;
  }else{
    spriteInfo = BaseType::get( e );
    if( ! spriteInfo )  return;
  }
  Render * r = game->getRender();

  if( spriteInfo->visible )
  {
    Vec2Quad shape;
    translateQuad( shapeDef.rect, shapeDef.pos, &shape );
    if(shapeDef.angle)
      rotateQuad(shape,shapeDef.angle,shapeDef.pos,&shape);
    r->drawAtlas( spriteInfo->tex,
                  spriteInfo->textureNumber, shape,
                  Render::CoordSpace_e( spriteInfo->coordSpace ),
                  spriteInfo->color,
                  shapeDef.depth );
  }
}
コード例 #3
0
ファイル: render_tests.cpp プロジェクト: aseprite/aseprite
TEST(Render, DefaultBackgroundModeWithNonzeroTransparentIndex)
{
  Document* doc = new Document;
  doc->sprites().add(Sprite::createBasicSprite(ImageSpec(ColorMode::INDEXED, 2, 2)));
  doc->sprite()->setTransparentColor(2); // Transparent color is index 2

  EXPECT_TRUE(!doc->sprite()->root()->firstLayer()->isBackground());
  Image* src = doc->sprite()->root()->firstLayer()->cel(0)->image();
  clear_image(src, 2);
  put_pixel(src, 1, 1, 1);

  std::unique_ptr<Image> dst(Image::create(IMAGE_INDEXED, 2, 2));
  clear_image(dst.get(), 1);
  EXPECT_2X2_PIXELS(dst.get(), 1, 1, 1, 1);

  Render render;
  render.renderSprite(dst.get(), doc->sprite(), frame_t(0));
  EXPECT_2X2_PIXELS(dst.get(), 2, 2, 2, 1); // Indexed transparent

  dst.reset(Image::create(IMAGE_RGB, 2, 2));
  clear_image(dst.get(), 1);
  EXPECT_2X2_PIXELS(dst.get(), 1, 1, 1, 1);
  render.renderSprite(dst.get(), doc->sprite(), frame_t(0));
  color_t c1 = doc->sprite()->palette(0)->entry(1);
  EXPECT_NE(0, c1);
  EXPECT_2X2_PIXELS(dst.get(), 0, 0, 0, c1); // RGB transparent
}
コード例 #4
0
void SpriteRenderer::RenderOnScreen()
{
	Render* render = Render::getInstance();
	int drawX = static_cast<int>(entity->GetTransform()->GetPoint().GetX()) - (width / 2);
	int drawY = static_cast<int>(window->GetBox().GetHeight()) - (static_cast<int>(entity->GetTransform()->GetPoint().GetY()) + (height / 2));
	render->DrawTextureToScreen(image, window, drawX, drawY, width, height, imageCrop.GetX(), imageCrop.GetY(), imageCrop.GetWidth(), imageCrop.GetHeight(), entity->GetTransform()->GetRotation());
}
コード例 #5
0
void pymms::gui::GUIWindowManager::__render()
{
  Render* pRenderer = S_Render::get_instance();
  GUIWindow* pWindow = (!m_vecWindows.empty()?m_vecWindows.front():0);

  if(pWindow && pWindow->getActive())
  {
    if(!pWindow->getOverlay())
    {
      pRenderer->prepare_new_image();

      pWindow->render();

      pRenderer->draw_and_release("Window");
    }
    else
    {
     pRenderer->wait_and_aquire();

     if (m_windowOverlay.elements.size() > 0)
        m_windowOverlay.partial_cleanup();

     pWindow->render(&m_windowOverlay);

     pRenderer->draw_and_release("Window", true);
    }
  }
}
コード例 #6
0
void pymms::gui::GUIWindowManager::unregisterWindow(GUIWindow* pWindow)
{
  ost::MutexLock lock(m_windowManagerLock);

  Render* pRenderer = S_Render::get_instance();

  for (std::vector<GUIWindow*>::iterator i = m_vecWindows.begin(),
       end = m_vecWindows.end(); i != end; i++) {
    if((*i) == pWindow)
    {
      if(pWindow->getOverlay())
      {
          pRenderer->wait_and_aquire();
          m_windowOverlay.cleanup();
  	  pRenderer->image_mut.leaveMutex();
      }

      m_vecWindows.erase(i);
      pWindow->setActive(false);

      GUIWindow* pFrontWindow = (!m_vecWindows.empty()?m_vecWindows.front():0);
      if(pFrontWindow)
        pFrontWindow->setActive(true);
    
      __render();

      return;
    }
  }
}
コード例 #7
0
TrackballMaterial::~TrackballMaterial(){
	Render* r = Application::instance()->getRender();
	if (il)
		r->deleteIL(il);
	if (shader)
		r->deleteShader(shader);
}
コード例 #8
0
RenderPanel::RenderPanel(CommandQueue *c, MainWindow *mw)
{  
    cmdq = c;
    fundolb = new QLabel(this);

    screenW = 750;
    screenH = 550;

    Render *r = new Render(screenW, screenH, c);
    connect(r, SIGNAL(renderizado(const QImage &)), this, SLOT(update(const QImage &)), Qt::QueuedConnection);
    connect(r, SIGNAL(feedBackBondary(bool)),this, SLOT(feedBackBondary(bool)));
    connect(this, SIGNAL(atualizaTamanho(int, int)), r, SLOT(updateScreen(int, int)), Qt::QueuedConnection);
    connect(this, SIGNAL(enviaArquivo(const QString &)), r, SLOT(recebeArquivo(const QString &)), Qt::QueuedConnection);
    
    QImage tmp(screenW, screenH,QImage::Format_ARGB32_Premultiplied);
    QPainter p;
    p.begin(&tmp);
    p.fillRect(tmp.rect(), Qt::white);
    p.end();
    fundolb->setPixmap(QPixmap::fromImage(tmp));
    fundolb->show();

    m_mw = mw;

    repaint();
    r->start();
}
コード例 #9
0
ファイル: ast.c プロジェクト: chain78/none
void forNode(Node *node){
    Render *render = newRender();
    if(render){
        forNodeDrv(node,render);
        render->destroy(render);
    }
}
コード例 #10
0
ファイル: UITexture.cpp プロジェクト: CptAsgard/TomatoLib
	void UITexture::Draw(Render& p) {
		p.Box(0, 0, this->W, this->H, this->BackgroundColor);

		if (this->TextureHandle == 0) return;
		p.SetTexture(this->TextureHandle);
		p.PutTexture(0, 0, (float)this->W, (float)this->H, this->TextureStart.X, this->TextureStart.Y, this->TextureEnd.X, this->TextureEnd.Y, this->DrawColor);
	}
コード例 #11
0
ファイル: UIDropDown.cpp プロジェクト: CptAsgard/TomatoLib
	void UIDropDown::Draw(Render& p) {
		p.Box(0, 0, this->W, this->H, this->BorderColor);
		p.Box(1, 1, this->W - 2, this->H - 2, this->BackColor);

		Vector2 apos = this->GetAbsoluteLocation();
		p.SetDrawingOffset((int)apos.X + 2, (int)apos.Y);
		UILabel::Draw(p);
	}
コード例 #12
0
ファイル: Camera.cpp プロジェクト: romart/Qoom
void Camera::DrawInterface( void )
{
	render.Set2D();
	D3DXMATRIX mat;
	ZeroMemory( &mat, sizeof( mat ) );
	mat._11 = mat._22 = mat._33 = mat._44 = 1.0f;
	render.DrawIndexSurface( cursor_index, mat );
}
コード例 #13
0
ファイル: Render.cpp プロジェクト: GhaisB/Bomberman
void		*Render::run(void *data)
{
  Render	*render = (Render*) data;

  (void)data;
  render->setImg();
  render->sfmlLaunch();
  return (NULL);
}
コード例 #14
0
ファイル: external_engine.c プロジェクト: akonneker/blensor
int RE_engine_test_break(RenderEngine *engine)
{
	Render *re = engine->re;

	if (re)
		return re->test_break(re->tbh);
	
	return 0;
}
コード例 #15
0
ファイル: external_engine.c プロジェクト: akonneker/blensor
void RE_engine_update_result(RenderEngine *engine, RenderResult *result)
{
	Render *re = engine->re;

	if (result) {
		result->renlay = result->layers.first; /* weak, draws first layer always */
		re->display_update(re->duh, result, NULL);
	}
}
コード例 #16
0
ファイル: external_engine.c プロジェクト: akonneker/blensor
void RE_engine_update_progress(RenderEngine *engine, float progress)
{
	Render *re = engine->re;

	if (re) {
		CLAMP(progress, 0.0f, 1.0f);
		re->progress(re->prh, progress);
	}
}
コード例 #17
0
int main(int argc, char** argv)
{
	Render render;
	ScriptRunner * sr = ScriptRunner::getInstance();
	Logger * logger = Logger::getInstance();
	osg::ArgumentParser parser = osg::ArgumentParser(&argc, argv);
	string filename; // filename for script 
	

	if(parser.containsOptions()){
		//grabs the file name that is associated with the --script 
	parser.read("--script",filename);
		ifstream infile;
		infile.open(filename);
		sr->setActions(sr->parseScript(infile));
	}           
	/*
	if(parser.containsOptions()){
		int sLoc = parser.find("-s");
		int aLoc = parser.find("-a");
		int lLoc = parser.find("-l");
		if(sLoc > 0){
			if(parser.isString(sLoc+1)){
				std::ifstream infile;
				infile.open(parser[sLoc+1]);
				sr->setActions(sr->parseScript(infile));
				std::cout << parser[sLoc+1] << std::endl;
			 }
		}
		if(aLoc > 0){
			if(parser.isString(aLoc+1)){
				std::cout << parser[aLoc+1] << std::endl;
				std::ifstream infile;
				infile.open(parser[aLoc+1]);
				Constants::setConstantsFromFile(infile);
				std::cout << Constants::getInstance()->gravity << std::endl;
			 }
		}
		if(lLoc > 0)
		{
			if(parser.isString(lLoc+1))
			{
				logger->setFileName(parser[lLoc+1]);
			}
		}
		else
			{
				logger->setFileName("helicopterLog.txt");
			}
	}
	*/
	render.Game_Play();
	return 0;
}
コード例 #18
0
ファイル: Workarea.cpp プロジェクト: bsmr-worldforge/sear
void Workarea::resize()
{
  Render *render = RenderSystem::getInstance().getRenderer();
  int width = render->getWindowWidth(),
      height = render->getWindowHeight();
  m_graphics->setTargetPlane(width, height);
  m_top->resize(width, height, m_width, m_height);
  // m_top->setDimension(gcn::Rectangle(0, 0, width, height));
  m_width = width;
  m_height = height;
}
コード例 #19
0
ファイル: Mask.cpp プロジェクト: Gabriele91/Easy2D
void MaskSprite::draw()
{
    //draw childs
    Scene*  scene = getScene();
    Object* object = getObject();
    //
    if (object && scene && isVisible())
    {
        Render* render = dynamic_cast<Render*>(scene);
        Camera* camera = render->getCamera();
        //display/view camera
        const Mat4& disViewM4 = RenderContext::getDisplay().mul(camera->getGlobalMatrix());
        const AABox2& viewBox = camera->getBoxViewport();
        /////////////////////////////////////////////////////////////////////////////////////
        //new box pos
        AABox2 modelBox = getBox().applay(disViewM4);
        //culling
        if (!modelBox.isIntersection(viewBox)) return;
        /////////////////////////////////////////////////////////////////////////////////////
        //build queue
        queue->clear();
        //add all childs
        for (auto child : *object)
        queue->append([&](const AABox2& mbox) -> bool
        {
            const AABox2& wbox = mbox.applay(disViewM4);
            return modelBox.isIntersection(wbox);
        }, child);
        //draw filter
        RenderContext::setStencil(STENCIL_REPLACE);
        RenderContext::stencilClear();
        RenderContext::setColorWritable(false, false, false, false);
        RenderContext::setZBufferWritable(false);
        ///////////////////////////////////
        //enable state settings
        enableStates();
        //set uniform
        getShader()->uniform(uAlphaMask,alphaMask);
        //draw mesh
        if (getMesh()) getMesh()->draw();
        ///////////////////////////////////
        //set filter
        RenderContext::setStencil(STENCIL_KEEP);
        RenderContext::setColorWritable(true, true, true, true);
        RenderContext::setZBufferWritable(true);
        //draw queue
        if (render->getBatchingIsEnable())
            queue->draw(render->getBatchingMesh());
        else
            queue->draw();
        //disable filter
        RenderContext::setStencil(STENCIL_NONE);
    }
}
コード例 #20
0
ファイル: batchrender.C プロジェクト: knutj/cinelerra
void BatchRenderThread::start_rendering(char *config_path,
	char *batch_path)
{
	BC_Hash *boot_defaults;
	Preferences *preferences;
	Render *render;
	BC_Signals *signals = new BC_Signals;
	// XXX the above stuff is leaked,
//PRINT_TRACE
// Initialize stuff which MWindow does.
	signals->initialize();
	MWindow::init_defaults(boot_defaults, config_path);
	load_defaults(boot_defaults);
	preferences = new Preferences;
	preferences->load_defaults(boot_defaults);
	MWindow::init_plugins(0, preferences);
	char font_path[BCTEXTLEN];
	strcpy(font_path, preferences->plugin_dir);
	strcat(font_path, "/fonts");
	BC_Resources::init_fontconfig(font_path);
	BC_WindowBase::get_resources()->vframe_shm = 1;
	MWindow::init_fileserver(preferences);

//PRINT_TRACE
	load_jobs(batch_path, preferences);
	save_jobs(batch_path);
	save_defaults(boot_defaults);

//PRINT_TRACE
// Test EDL files for existence
	if(test_edl_files()) return;

//PRINT_TRACE

// Predict all destination paths
	ArrayList<char*> paths;
	paths.set_array_delete();
	calculate_dest_paths(&paths, preferences);

//PRINT_TRACE
	int result = ConfirmSave::test_files(0, &paths);
	paths.remove_all_objects();
// Abort on any existing file because it's so hard to set this up.
	if(result) return;

//PRINT_TRACE
	render = new Render(0);
//PRINT_TRACE
	render->start_batches(&jobs, 
		boot_defaults,
		preferences);
//PRINT_TRACE
}
コード例 #21
0
ファイル: Render.cpp プロジェクト: baraplayer/baraplayer
	void paintEvent(QPaintEvent *e)
	{
		QPainter painter(this);
		QRect rect(QPoint(0,0),size());
		painter.setRenderHints(QPainter::SmoothPixmapTransform);
		if(VPlayer::instance()->getState()==VPlayer::Stop){
			render->drawStop(&painter,rect);
		}
		else{
			render->drawPlay(&painter,rect);
			render->drawTime(&painter,rect);
		}
		QWidget::paintEvent(e);
	}
コード例 #22
0
ファイル: render.cpp プロジェクト: tempbottle/kj2
SpriteCmp::SpriteCmp( Game * game_ ) : BaseComponent<SpriteInfo>( game_ )
{
  SpriteDef def;
  Render * r = game->getRender();
  const AtlasInfo * ai =
    r->getAtlas( def.atlasFile.c_str(), def.atlasInfoFile.c_str() );
  if( !ai ) {
    ai = r->loadAtlas( def.atlasFile.c_str(), def.atlasInfoFile.c_str() );
    if( !ai ) PRINT_ERROR( "ERROR: nie zaladowano atlasu" );
  }
  untexturedSprite.tex = ai->tex;
  untexturedSprite.textureNumber = ai->getTextureNumber( def.textureName.c_str() );
  untexturedSprite.coordSpace = def.coordSpace;
  untexturedSprite.color = def.color;
}
コード例 #23
0
ファイル: render.cpp プロジェクト: galek/erbiqingnian
_NAMESPACE_BEGIN

Render *Render::createRender(uint64 windowHandle)
{
	Render *renderer = new D3D9Render(windowHandle);

	if(renderer && !renderer->isOk())
	{
		renderer->release();
		renderer = 0;
	}

	ph_assert2(renderer, "Failed to create renderer!");
	return renderer;
}
コード例 #24
0
ファイル: Main.cpp プロジェクト: HannuSa/WIP_Engine
int main()
{

	Window window(1000, 800, "This is window!");
	Render render;
	
	//Initialize graphics stuff
	render.EnableAttributeArray();
	render.EnableBlending();
	render.InitializeProjection();

	window.SetClearColor(100, 50, 150);

	ResourceManager* res = ResourceManager::Create();
	Texture* texture = &res->LoadTextureFromFile("Test.png");

	Sprite test;
	test.SetTexture(*texture);
	test.SetPosition(0, 0);
	test.SetSize(100, 100);

	window.SetClearColor(100, 50, 150);

	//Game
	Game_Timer_Random T_R(60.0f);
	T_R.SeedRandom(2);

	//Test
	float x = 0;

	while (window.IsOpen())
	{
		T_R.Counter();//Start game timer
		window.Clear();
		
		x++;
		test.SetPosition(x, 0);
		render.DrawSprite(test);	

		window.Display();

		//Set FPS
		T_R.SwitchFrame();

	}

	return 0;
}
コード例 #25
0
ファイル: main.cpp プロジェクト: vlopezsa/code
void RenderF()
{
    g_Render.clear({ 0.1f, 0.1f, 0.0f });

   // glLoadIdentity();

    UpdateEyePositionFromMouse();

    g_Render.updateCamera(g_Camera);    

    g_Render.renderScene(&g_Scene);

    TwDraw();

    g_Render.swapBuffers();
}
コード例 #26
0
ファイル: render_tests.cpp プロジェクト: aseprite/aseprite
TEST(Render, Basic)
{
  Document* doc = new Document;
  doc->sprites().add(Sprite::createBasicSprite(ImageSpec(ColorMode::INDEXED, 2, 2)));

  Image* src = doc->sprite()->root()->firstLayer()->cel(0)->image();
  clear_image(src, 2);

  std::unique_ptr<Image> dst(Image::create(IMAGE_INDEXED, 2, 2));
  clear_image(dst.get(), 1);
  EXPECT_2X2_PIXELS(dst.get(), 1, 1, 1, 1);

  Render render;
  render.renderSprite(dst.get(), doc->sprite(), frame_t(0));
  EXPECT_2X2_PIXELS(dst.get(), 2, 2, 2, 2);
}
コード例 #27
0
ファイル: Label.cpp プロジェクト: joewan/NeoEditor
void Label::draw()
{
	Render* render = Render::getInstance();
	Neo2DEngine* gui = Neo2DEngine::getInstance();

	if (m_labelText == NULL)
	{
		m_labelText = render->createText(m_font.getSafeString(),
										 m_fontSize);
		m_labelText->setAlign(m_alignment);
	}

	m_labelText->setText(m_label.c_str());
	render->drawText(m_labelText, m_x + 0.5 * (float) m_width,
					 m_y + 0.5 * m_labelText->getSize() + 0.5 * (float) m_height);
}
コード例 #28
0
ファイル: render_tests.cpp プロジェクト: aseprite/aseprite
TEST(Render, ZoomAndDstBounds)
{
  // Create this image:
  // 0 0 0
  // 0 4 4
  // 0 4 4
  Document* doc = new Document;
  doc->sprites().add(Sprite::createBasicSprite(ImageSpec(ColorMode::INDEXED, 3, 3)));
  Image* src = doc->sprite()->root()->firstLayer()->cel(0)->image();
  clear_image(src, 0);
  fill_rect(src, 1, 1, 2, 2, 4);

  std::unique_ptr<Image> dst(Image::create(IMAGE_INDEXED, 4, 4));
  clear_image(dst.get(), 0);

  Render render;
  render.setBgType(BgType::CHECKED);
  render.setBgZoom(true);
  render.setBgColor1(1);
  render.setBgColor2(2);
  render.setBgCheckedSize(gfx::Size(1, 1));

  render.renderSprite(
    dst.get(), doc->sprite(), frame_t(0),
    gfx::Clip(1, 1, 0, 0, 2, 2));
  EXPECT_4X4_PIXELS(dst.get(),
    0, 0, 0, 0,
    0, 1, 2, 0,
    0, 2, 4, 0,
    0, 0, 0, 0);
}
コード例 #29
0
ファイル: UIColorPicker.cpp プロジェクト: Bromvlieg/TomatoLib
	void UIColorPicker::Draw(Render& p) {
		float w = (float)this->W / 2;
		float h = (float)this->H / 2;

		float x = w;
		float y = h;

		float space = (float)M_PI * 2 / this->CirclePoints;

		p.CheckSpace(this->CirclePoints * 6, this->CirclePoints * 6);

		for (int i = 0; i < this->CirclePoints;) {
			Vector2 a(x + (sin(space * i) * (w - this->BorderSize)), y + (cos(space * i) * (h - this->BorderSize)));
			Vector2 b(x + sin(space * i) * w, y + cos(space * i) * h);

			float hue = space * i * (float)(180.0 / M_PI);

			i++;
			Vector2 c(x + (sin(space * i) * (w - this->BorderSize)), y + (cos(space * i) * (h - this->BorderSize)));
			Vector2 d(x + sin(space * i) * w, y + cos(space * i) * h);

			float hue2 = space * i * (float)(180.0 / M_PI);

			Color ca = HSVtoRGB(hue, 1, 1);
			Color cb = HSVtoRGB(hue, 1, 1);
			Color cc = HSVtoRGB(hue2, 1, 1);
			Color cd = HSVtoRGB(hue2, 1, 1);

			p.Triangle(a, b, c, ca, cb, cc);
			p.Triangle(b, d, c, cb, cd, cc);
		}

		Vector2 a(this->BorderSize * 3 + this->Padding, this->BorderSize * 3 + this->Padding);
		Vector2 b(this->W - this->BorderSize * 3 - +this->Padding, this->BorderSize * 3 + +this->Padding);
		Vector2 c(this->BorderSize * 3 + +this->Padding, this->H - this->BorderSize * 3 - +this->Padding);
		Vector2 d(this->W - this->BorderSize * 3 - +this->Padding, this->H - this->BorderSize * 3 - +this->Padding);

		Color ca = HSVtoRGB(this->pm_fHue, 0, 1);
		Color cb = HSVtoRGB(this->pm_fHue, 1, 1);
		Color cc = HSVtoRGB(this->pm_fHue, 0, 0);
		Color cd = HSVtoRGB(this->pm_fHue, 1, 0);

		p.Triangle(a, b, c, ca, cb, cc);
		p.Triangle(b, d, c, cb, cd, cc);
	}
コード例 #30
0
ファイル: UIManager.cpp プロジェクト: Bromvlieg/TomatoLib
	void UIManager::Draw(Render& r) {
		this->ShowCursor = this->OverrideShowCursor;

		r.SetDrawingOffset(0, 0);

		for (unsigned int i = 0; i < this->Children.size(); i++) {
			this->Children[i]->_InternalDraw(r);
		}
	}