Ejemplo n.º 1
0
void display(void)
{
	int i;
	glClearColor(1.0f,1.0f,1.0f,1.0f);

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	
	glPointSize(1.0);

	glBegin(GL_POINTS);
	
	init_buffer();		//initialize buffer
	rotate_all();		//rotate object
	project_data();		//project object
	drawPoly_zbuffer();	//draws cube
	performUpdate();	//moves balls and handles collisions

	//draws the balls
	for(i=0;i<no_balls;i++)
	{
		find_intersect(Balls[i].pos[0],Balls[i].pos[1],Balls[i].pos[2],Balls[i].r);
		fill_color(Balls[i].pos[0],Balls[i].pos[1],Balls[i].pos[2],i%6);
	}
	//draws the z-buffer	
	disp_zbuf();
		
	glEnd();
	glutSwapBuffers();
}
Ejemplo n.º 2
0
  void CrossDelegate::run(int width, int height, int aaSamples, int depthBits)
  {
    initInfo.windowInfo = WindowInfo(width, height, aaSamples, depthBits);

    performInit(); // TODO: HANDLE FAILURES
    performSetup();
    performResize(setupInfo.windowInfo.size);

    sketch->performStart(CrossSketch::START_REASON_VIEW_SHOWN);

    while (!glfwWindowShouldClose(window))
    {
      intern::instance->processMouseEvents();
      intern::instance->processKeyEvents();
      intern::instance->processWheelEvents();

      performUpdate();
      performDraw();

      glfwSwapBuffers(window);

      intern::instance->clearMouseEvents();
      intern::instance->clearKeyEvents();
      intern::instance->clearWheelEvents();
      glfwPollEvents();
    }

    sketch->performStop(CrossSketch::STOP_REASON_VIEW_HIDDEN);

    performShutdown();
    performUninit();
  }
Ejemplo n.º 3
0
/*!
    Queues an updateGL() to happen during the next event loop.
    If multiple calls are made to this function, only one
    call to updateGL() occurs during the next event loop.
*/
void QGLView::queueUpdate()
{
    if (!d->updateQueued) {
        d->updateQueued = true;
        QTimer::singleShot(0, this, SLOT(performUpdate()));
    }
}
Ejemplo n.º 4
0
bool game_host::recieveFromClients()
{
	string packData = recieveMessageUDP();
	string temp;
	while (packData != "NO MESSAGE")
	{
		cout << packData << endl;
		performUpdate(packData);
		packData = recieveMessageUDP();
	}
	return true;
}
Ejemplo n.º 5
0
void Tonav::performUpdateIfPossible() {
    bool has_image = !std::isnan(last_image_capture_time_);
    bool has_accelerometer_after_image = getMaxAccelerometerTime() >= last_image_capture_time_;
    bool has_gyroscope_after_image = getMaxGyroscopeTime() >= last_image_capture_time_;
    
    if (has_image && has_accelerometer_after_image && has_gyroscope_after_image) {
        performUpdate();
        filter_was_updated_ = true;
    } else {
        filter_was_updated_ = false;
    }
}
Ejemplo n.º 6
0
bool NSISUpdater::handleStartup()
{
    switch (updateStateOnStart()) {
    case NSISUpdater::UpdateAvailable:
        return performUpdate();
    case NSISUpdater::UpdateFailed:
        _showFallbackMessage = true;
        return false;
    case NSISUpdater::NoUpdate:
    default:
        return false;
    }
}
void SQLitePersistedObjectSet::performUpdateWithRetry(const UUID& internal_id, const String& script_type, const String& script_args, const String& script_contents, RequestCallback cb) {
    UpdateResult res = LOCK_ERROR;
    for(int32 i = 0; i < 100 && res == LOCK_ERROR; i++) {
        if (i != 0) Timer::sleep(Duration::milliseconds(25));
        res = performUpdate(internal_id, script_type, script_args, script_contents, cb);
    }

    if (res == LOCK_ERROR)
        SILOG(sqlite-persisted-object-set, error, "Couldn't perform update after 100 retries, database was busy.");

    if (cb != 0)
        mContext->mainStrand->post(std::tr1::bind(cb, (res == SUCCESS)), "SQLitePersistedObjectSet::performUpdate callback");
}
Ejemplo n.º 8
0
void advance(float t, float timeUntilUpdate) 
{
	while (t > 0) 
	{
		if (timeUntilUpdate <= t) 
		{
			move_balls(timeUntilUpdate);
			performUpdate();
			t -= timeUntilUpdate;
			timeUntilUpdate = TIME_BETWEEN_UPDATES;
		}
		else 
		{
			move_balls(timeUntilUpdate);
			timeUntilUpdate -= t;
			t = 0;
		}
	}
}
Ejemplo n.º 9
0
void
FeedHandler::performOperation(FeedToken token, FeedOperation::UP op)
{
    if (considerWriteOperationForRejection(token, *op)) {
        return;
    }
    switch(op->getType()) {
    case FeedOperation::PUT:
        performPut(std::move(token), static_cast<PutOperation &>(*op));
        return;
    case FeedOperation::REMOVE:
        performRemove(std::move(token), static_cast<RemoveOperation &>(*op));
        return;
    case FeedOperation::UPDATE_42:
    case FeedOperation::UPDATE:
        performUpdate(std::move(token), static_cast<UpdateOperation &>(*op));
        return;
    case FeedOperation::DELETE_BUCKET:
        performDeleteBucket(std::move(token), static_cast<DeleteBucketOperation &>(*op));
        return;
    case FeedOperation::SPLIT_BUCKET:
        performSplit(std::move(token), static_cast<SplitBucketOperation &>(*op));
        return;
    case FeedOperation::JOIN_BUCKETS:
        performJoin(std::move(token), static_cast<JoinBucketsOperation &>(*op));
        return;
    case FeedOperation::WIPE_HISTORY:
        performGarbageCollect(std::move(token));
        return;
    case FeedOperation::CREATE_BUCKET:
        performCreateBucket(std::move(token), static_cast<CreateBucketOperation &>(*op));
        return;
    default:
        assert(!"Illegal operation type");
    }
}
cairo_surface_t* HeadlessViewBackend::createSnapshot()
{
    performUpdate();

    EGLImageKHR image = std::get<0>(m_lockedImage.second);
    if (!image)
        return nullptr;

    uint32_t width = std::get<1>(m_lockedImage.second);
    uint32_t height = std::get<2>(m_lockedImage.second);

    uint8_t* buffer = new uint8_t[4 * width * height];
    bool successfulSnapshot = false;

    makeCurrent();

    GLuint imageTexture;
    glGenTextures(1, &imageTexture);
    glBindTexture(GL_TEXTURE_2D, imageTexture);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    glTexImage2D(GL_TEXTURE_2D, 0, GL_BGRA_EXT, width, height, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, nullptr);

    m_egl.imageTargetTexture2DOES(GL_TEXTURE_2D, image);
    glBindTexture(GL_TEXTURE_2D, 0);

    GLuint imageFramebuffer;
    glGenFramebuffers(1, &imageFramebuffer);
    glBindFramebuffer(GL_FRAMEBUFFER, imageFramebuffer);
    glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, imageTexture, 0);

    glFlush();
    if (glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE) {
        glReadPixels(0, 0, width, height, GL_BGRA_EXT, GL_UNSIGNED_BYTE, buffer);
        successfulSnapshot = true;
    }

    glBindFramebuffer(GL_FRAMEBUFFER, 0);
    glDeleteFramebuffers(1, &imageFramebuffer);
    glDeleteTextures(1, &imageTexture);

    if (!successfulSnapshot) {
        delete[] buffer;
        return nullptr;
    }

    cairo_surface_t* imageSurface = cairo_image_surface_create_for_data(buffer,
        CAIRO_FORMAT_ARGB32, width, height, cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, width));
    cairo_surface_mark_dirty(imageSurface);

    static cairo_user_data_key_t bufferKey;
    cairo_surface_set_user_data(imageSurface, &bufferKey, buffer,
        [](void* data) {
            auto* buffer = static_cast<uint8_t*>(data);
            delete[] buffer;
        });

    return imageSurface;
}
Ejemplo n.º 11
0
/*
 * Writes a buffer with the status to send and returns the length
 * of the data written.
 */
int device::update(uint8_t * buf)
{
    performUpdate();
    return _out(buf);
}