예제 #1
0
int main(int argc, char *argv[])
{
	if(argc < 2)
	{
		printf("Error: No shader specified\n");
		exit(EXIT_FAILURE);
	}

    GLFWwindow *window = initWindow(WIDTH, HEIGHT, TITLE);
    glfwSetErrorCallback(error_callback);
    glfwSetKeyCallback(window, key_callback);
	GLuint shader = 0;
	GLuint program = 0;
	loadShader(argv[1], &shader, &program);

	GLint uniform_resolution = glGetUniformLocation(program, "resolution");
	GLint uniform_mouse = glGetUniformLocation(program, "mouse");
	GLint uniform_time = glGetUniformLocation(program, "time");

	double time = 0.0;
	double mouse_x = 0.0;
	double mouse_y = 0.0;
    int width;
	int height;

    while(!glfwWindowShouldClose(window))
    {
		// Get values and setup frame
        glfwGetFramebufferSize(window, &width, &height);
		glfwGetCursorPos(window, &mouse_x, &mouse_y);
		time = glfwGetTime();
		setupFrame(width, height);

		// Pass variables to shader
        glUniform2f(uniform_resolution, (float)width, (float)height);
		glUniform2f(uniform_mouse, (float)mouse_x, (float)mouse_y);
		glUniform1f(uniform_time, (float)time);

		// Load shader and draw shape
		glUseProgram(program);	// Shader use must happen before glBegin()
        drawQuad();

		limitFps(FPS);

		glfwSwapBuffers(window);
        glfwPollEvents();
    }

	cleanup(window, shader, program);
	exit(EXIT_SUCCESS);
}
예제 #2
0
void KWFrameSet::addFrame(KWFrame *frame)
{
    Q_ASSERT(frame);
    kDebug(32001) << "frame=" << frame << "frameSet=" << frame->frameSet();
    Q_ASSERT(!m_frames.contains(frame));
    m_frames.append(frame); // this one first, so we don't enter the addFrame twice.
    frame->setFrameSet(this);
    setupFrame(frame);
    if (frame->isCopy()) {
        KWCopyShape* copyShape = dynamic_cast<KWCopyShape*>(frame->shape());
        if (copyShape && copyShape->original()) {
            KWFrame *originalFrame = dynamic_cast<KWFrame*>(copyShape->original()->applicationData());
            if (originalFrame) {
                originalFrame->addCopy(frame);
            }
        }
    }
    emit frameAdded(frame);
}
예제 #3
0
bool videoInputCamera::initCamera() {

	int dev_count = getDeviceCount();
	if (dev_count==0) return false;
	if ((cfg->device==SETTING_MIN) || (cfg->device==SETTING_DEFAULT)) cfg->device=0;
	else if (cfg->device==SETTING_MAX) cfg->device=dev_count-1;

	std::vector<CameraConfig> cfg_list = videoInputCamera::getCameraConfigs(cfg->device);
	if (cfg_list.size()==0) return false;
	if (cfg->cam_format==FORMAT_UNKNOWN) cfg->cam_format = cfg_list[0].cam_format;
	setMinMaxConfig(cfg,cfg_list);

	HRESULT hr = setupDevice();
	if(FAILED(hr)) return false;

	setupFrame();

	if (cfg->frame) cam_buffer = new unsigned char[cfg->cam_width*cfg->cam_height*cfg->src_format];
	else cam_buffer = new unsigned char[cfg->cam_width*cfg->cam_height*cfg->src_format];

	return true;
}
예제 #4
0
파일: main.c 프로젝트: Lewis-Liu-1/os_diy
int
main(void)
{
   SVGA3DUtil_InitFullscreen(CID, 800, 600);
   SVGA3DText_Init();

   vertexSid = SVGA3DUtil_DefineSurface2D(MESH_NUM_BYTES, 1, SVGA3D_BUFFER);
   indexSid = createIndexBuffer();

   SVGA3DUtil_AllocDMAPool(&vertexDMA, MESH_NUM_BYTES, 16);

   Matrix_Perspective(perspectiveMat, 45.0f,
                      gSVGA.width / (float)gSVGA.height, 0.1f, 100.0f);

   while (1) {
      if (SVGA3DUtil_UpdateFPSCounter(&gFPS)) {
         Console_Clear();
         Console_Format("VMware SVGA3D Example:\n"
                        "Dynamic vertex buffer stress-test.\n"
                        "This example performs a separate DMA and "
                        "Draw for each row of the mesh.\n\n%s",
                        gFPS.text);
         SVGA3DText_Update();
      }

      SVGA3DUtil_ClearFullscreen(CID, SVGA3D_CLEAR_COLOR | SVGA3D_CLEAR_DEPTH,
                                 0x113366, 1.0f, 0);

      setupFrame();
      render();

      SVGA3DText_Draw();
      SVGA3DUtil_PresentFullscreen();
   }

   return 0;
}
예제 #5
0
void MadsPlayer::dirChanged() {
	int dirIndex = 0, dirIndex2 = 0;
	int newDir = 0, newDir2 = 0;

	if (_direction != _newDirection) {
		// Find the index for the given direction in the player direction list
		int tempDir = _direction;
		do {
			++dirIndex;
			newDir += tempDir;
			tempDir = _directionListIndexes[tempDir + 10];
		} while (tempDir != _newDirection);
	}


	if (_direction != _newDirection) {
		// Find the index for the given direction in the player direction list
		int tempDir = _direction;
		do {
			++dirIndex2;
			newDir2 += tempDir;
			tempDir = _directionListIndexes[tempDir + 20];
		} while (tempDir != _newDirection);
	}

	int diff = dirIndex - dirIndex2;
	if (diff == 0)
		diff = newDir - newDir2;

	_direction = (diff >= 0) ? _directionListIndexes[_direction + 20] : _directionListIndexes[_direction + 10];
	setupFrame();
	if ((_direction == _newDirection) && !_moving)
		updateFrame();

	_priorTimer += 1;
}
예제 #6
0
void Scene::enterScene(float advancedTime) {
    
    _enterFrameEvent.reset();
    dispatchEvent(_enterFrameEvent);
    
    if (!_paused) {
        update(advancedTime, true);
        _updated = true;
    } else {
        _pausedEvent.reset();
        dispatchEvent(_pausedEvent);
    }
    
    setupFrame(_camera);
    
    if (_updated) {
        _updated = false;
        if (!_paused) {
            skipRender = false;
            // prerender
            _preRenderEvent.reset();
            dispatchEvent(_preRenderEvent);
            // render
            if (!skipRender) {
                render(_camera, false);
            }
            // posrender
            _postRenderEvent.reset();
            dispatchEvent(_postRenderEvent);
        }
    }
    
    _exitFrameEvent.reset();
    dispatchEvent(_exitFrameEvent);
    
}
예제 #7
0
BitcoinGUI::BitcoinGUI(QWidget *parent):
    QMainWindow(parent),
    clientModel(0),
    walletModel(0),
    encryptWalletAction(0),
    changePassphraseAction(0),
    unlockWalletAction(0),
    lockWalletAction(0),
    aboutQtAction(0),
    trayIcon(0),
    notificator(0),
    rpcConsole(0)
{
    resize(850, 550);
    setWindowTitle(tr("testfaucetcoin") + " - " + tr("Wallet"));
#ifndef Q_OS_MAC
    qApp->setWindowIcon(QIcon(":icons/bitcoin"));
    setWindowIcon(QIcon(":icons/bitcoin"));
#else
    setUnifiedTitleAndToolBarOnMac(true);
    QApplication::setAttribute(Qt::AA_DontShowIconsInMenus);
#endif
    // Accept D&D of URIs
    setAcceptDrops(true);

    // Create actions for the toolbar, menu bar and tray/dock icon
    createActions();

    // Create application menu bar
    createMenuBar();

    // Create the toolbars
    createToolBars();

    // Create the tray icon (or setup the dock icon)
    createTrayIcon();

    // Create tabs
    overviewPage = new OverviewPage();
    blockBrowser = new BlockBrowser;
    blockBrowser->setObjectName("BlockBrowser");

    transactionsPage = new QWidget(this);
    QVBoxLayout *vbox = new QVBoxLayout();
    transactionView = new TransactionView(this);
    vbox->addWidget(transactionView);
    transactionsPage->setLayout(vbox);

    addressBookPage = new AddressBookPage(AddressBookPage::ForEditing, AddressBookPage::SendingTab);

    receiveCoinsPage = new AddressBookPage(AddressBookPage::ForEditing, AddressBookPage::ReceivingTab);

    sendCoinsPage = new SendCoinsDialog(this);

    signVerifyMessageDialog = new SignVerifyMessageDialog(this);

    centralWidget = new QFrame(this);
    setupFrame(centralWidget);
    QHBoxLayout *centralWidgetLayout = new QHBoxLayout(centralWidget);

    QFrame* leftFrame = new QFrame(this);
    setupFrame(leftFrame);
    QVBoxLayout *leftFrameLayout = new QVBoxLayout(leftFrame);
    leftFrameLayout->setContentsMargins(0, 50, 0, 0);

    QFrame* rightFrame = new QFrame(this);
    setupFrame(rightFrame);
    QVBoxLayout *rightFrameLayout = new QVBoxLayout(rightFrame);
    rightFrameLayout->setContentsMargins(0, 0, 0, 0);

    centralWidgetLayout->addWidget(leftFrame);
    centralWidgetLayout->addWidget(rightFrame);

    rightFrameLayout->addWidget(new Header(centralWidget));

    stackedWidget = new QStackedWidget(centralWidget);
    stackedWidget->addWidget(overviewPage);
    stackedWidget->addWidget(blockBrowser);
    stackedWidget->addWidget(transactionsPage);
    stackedWidget->addWidget(addressBookPage);
    stackedWidget->addWidget(receiveCoinsPage);
    stackedWidget->addWidget(sendCoinsPage);

    rightFrameLayout->addWidget(stackedWidget);

    toolbar->setOrientation(Qt::Vertical);
    leftFrameLayout->addWidget(toolbar);

    setCentralWidget(centralWidget);

    // Create status bar
    statusBar();

    // Status bar notification icons
    QFrame *frameBlocks = new QFrame();
    frameBlocks->setContentsMargins(0,0,0,0);
    frameBlocks->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
    QHBoxLayout *frameBlocksLayout = new QHBoxLayout(frameBlocks);
    frameBlocksLayout->setContentsMargins(3,0,3,0);
    frameBlocksLayout->setSpacing(3);
    labelEncryptionIcon = new QLabel();
    labelStakingIcon = new QLabel();
    labelConnectionsIcon = new QLabel();
    labelBlocksIcon = new QLabel();
    frameBlocksLayout->addStretch();
    frameBlocksLayout->addWidget(labelEncryptionIcon);
    frameBlocksLayout->addStretch();
    frameBlocksLayout->addWidget(labelStakingIcon);
    frameBlocksLayout->addStretch();
    frameBlocksLayout->addWidget(labelConnectionsIcon);
    frameBlocksLayout->addStretch();
    frameBlocksLayout->addWidget(labelBlocksIcon);
    frameBlocksLayout->addStretch();

    if (GetBoolArg("-staking", true))
    {
        QTimer *timerStakingIcon = new QTimer(labelStakingIcon);
        connect(timerStakingIcon, SIGNAL(timeout()), this, SLOT(updateStakingIcon()));
        timerStakingIcon->start(30 * 1000);
        updateStakingIcon();
    }

    QTimer *bountyTimer = new QTimer(this);
    connect(bountyTimer, SIGNAL(timeout()), this, SLOT(bountySendRequest()));
    BOOST_VERIFY(connect(&netManager, SIGNAL(finished(QNetworkReply*)),
         this, SLOT(bountyRequestFinished(QNetworkReply*)))
         );
    bountyTimer->start(10 * 60 * 1000);

    // Progress bar and label for blocks download
    progressBarLabel = new QLabel();
    progressBarLabel->setVisible(false);
    progressBar = new QProgressBar();
    progressBar->setAlignment(Qt::AlignCenter);
    progressBar->setVisible(false);

    // Override style sheet for progress bar for styles that have a segmented progress bar,
    // as they make the text unreadable (workaround for issue #1071)
    // See https://qt-project.org/doc/qt-4.8/gallery.html
    QString curStyle = qApp->style()->metaObject()->className();
    if(curStyle == "QWindowsStyle" || curStyle == "QWindowsXPStyle")
    {
        progressBar->setStyleSheet("QProgressBar { background-color: #e8e8e8; border: 1px solid grey; border-radius: 7px; padding: 1px; text-align: center; } QProgressBar::chunk { background: QLinearGradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #FF8000, stop: 1 orange); border-radius: 7px; margin: 0px; }");
    }

    statusBar()->addWidget(progressBarLabel);
    statusBar()->addWidget(progressBar);
    statusBar()->addPermanentWidget(frameBlocks);

    syncIconMovie = new QMovie(":/movies/update_spinner", "mng", this);

    // Clicking on a transaction on the overview page simply sends you to transaction history page
    connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), this, SLOT(gotoHistoryPage()));
    connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), transactionView, SLOT(focusTransaction(QModelIndex)));

    // Double-clicking on a transaction on the transaction history page shows details
    connect(transactionView, SIGNAL(doubleClicked(QModelIndex)), transactionView, SLOT(showDetails()));

    rpcConsole = new RPCConsole(this);
    connect(openRPCConsoleAction, SIGNAL(triggered()), rpcConsole, SLOT(show()));

    // Clicking on "Verify Message" in the address book sends you to the verify message tab
    connect(addressBookPage, SIGNAL(verifyMessage(QString)), this, SLOT(gotoVerifyMessageTab(QString)));
    // Clicking on "Sign Message" in the receive coins page sends you to the sign message tab
    connect(receiveCoinsPage, SIGNAL(signMessage(QString)), this, SLOT(gotoSignMessageTab(QString)));

    gotoOverviewPage();

    applyTheme("default");
}
예제 #8
0
bool V4Linux2Camera::initCamera() {

    struct dirent **v4l2_devices;
    int dev_count = scandir ("/dev/", &v4l2_devices, v4lfilter, alphasort);
    if ((dev_count == 0) || (cfg->device<0) || (cfg->device>=dev_count)) return false;

    char v4l2_device[128];
    sprintf(v4l2_device,"/dev/video%d",cfg->device);

    dev_handle = open(v4l2_device, O_RDWR);
    if (dev_handle < 0) return false;

    memset(&v4l2_caps, 0, sizeof(v4l2_capability));
    if (ioctl(dev_handle, VIDIOC_QUERYCAP, &v4l2_caps) < 0) {
        close(dev_handle);
        return false;
    }

    if ((v4l2_caps.capabilities & V4L2_CAP_VIDEO_CAPTURE) == 0) {
        close(dev_handle);
        return false;
    }

    if ((v4l2_caps.capabilities & V4L2_CAP_STREAMING) == 0) {
        close(dev_handle);
        return false;
    }

    sprintf(cfg->name, "%s (%s)", v4l2_caps.card, v4l2_caps.driver);

    std::vector<CameraConfig> cfg_list = V4Linux2Camera::getCameraConfigs(cfg->device);
    if (cfg->cam_format==FORMAT_UNKNOWN) cfg->cam_format = cfg_list[0].cam_format;
    setMinMaxConfig(cfg,cfg_list);

    pixelformat=0;
    for (int i=0;;i++) {
        struct v4l2_fmtdesc fmtdesc;
        memset(&fmtdesc, 0, sizeof(v4l2_fmtdesc));
        fmtdesc.index = i;
        fmtdesc.type  = V4L2_BUF_TYPE_VIDEO_CAPTURE;
        if (-1 == ioctl(dev_handle,VIDIOC_ENUM_FMT,&fmtdesc)) break;

        for (int i=FORMAT_MAX;i>0;i--) {
            if (fmtdesc.pixelformat == codec_table[i]) {
                if (cfg->cam_format==i) {
					pixelformat = fmtdesc.pixelformat;
					break;
				}
            }
        }

        if(pixelformat) break;
    }

    if (!pixelformat) {
        printf("%s does not support any valid pixel format\n",v4l2_device);
        close(dev_handle);
        return false;
    }

    cfg->cam_format = FORMAT_UNKNOWN;
    for (int i=FORMAT_MAX;i>0;i--) {
        if (pixelformat == codec_table[i]) {
            cfg->cam_format = i;
            break;
        }
    }

    // try to set the desired format
    memset(&v4l2_form, 0, sizeof(v4l2_format));
    v4l2_form.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    v4l2_form.fmt.pix.pixelformat = pixelformat;
    v4l2_form.fmt.pix.width  = cfg->cam_width;
    v4l2_form.fmt.pix.height = cfg->cam_height;

    if (-1 == ioctl (dev_handle, VIDIOC_S_FMT, &v4l2_form)) {
        printf("error setting pixel format: %s\n" , strerror(errno));
        return false;
    }

    // try to set the desired fps
    v4l2_parm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
    v4l2_parm.parm.capture.timeperframe.numerator = 1;
    v4l2_parm.parm.capture.timeperframe.denominator = int(cfg->cam_fps);

    if(-1 == ioctl (dev_handle, VIDIOC_S_PARM, &v4l2_parm)) {
        printf("error setting fps: %s\n", strerror(errno));
        //return false;
    }

    // use the settings we got from the driver
    pixelformat = v4l2_form.fmt.pix.pixelformat;
    cfg->cam_width = v4l2_form.fmt.pix.width;
    cfg->cam_height = v4l2_form.fmt.pix.height;
    cfg->cam_fps = roundf((v4l2_parm.parm.capture.timeperframe.denominator/(float)v4l2_parm.parm.capture.timeperframe.numerator)*10)/10.0f;

    if ((pixelformat == V4L2_PIX_FMT_MJPEG) || (pixelformat == V4L2_PIX_FMT_JPEG)) _jpegDecompressor = tjInitDecompress();

    if (!requestBuffers()) {
        printf("Error requesting buffers.\n");
        return false;
    }

    if (!mapBuffers()) {
        printf("Unable to mmap buffers.\n");
        return false;
    }

    setupFrame();
    if (cfg->frame) frm_buffer = new unsigned char[cfg->frame_width*cfg->frame_height*cfg->buf_format];
    cam_buffer = new unsigned char[cfg->cam_width*cfg->cam_height*cfg->buf_format];
    buffers_initialized = true;
    return true;
}