Exemple #1
1
int main(void) {

    PlatformState state;
    SDL_Event e;
    SDL_Window *window;
    SDL_Renderer *renderer;
    SDLInputContext sdlIC;
    SDLSoundRingBuffer srb;
    GameSoundOutput sb;
    GameMemory gameMemory;

    //controller input state
    InputContext inputStates[2]; //contains old and new state
    InputContext* newInputState = &inputStates[0];
    InputContext* oldInputState = &inputStates[1];
    real32_t secsSinceLastFrame = 0;


    sb.volume = 2500;

    gameMemory.permanentStorageSize = MB(64);
    gameMemory.transientStorageSize = MB(64);
    state.gameMemorySize = gameMemory.transientStorageSize + gameMemory.permanentStorageSize;
    state.memoryBlock = mmap(nullptr, state.gameMemorySize, PROT_READ | PROT_WRITE,
            MAP_ANONYMOUS | MAP_PRIVATE ,
            -1,
            0);
    gameMemory.permanentStorage = state.memoryBlock;
    gameMemory.transientStorage = (uint8_t*)(gameMemory.transientStorage) + gameMemory.transientStorageSize;


    initSDL(&window, &renderer, &gOsb, &sdlIC, &srb);

    GameCode gameCode = loadGameCode();

    assert(gameCode.guarf);

    uint64_t startCount = SDL_GetPerformanceCounter();
    real32_t targetFrameSeconds = 1./getRefreshRate(window);

    SDL_PauseAudio(0);
    while(state.running) {

        if(getCreateTimeOfFile(GAME_LIB_PATH) != gameCode.dateLastModified) {
            reloadGameCode(&gameCode);
        }

        //keyboard input
        ControllerInput* newKeyInput = getContoller(newInputState, 0);

        //TODO: figure out why this is special
        ControllerInput* oldKeyInput = getContoller(oldInputState, 0);
        *newKeyInput = {};

        for(size_t i = 0; i < ARRAY_SIZE(oldKeyInput->buttons); i++) {
            newKeyInput->buttons[i] = oldKeyInput->buttons[i];
        }
        while(SDL_PollEvent(&e)) {
            processEvent(&e, newInputState, &state);
        }


        //controller input
        for(int i = 0; i < MAX_SDL_CONTROLLERS; i++) {
            if(sdlIC.controllers[i] != nullptr && SDL_GameControllerGetAttached(sdlIC.controllers[i])) {

                ControllerInput* newCIState = getContoller(newInputState, i+1);
                ControllerInput* oldCIState = getContoller(oldInputState, i+1);


                int16_t xVal = SDL_GameControllerGetAxis(sdlIC.controllers[i], SDL_CONTROLLER_AXIS_LEFTX);
                int16_t yVal = SDL_GameControllerGetAxis(sdlIC.controllers[i], SDL_CONTROLLER_AXIS_LEFTY);

                newCIState->avgX = normalizeStickInput(xVal, LEFT_THUMB_DEADZONE);
                newCIState->avgY = normalizeStickInput(yVal, LEFT_THUMB_DEADZONE);

                if(newCIState->avgX != 0 || newCIState->avgY != 0) {
                    newCIState->isAnalog = true;
                }

                processControllerButtonInput(&newCIState->actionDown, &oldCIState->actionDown, &newCIState->isAnalog, sdlIC.controllers[i], SDL_CONTROLLER_BUTTON_A);
                processControllerButtonInput(&newCIState->actionUp, &oldCIState->actionUp, &newCIState->isAnalog, sdlIC.controllers[i], SDL_CONTROLLER_BUTTON_Y);
                processControllerButtonInput(&newCIState->actionLeft, &oldCIState->actionLeft, &newCIState->isAnalog, sdlIC.controllers[i], SDL_CONTROLLER_BUTTON_X);
                processControllerButtonInput(&newCIState->actionRight, &oldCIState->actionRight, &newCIState->isAnalog, sdlIC.controllers[i], SDL_CONTROLLER_BUTTON_B);

                processControllerButtonInput(&newCIState->directionDown, &oldCIState->directionDown, &newCIState->isAnalog, sdlIC.controllers[i], SDL_CONTROLLER_BUTTON_DPAD_DOWN);
                processControllerButtonInput(&newCIState->directionUp, &oldCIState->directionUp, &newCIState->isAnalog, sdlIC.controllers[i], SDL_CONTROLLER_BUTTON_DPAD_UP);
                processControllerButtonInput(&newCIState->directionLeft, &oldCIState->directionLeft, &newCIState->isAnalog, sdlIC.controllers[i], SDL_CONTROLLER_BUTTON_DPAD_LEFT);
                processControllerButtonInput(&newCIState->directionRight, &oldCIState->directionRight, &newCIState->isAnalog, sdlIC.controllers[i], SDL_CONTROLLER_BUTTON_DPAD_RIGHT);

                oldCIState->isAnalog = newCIState->isAnalog;


            }
            else {
                //TODO: Logging
            }
        }


        //TODO: Do this instead of processing input, not after
        //process recording/playback
        assert(!(state.isRecording && state.isPlayingBack));

        if(state.isRecording) {
            recordInput(newInputState, state.inputRecordFile);
        }

        if(state.isPlayingBack) {
            playInput(newInputState, state.inputRecordFile);
        }

        //calculate audio buffers' indicies and sizes
        SDL_LockAudioDevice(1);
        uint32_t startIndex = srb.runningIndex % ARRAY_SIZE(srb.samples);
        uint32_t endIndex = (srb.sampleToPlay + SOUND_LATENCY) % ARRAY_SIZE(srb.samples);
        uint32_t samplesToGetFromGame = (startIndex <= endIndex) ? endIndex - startIndex : (ARRAY_SIZE(srb.samples) - startIndex) + endIndex; 
        sb.numSamples = samplesToGetFromGame;
        SDL_UnlockAudioDevice(1);



        gameCode.guarf(&gameMemory, &gOsb, &sb, newInputState, secsSinceLastFrame);

        updateSDLSoundBuffer(&srb, &sb, startIndex, endIndex);
        updateWindow(window, gTexture);

        InputContext* temp = newInputState;
        newInputState = oldInputState;
        oldInputState = temp;

        //benchmark stuff

        real32_t secsElapsed = secondsForCountRange(startCount, SDL_GetPerformanceCounter());

        //sleep to lock frame rate
        if(secsElapsed < targetFrameSeconds) {


            //NOTE: .5 denotes the amount we will spin manually since
            //      SDL_Delay is not 100% accurate
            real32_t timeToSleep = (targetFrameSeconds - secsElapsed)*1000 - .5;
            SDL_Delay(timeToSleep);
            secsElapsed = secondsForCountRange(startCount, SDL_GetPerformanceCounter());
            
            //This assert will fire if the window is moved
            //assert(secondsForCountRange(startCount, SDL_GetPerformanceCounter()) < targetFrameSeconds); 
            
            while(secondsForCountRange(startCount, SDL_GetPerformanceCounter()) < targetFrameSeconds) {
                //wait
            }
            secsElapsed = secondsForCountRange(startCount, SDL_GetPerformanceCounter());
        }
        uint64_t endCount = SDL_GetPerformanceCounter();
        real32_t fpsCount =  ((1./secsElapsed));
        real32_t mcPerFrame = (real32_t)(endCount-startCount) / (1000 * 1000 );


        printf("TPF: %.2fms FPS: %.2f MCPF: %.2f\n", secsElapsed*1000, fpsCount, mcPerFrame);

        startCount = endCount;
        secsSinceLastFrame = secsElapsed;
    }

    cleanUp(&state, &gameCode);
    return 0;
}
void MainWindow::createKhollo() {
    //Try to load directory preferences
    Preferences pref;
    QString pref_path = pref.dir();

    //Get file name
    QString filename = QFileDialog::getSaveFileName(this, "Enregistrer sous...",
                                                    pref_path + QDir::separator() + "kholloscope",  "KSCOPE (*.kscope)");

    if(filename == "") {
        updateWindow();
        return;
    }

    record(false);
    //Save directory in preferences
    QString dirpath = QFileInfo(filename).absoluteDir().absolutePath();
    pref.setDir(dirpath);

    if(kscopemanager.createFile(filename))
        QMessageBox::information(NULL, "Succès", "Votre kholloscope a été créé.<br />Vous pouvez dès maintenant l'utiliser. :p");

    updateWindow();
    record(QSqlDatabase::database().isOpen());
    return;
}
Exemple #3
0
void saveFile(Widget *widget, Window *window)
{
  closeDialog(widget, window);
  int fd = open(filenameBox.text, O_WRONLY);
  char isNewFile = 0;

  if (fd < 0)
  {
    fd = open(filenameBox.text, O_CREATE);
    if (fd < 0)
    {
      return;
    }
    close(fd);
    fd = open(filenameBox.text, O_WRONLY);
    if (fd < 0)
    {
      return;
    }
    isNewFile = 1;
  }
  write(fd, text_box.text, strlen(text_box.text) + 1);
  close(fd);
  if (isNewFile)
  {
    strcpy(mainwindow.caption, filenameBox.text);
    updateWindow(hWind);
    fileSystemChanged();
  }
}
Exemple #4
0
RocketBar::MainWidget::MainWidget(
        RocketBar::Context *config, QWidget *parent)
    : QDeclarativeView(parent), mContext(config),
      mLauncherList(QList<QObject*>()),
      mAppletList(QList<QObject*> ())
{
    /* initialize a borderless panel window */
    setFocus(Qt::ActiveWindowFocusReason);
    setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
    setAttribute(Qt::WA_TranslucentBackground);
    setAttribute(Qt::WA_X11NetWmWindowTypeDock);
    setStyleSheet("border-style: none;background:transparent;");
    setResizeMode(QDeclarativeView::SizeRootObjectToView);

    engine()->addImageProvider(QLatin1String("xdg"), mContext->mImageProvider);
    engine()->addImageProvider(QLatin1String("task"),
                               mContext->mWindowManager->taskImageProvider());
    engine()->addImageProvider(QLatin1String("applet"),
                               mContext->mAppletImageProvider);

    buildMenu();
    buildLauncher();
    buildApplets();

    updateWindow();
    connect(mContext->mWindowManager,
            SIGNAL(windowsChanged(WindowManager::WindowList&)),
            this, SLOT(updateWindows(WindowManager::WindowList&)));
}
void displayGameOver(SDL_Texture * font)
{
    clearScreen();
    displayTextMiddle(font, "Game Over", FONT_LARGE, 1.0);
    updateWindow();
    SDL_Delay(2 * 1000);
}
DiscoInfoWindow::DiscoInfoWindow(IServiceDiscovery *ADiscovery, const Jid &AStreamJid, const Jid &AContactJid, const QString &ANode, QWidget *AParent) : QDialog(AParent)
{
	REPORT_VIEW;
	ui.setupUi(this);
	setAttribute(Qt::WA_DeleteOnClose,true);
	setWindowTitle(tr("Discovery Info - %1").arg(AContactJid.uFull()));
	IconStorage::staticStorage(RSR_STORAGE_MENUICONS)->insertAutoIcon(this,MNI_SDISCOVERY_DISCOINFO,0,0,"windowIcon");

	FNode = ANode;
	FFormMenu = NULL;
	FStreamJid = AStreamJid;
	FContactJid = AContactJid;

	FDiscovery = ADiscovery;
	FDataForms = PluginHelper::pluginInstance<IDataForms>();

	ui.pbtExtensions->setEnabled(false);
	ui.lblError->setVisible(false);

	connect(FDiscovery->instance(),SIGNAL(discoInfoReceived(const IDiscoInfo &)),SLOT(onDiscoInfoReceived(const IDiscoInfo &)));
	connect(ui.pbtUpdate,SIGNAL(clicked()),SLOT(onUpdateClicked()));
	connect(ui.lwtFearures,SIGNAL(currentItemChanged(QListWidgetItem *, QListWidgetItem *)),SLOT(onCurrentFeatureChanged(QListWidgetItem *, QListWidgetItem *)));
	connect(ui.lwtFearures,SIGNAL(itemDoubleClicked(QListWidgetItem *)),SLOT(onListItemDoubleClicked(QListWidgetItem *)));

	if (!FDiscovery->hasDiscoInfo(FStreamJid,FContactJid,ANode) || !FDiscovery->discoInfo(FStreamJid,FContactJid,ANode).error.isNull())
		requestDiscoInfo();
	else
		updateWindow();
}
Exemple #7
0
void Extension::runExtension()
{
    while(1)
    {
        // Less, else the application crash certainly.
        #ifndef WIN32
            usleep(18000);
        #else
            //Sleep(10);
        #endif

        //if( m_paintGLdata.dataUpdated == 0 )
        //{ // Si la donnée a été traitée.

            // Update local data.
            updateData() ;

            // Update window data.
            updateWindow() ;

            // Update GLWidget.
            //updateGLWidget() ;
        //}
    }
}
Exemple #8
0
bool MainWindow::loadFile(const QString &fileName )
{

	cout<<"file:"<<fileName.toStdString()<<endl;
	vector<Molecular>				mol;
	mol = readMolecularFile( fileName.toStdString().c_str() );

	termEdit->append(tr((string("read molecular: ")).c_str())
			+fileName);

	if( ! mol.empty() ){
		for( size_t i=0; i<mol.size(); i++ ){
			molVec.push_back( mol[i] );
		}

		molViewer->updateLine( molVec );
		molViewer->update();

		molTreeViewer->setMolVec( molVec );
		molTreeViewer->update();

		updateWindow();
		createActions();
	}
    return true;
}
void 
AP_UnixDialog_Goto::activate (void)
{
	UT_ASSERT (m_wDialog);
	UT_DEBUGMSG (("ROB: AP_UnixDialog_Goto::activate ()\n"));
	updateWindow ();
	gtk_window_present (GTK_WINDOW (m_wDialog));
}
Exemple #10
0
void cv::imshow( const String& winname, InputArray _img )
{
    CV_TRACE_FUNCTION();
    const Size size = _img.size();
#ifndef HAVE_OPENGL
    CV_Assert(size.width>0 && size.height>0);
    {
        Mat img = _img.getMat();
        CvMat c_img = cvMat(img);
        cvShowImage(winname.c_str(), &c_img);
    }
#else
    const double useGl = getWindowProperty(winname, WND_PROP_OPENGL);
    CV_Assert(size.width>0 && size.height>0);

    if (useGl <= 0)
    {
        Mat img = _img.getMat();
        CvMat c_img = cvMat(img);
        cvShowImage(winname.c_str(), &c_img);
    }
    else
    {
        const double autoSize = getWindowProperty(winname, WND_PROP_AUTOSIZE);

        if (autoSize > 0)
        {
            resizeWindow(winname, size.width, size.height);
        }

        setOpenGlContext(winname);

        cv::ogl::Texture2D& tex = ownWndTexs[winname];

        if (_img.kind() == _InputArray::CUDA_GPU_MAT)
        {
            cv::ogl::Buffer& buf = ownWndBufs[winname];
            buf.copyFrom(_img);
            buf.setAutoRelease(false);

            tex.copyFrom(buf);
            tex.setAutoRelease(false);
        }
        else
        {
            tex.copyFrom(_img);
        }

        tex.setAutoRelease(false);

        setOpenGlDrawCallback(winname, glDrawTextureCallback, &tex);

        updateWindow(winname);
    }
#endif
}
void 
AP_UnixDialog_Goto::notifyActiveFrame (XAP_Frame * /*pFrame*/)
{
	UT_DEBUGMSG (("ROB: notifyActiveFrame ()\n"));
	UT_ASSERT (m_wDialog);

	updateWindow ();
	/* default to page */
	m_JumpTarget = AP_JUMPTARGET_PAGE;
}
Exemple #12
0
void MainWindow::openKhollo(QString filename) {
    record(false);
    //Save directory in preferences
    QString dirpath = QFileInfo(filename).absoluteDir().absolutePath();
    Preferences pref; pref.setDir(dirpath);

    kscopemanager.openFile(filename);
    updateWindow();
    record(QSqlDatabase::database().isOpen());
    return;
}
void 
AP_UnixDialog_Goto::runModeless (XAP_Frame * pFrame)
{
	UT_DEBUGMSG (("ROB: runModeless ()\n"));
	constuctWindow (pFrame);
	UT_ASSERT (m_wDialog);
	updateWindow ();
	abiSetupModelessDialog (GTK_DIALOG (m_wDialog), pFrame, this, GTK_RESPONSE_CLOSE);
	gtk_widget_show_all (m_wDialog);
	gtk_window_present (GTK_WINDOW (m_wDialog));
}
Exemple #14
0
void Plus4EmuGUI_DebugWindow::show()
{
  monitor_->closeTraceFile();
  updateWindow();
  if (!window->shown()) {
    window->resize(savedWindowPositionX, savedWindowPositionY, 960, 720);
    if (focusWidget != (Fl_Widget *) 0 && focusWidget != monitor_)
      focusWidget->take_focus();
    else
      stepButton->take_focus();
  }
  window->show();
}
Exemple #15
0
int main()
{
	windowProcess = (LRESULT CALLBACK)windowProcessN;
	WNDCLASS window = createGLWindow((LPCWSTR)L"Moon Walk Demo", 1280, 800, false);
	onResize(1280, 800);
	glEnable(GL_DEPTH_TEST);

	MSG msg;
	bool done = false;

	initExtendedGL();

	current_state = new main_game();
	current_state->initialize();

	int version = 0;
	printf("%s\n", glGetString(GL_VERSION));
	while(!done)
	{
		if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
		{
			if(msg.message == WM_QUIT)
			{
				done = true;
			}
			else
			{
				TranslateMessage(&msg);
				DispatchMessage(&msg);
			}
		}

		current_state->updateLogic();
	
		// Draw graphics here.
		{
			// Set color and depth clear value
			glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
			glClearColor(0.f, 0.f, 0.f, 0.f);

			current_state->updateGraphics();
		}

		current_state->updateSound();

		updateWindow();
	}
	killGLWindow();

	return 0;
}
Exemple #16
0
/* Remove ACKed segment from send buffer */
TCP_buffer* removeFromSendBuffer (TCP_buffer* bufptr, int sock, struct sockaddr_in timer, int ackno){
  TCP_buffer* p = bufptr;
  TCP_buffer* prev = NULL; 
  struct timeval tim;
  double t1;
    
  /* TODO: Circular buffer */
  
  /* Search for corresponding segment using ACK no*/
  while (p != NULL && (p->ts.hdr.seq + p->len - TCP_HEADER_SIZE) != ackno){
    prev = p;
    /*
    printf("Traversing seq = %d len = %d\n",p->ts.hdr.seq, p->len);
    */
    p = p->next;
  }
  /* Segment found in buffer. Should always be true!*/
  if (p != NULL){
    if (p == bufptr)  bufptr = p->next;
    else  prev->next = p->next;
    p->next = NULL;
    printf("Removed ACKed segment seq = %d\n",p->ts.hdr.seq);
    /* Update M for RTO */
    
    if (p->txCount == 1){
      gettimeofday(&tim, NULL);
      t1 = tim.tv_sec + (tim.tv_usec/1000000.0);
      M = t1 - p->lastTxTime; 
    }
    /*
     * printf("Updating M.. lastTime = %.2f\n",p->lastTxTime);
    */
    /* Send remove request to timer */
    sendTimerRemoveRequest (sock, timer, &(p->ts));
    /* Update send window */
    
    updateWindow (&sendWindow, p->ts.hdr.seq, p->len - TCP_HEADER_SIZE);
    
    free (p);
    sBufCount--;
    if (sBufCount == 0) return NULL;
    /*
    if (bufptr == NULL) printf("Send buffer empty\n");
    */
  }
  /* Should never happen */
  else {
    printf("Segment not found in buffer for ACK = %d\n",ackno);
  }
  return bufptr;
}
Exemple #17
0
void GfxPorts::beginUpdate(Window *wnd) {
	Port *oldPort = setPort(_wmgrPort);
	PortList::iterator it = _windowList.reverse_begin();
	const PortList::iterator end = Common::find(_windowList.begin(), _windowList.end(), wnd);
	while (it != end) {
		// We also store Port objects in the window list, but they
		// shouldn't be encountered during this iteration.
		assert((*it)->isWindow());

		updateWindow((Window *)*it);
		--it;
	}
	setPort(oldPort);
}
Exemple #18
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    m_idRecord = -1;

    connect(ui->action_File_Create, SIGNAL(triggered()), this, SLOT(createKhollo()));
    connect(ui->action_File_Open, SIGNAL(triggered()), this, SLOT(openKhollo()));
    connect(ui->action_File_Settings, SIGNAL(triggered()), this, SLOT(openSettings()));
    connect(ui->action_File_Quit, SIGNAL(triggered()), this, SLOT(close()));
    connect(ui->action_DB_Students, SIGNAL(triggered()), this, SLOT(openStudentsManager()));
    connect(ui->action_DB_Groups, SIGNAL(triggered()), this, SLOT(openGroupsManager()));
    connect(ui->action_DB_Subjects, SIGNAL(triggered()), this, SLOT(openSubjectsManager()));
    connect(ui->action_DB_Kholleurs, SIGNAL(triggered()), this, SLOT(openKholleursManager()));
    connect(ui->action_Schedule_Students_Groups, SIGNAL(triggered()), this, SLOT(openUsersGroupsManager()));
    connect(ui->action_Schedule_Timetable, SIGNAL(triggered()), this, SLOT(openCoursesManager()));
    connect(ui->action_Schedule_Swapping_Groups, SIGNAL(triggered()), this, SLOT(openGroupsSwappingsManager()));
    connect(ui->action_Schedule_Tribes, SIGNAL(triggered()), this, SLOT(openTribesManager()));
    connect(ui->action_Schedule_Kholles, SIGNAL(triggered()), this, SLOT(openTimeslotsManager()));
    connect(ui->action_Schedule_Events, SIGNAL(triggered()), this, SLOT(openEventsManager()));
    connect(ui->action_Kholles_Interface, SIGNAL(triggered()), this, SLOT(openInterface()));
    connect(ui->action_Kholles_Generate, SIGNAL(triggered()), this, SLOT(openKholloscope()));
    connect(ui->action_Kholles_Historic, SIGNAL(triggered()), this, SLOT(openReview()));
    connect(ui->action_Kholles_LastChanges, SIGNAL(triggered()), this, SLOT(openLastChanges()));
    connect(ui->action_Help, SIGNAL(triggered()), this, SLOT(openHelp()));
    connect(ui->action_AboutIt, SIGNAL(triggered()), this, SLOT(openAboutIt()));

    connect(this, SIGNAL(triggerInterface(QDate,int)), this, SLOT(openInterfaceWithDate(QDate,int)));

    m_shortcutNotepad = Notepad::shortcut();
    this->addAction(m_shortcutNotepad);

    updateWindow();

#ifndef Q_OS_MAC
    // Ouvrir directement un fichier sur OS autre que Mac
    args = QCoreApplication::arguments();
    if(args.count() > 1) {
        QString suffix = QFileInfo(args[1]).suffix().toUpper();
        // Check the file suffix
        if(suffix == "KSCOPE") {
            openKhollo(args[1]); // Try to open the file
        } else {
            QMessageBox::critical(this, "Fichier non pris en charge", "Erreur : Fichier " + QFileInfo(args[1]).suffix().toUpper() + " non pris en charge.");
        }
    }
#endif
}
Protocol::Packet *ServerQueue::getNextPacket() {
    static int sentCt = 0;
    if(sentCt == 0) {
        updateWindow();
        std::cout << "refreshing output packet window!" << std::endl;
    }

    Protocol::Packet *rtnPacket = NULL;
    if(window.size() > sentCt) {
        rtnPacket = window.at(sentCt++)->packet;
        sentCt = sentCt%window.size();
    }

    return rtnPacket;
}
TInt WindowManager::newWin(const std::string &params) {
    TInt id = Windows.getNew();
    TuringWindow *newWin = Windows.get(id);
    
    setWinParams(id, params);
    newWin->Win.UseVerticalSync(true);
    // clear both buffers
    clearWin(id);
    updateWindow(id, true);
    clearWin(id);
    // activate
    newWin->Win.Show(true);
    setCurWin(id);
    
    return id;
}
void WindowSystem::handleRequest()
{
    // read request(s)
    QTcpSocket *connection = qobject_cast<QTcpSocket*>(sender());
    QDataStream stream(connection);
    while (!stream.atEnd()) {
        qDebug() << "SERVER: reading request";
        Request request;
        stream >> request;
        // ### FIXME: verify that message type is request
        switch (request.type) {
        case Request::CreateWindowRequest: {
            quint32 id = createWindow(request.id);
            m_connections.insert(id, connection);
            Response response(Response::CreatedWindowResponse, id);
            qDebug() << "SERVER: sending response";
            stream << response;
            break; }
        case Request::DestroyWindowRequest:
            destroyWindow(request.id);
            break;
        case Request::ShowWindowRequest:
            showWindow(request.id);
            break;
        case Request::HideWindowRequest:
            hideWindow(request.id);
            break;
        case Request::RaiseWindowRequest:
            raiseWindow(request.id);
            break;
        case Request::LowerWindowRequest:
            lowerWindow(request.id);
            break;
        case Request::UpdateWindowRequest:
            updateWindow(request.id, request.rect);
            break;
        case Request::SetWindowGeometryRequest:
            setWindowGeometry(request.id, request.rect);
            break;
        default:
            qWarning() << "SERVER: unknown request type" << request.type;
            break;
        };
    } // while (!stream.atEnd())
}
Exemple #22
0
void runGame()
{
	hideCursor();

	initWorld();

	unsigned long curtime = ccTimeMilliseconds();
	double acctime = 0.0;

	while(true){
		ccEvent event = updateWindow();
		if(event.type == CC_EVENT_WINDOW_QUIT){
			break;
		}else if(event.type == CC_EVENT_KEY_DOWN){
			handleKeyDownWorld(event.keyCode);
		}else if(event.type == CC_EVENT_KEY_UP){
			handleKeyUpWorld(event.keyCode);
		}

		unsigned long newtime = ccTimeMilliseconds();
		double frametime = (newtime - curtime) * 0.001;
		curtime = newtime;

		if(frametime > FRAME_CAP){
			frametime = FRAME_CAP;
		}
		acctime += frametime;

		bool redraw = false;
		while(acctime >= FRAME_DELTA){
			acctime -= FRAME_DELTA;
			redraw = updateWorld();
		}

		if(redraw){
			renderWorld(2, 1, getWidth() - getGuiWidth() - 3, getHeight() - 8);
			renderGui(getWidth() - getGuiWidth(), 0);
		}
		renderWindow(2);
		
	}
}
Exemple #23
0
void GfxPorts::endUpdate(Window *wnd) {
	Port *oldPort = setPort(_wmgrPort);
	const PortList::iterator end = _windowList.end();
	PortList::iterator it = Common::find(_windowList.begin(), end, wnd);

	// wnd has to be in _windowList
	assert(it != end);

	while (++it != end) {
		// We also store Port objects in the window list, but they
		// shouldn't be encountered during this iteration.
		assert((*it)->isWindow());

		updateWindow((Window *)*it);
	}

	if (getSciVersion() < SCI_VERSION_1_EGA_ONLY)
		g_sci->_gfxPaint16->kernelGraphRedrawBox(_curPort->rect);

	setPort(oldPort);
}
Exemple #24
0
void MainWindow::openKhollo() {
    //Try to load directory preferences
    Preferences pref;
    QString pref_path = pref.dir();

    //Get file name
    QString fileDB = QFileDialog::getOpenFileName(this, "Ouvrir un fichier", pref_path + QDir::separator(), "KSCOPE (*.kscope)");

    if(fileDB == "") {
        updateWindow();
        return;
    }

    QString suffix = QFileInfo(fileDB).suffix().toUpper();
    // Check the file suffix
    if(suffix == "KSCOPE")
        openKhollo(fileDB); // Try to open the file
    else
        QMessageBox::critical(this, "Fichier non pris en charge", "Erreur : Fichier " + QFileInfo(fileDB).suffix().toUpper() + " non pris en charge.");

    return;
}
Exemple #25
0
void Dialogue::setNextNode(int choice) {
	if (m_currentNode == nullptr) return;
	int nextNode;
	if (choice == -1) {
		nextNode = m_currentNode->nextTag;
	}
	else {
		nextNode = m_currentNode->choices[choice].second;
	}

	if (nextNode == -1) {
		m_currentNode = nullptr;
		return;
	}
	else if (nextNode == -2) {
		reload(m_id, m_screen, m_window);
		updateWindow();
		return;
	}

	m_currentNode = &m_nodes[nextNode];
}
Exemple #26
0
void cv::imshow(const String& winname, const ogl::Texture2D& _tex)
{
    CV_TRACE_FUNCTION();
#ifndef HAVE_OPENGL
    CV_UNUSED(winname);
    CV_UNUSED(_tex);
    CV_Error(cv::Error::OpenGlNotSupported, "The library is compiled without OpenGL support");
#else
    const double useGl = getWindowProperty(winname, WND_PROP_OPENGL);

    if (useGl <= 0)
    {
        CV_Error(cv::Error::OpenGlNotSupported, "The window was created without OpenGL context");
    }
    else
    {
        const double autoSize = getWindowProperty(winname, WND_PROP_AUTOSIZE);

        if (autoSize > 0)
        {
            Size size = _tex.size();
            resizeWindow(winname, size.width, size.height);
        }

        setOpenGlContext(winname);

        cv::ogl::Texture2D& tex = wndTexs[winname];

        tex = _tex;

        tex.setAutoRelease(false);

        setOpenGlDrawCallback(winname, glDrawTextureCallback, &tex);

        updateWindow(winname);
    }
#endif
}
Exemple #27
0
int main(){
	createWindow();
	printf("This is SDL primitives\r\n");
	//pthread_t t1, t2, th;

	while( !quit ) {
		//Handle events on queue
		while( SDL_PollEvent( &e ) != 0 ){
			//User requests quit
			if( e.type == SDL_QUIT ){
				quit = true;
			}
		}
		char str[56];
		uint len = snprintf(str, sizeof(str),"%0.2f", elapsed);
		updateWindow(str, len);
		for(uint i=0; i<5; i++)keyBoard[i*2].pressed ^= true; 
		SDL_Delay(500);
		elapsed += 0.5;
	}		
	closeWindow();
	return 0;
}
Exemple #28
0
/*
=====================
	initSystem
=====================
*/
BOOL initSystem() {

	//get game directory path (Ex: D:\Games\Netrix)
	//
	GetCurrentDirectory( MAX_PATH, k_system.szStartDir );

	N_InitTrace();

	//init Win32 system
	//
	initWin32();

	//System
	//
	k_system.pLeftGame	= NULL;
	k_system.pRightGame	= NULL;
	k_system.gameType	= GNO;
	k_system.pause		= FALSE;
	k_system.flags		= 0;
	k_system.dwAccumTime	= 0;
	k_system.dwTime		= 0;
	
	//Maps
	//
	k_system.cMaps	= 0;
	k_system.pMaps	= NULL;
	k_system.idMap	= -1;
	
	//Bots
	//
	k_system.cBots	= 0;
	k_system.pBots	= NULL;
	k_system.idBotLeft	= -1;
	k_system.idBotRight	= -1;
	
	//Paths
	//
	k_system.pPaths	= NULL;
	k_system.cPaths	= 0;
	
	//HWND
	//
	k_system.hwnd		= NULL;
	k_system.hwndLeft	= NULL;
	k_system.hwndRight	= NULL;
	
	k_system.cPlayers	= 0;

	initRandom();

	cfInitTable();

	//resources
	//
	loadResources();
	
	//init bot system
	//
	botInit();

	//Skins
	//
	loadSkin( &k_system.hSkinRgnLeft, &k_system.hSkinBitmapLeft,
		&k_system.cxSkinLeft, &k_system.cySkinLeft, IDR_SKIN_LEFT );

	loadSkin( &k_system.hSkinRgnRight, &k_system.hSkinBitmapRight,
		&k_system.cxSkinRight, &k_system.cySkinRight, IDR_SKIN_RIGHT );

	createWindow();
	
	//GUI
	//
	populateGUI();

	if( !initGraphics( NEUTRAL ) )
		return FALSE;

	if( !initGraphics( LEFTGAME ) )
		return FALSE;

	updateWindow( CGF_DRAWLEFT );
	
	//winmm
	timeBeginPeriod( 1 );
	
	return TRUE;
}
Exemple #29
0
void cv::imshow( const std::string& winname, InputArray _img )
{
#ifndef HAVE_OPENGL
    Mat img = _img.getMat();
    CvMat c_img = img;
    cvShowImage(winname.c_str(), &c_img);
#else
    const double useGl = getWindowProperty(winname, WND_PROP_OPENGL);

    if (useGl <= 0)
    {
        Mat img = _img.getMat();
        CvMat c_img = img;
        cvShowImage(winname.c_str(), &c_img);
    }
    else
    {
        const double autoSize = getWindowProperty(winname, WND_PROP_AUTOSIZE);

        if (autoSize > 0)
        {
            Size size = _img.size();
            resizeWindow(winname, size.width, size.height);
        }

        setOpenGlContext(winname);

        if (_img.kind() == _InputArray::OPENGL_TEXTURE)
        {
            cv::ogl::Texture2D& tex = wndTexs[winname];

            tex = _img.getOGlTexture2D();

            tex.setAutoRelease(false);

            setOpenGlDrawCallback(winname, glDrawTextureCallback, &tex);
        }
        else
        {
            cv::ogl::Texture2D& tex = ownWndTexs[winname];

            if (_img.kind() == _InputArray::GPU_MAT)
            {
                cv::ogl::Buffer& buf = ownWndBufs[winname];
                buf.copyFrom(_img);
                buf.setAutoRelease(false);

                tex.copyFrom(buf);
                tex.setAutoRelease(false);
            }
            else
            {
                tex.copyFrom(_img);
            }

            tex.setAutoRelease(false);

            setOpenGlDrawCallback(winname, glDrawTextureCallback, &tex);
        }

        updateWindow(winname);
    }
#endif
}
Exemple #30
0
void RedefineDlg::displayLine(const QString& info)
{
  this->enableButtonOk(false);
  QString txt;
  txt.setNum(m_typeColumn + 1);
  m_widget->label_actionCol->setText(i18n("Column ") + txt);
  m_widget->label_info->setText(info);
  m_maxCol = m_columnList.count();
  m_widget->tableWidget->setColumnCount(m_maxCol);

  QBrush brush;
  QColor colr;
  colr.setRgb(255, 0, 127, 100);
  brush.setColor(colr);
  brush.setStyle(Qt::SolidPattern);
  int row;
  m_columnTotalWidth = 0;
  m_maxWidth = 0;
  m_widget->tableWidget->setRowCount(2);
  for (int col = 0; col < m_maxCol; col++) {
    row = 1;
    txt = m_columnList[col];
    txt = txt.remove('"');

    QTableWidgetItem *item = new QTableWidgetItem;//  add items to UI
    item->setText(txt);
    m_widget->tableWidget->setItem(row, col, item);  // add items to UI here
    if (m_typeColumn == col) {
      item->setBackground(brush);
    }
    row = 0;
    if (col == m_quantityColumn) {
      QTableWidgetItem *item = new QTableWidgetItem;//        add items to UI
      item->setText(i18n("Quantity"));
      m_widget->tableWidget->setItem(row, col, item);
    } else if (col == m_priceColumn) {
      QTableWidgetItem *item = new QTableWidgetItem;//        add items to UI
      item->setText(i18n("Price"));
      m_widget->tableWidget->setItem(row, col, item);
    } else if (col == m_amountColumn) {
      QTableWidgetItem *item = new QTableWidgetItem;//        add items to UI
      item->setText(i18n("Amount"));
      m_widget->tableWidget->setItem(row, col, item);
    } else if (col == m_typeColumn) {
      QTableWidgetItem *item = new QTableWidgetItem;//        add items to UI
      item->setText(i18n("Type"));
      m_widget->tableWidget->setItem(row, col, item);
    } else if (col == m_detailColumn) {
      QTableWidgetItem *item = new QTableWidgetItem;//        add items to UI
      item->setText(i18n("Detail"));
      m_widget->tableWidget->setItem(row, col, item);
    }
  }
  m_widget->tableWidget->resizeColumnsToContents();
  for (int col = 0; col < m_maxCol; col++) {
    m_columnTotalWidth += m_widget->tableWidget->columnWidth(col);
  }
  if (m_columnTotalWidth > m_maxWidth) {
    m_maxWidth = m_columnTotalWidth;
  }
  updateWindow();
}