int
main(int argc, char *argv[])
{
   Display *dpy;
   GLXFBConfig pixmapConfig;
   XVisualInfo *windowVis;
   GLXPixmap gp;
   Window win;
   GLXContext ctx;
   Pixmap p;

   dpy = OpenDisplay();

   pixmapConfig = ChoosePixmapFBConfig(dpy);
   windowVis = ChooseWindowVisual(dpy);
   win = CreateWindow(dpy, windowVis, 500, 500, "Texture From Pixmap");

   gp = CreatePixmap(dpy, pixmapConfig, 512, 512, &p);
   DrawPixmapImage(dpy, p, 512, 512);

   ctx = glXCreateContext(dpy, windowVis, NULL, True);
   if (!ctx) {
      printf("Couldn't create GLX context\n");
      exit(1);
   }

   glXMakeCurrent(dpy, win, ctx);

   BindPixmapTexture(dpy, gp);

   EventLoop(dpy, win);

   return 0;
}
Esempio n. 2
0
/*---------------------------main------------------------
              M A I N   E N T R Y    P O I N T
  ---------------------------main------------------------*/
int main(int argc, char *argv[])
{
	struct sockaddr_in server;
	struct hostent *sp;
	char *host;
	*global_argv = *argv;
    openlog("browser", LOG_PID, LOG_USER);
	setlogmask(LOG_UPTO(LOG_DEBUG));
    syslog(LOG_INFO, "%s STARTED", argv[0]);

	/* Create a socket */
	sockfd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);

	/* Connect it to a server */
	memset((char *) &server, 0, sizeof(struct sockaddr_in));
	server.sin_family = AF_INET;
	server.sin_port = htons((u_short) PORT);
	sp = gethostbyname(SERVER);
	memcpy(&server.sin_addr, sp->h_addr, sp->h_length);
	connect(sockfd, (struct sockaddr *) &server, sizeof(struct sockaddr_in));

	/* All event driven I/O starts in the EventLoop */
	int rc = EventLoop();
	/* This process ends when all event driven I/O file descriptors are closed */

    syslog(LOG_INFO, "%s SHUTDOWN ", argv[0]);
	/* SHUTDOWN */
	close(sockfd);
	exit(0);
}
Esempio n. 3
0
// Begin 'context help mode'
bool wxContextHelp::BeginContextHelp(wxWindow* win)
{
    if (!win)
        win = wxTheApp->GetTopWindow();
    if (!win)
        return false;

    wxCursor cursor(wxCURSOR_QUESTION_ARROW);
    wxCursor oldCursor = win->GetCursor();
    win->SetCursor(cursor);

#ifdef __WXMAC__
    wxSetCursor(cursor);
#endif

    m_status = false;

#ifdef __WXMOTIF__
    wxPushOrPopEventHandlers(this, win, true);
#else
    win->PushEventHandler(new wxContextHelpEvtHandler(this));
#endif

    win->CaptureMouse();

    EventLoop();

    win->ReleaseMouse();

#ifdef __WXMOTIF__
    wxPushOrPopEventHandlers(this, win, false);
#else
    win->PopEventHandler(true);
#endif

    win->SetCursor(oldCursor);

#ifdef __WXMAC__
    wxSetCursor(wxNullCursor);
#endif

    if (m_status)
    {
        wxPoint pt;
        wxWindow* winAtPtr = wxFindWindowAtPointer(pt);

#if 0
        if (winAtPtr)
        {
            printf("Picked %s (%d)\n", winAtPtr->GetName().c_str(),
                   winAtPtr->GetId());
        }
#endif

        if (winAtPtr)
            DispatchEvent(winAtPtr, pt);
    }

    return true;
}
Esempio n. 4
0
/*---------------------------main------------------------
              M A I N   E N T R Y    P O I N T
  ---------------------------main------------------------*/
int main(int argc, char *argv[])
{
	char 		result[BUFFSIZE];
	*global_argv = *argv;
    LogOpenSystem("application");
	LogDebugOn();
    LogDebug("%s STARTED ", argv[0]);
	sprintf(result, "Application Started\n");
	Writen(STDOUT_FILENO, result, strlen(result));
	sprintf(result, "*******************\n");
	Writen(STDOUT_FILENO, result, strlen(result));
	sprintf(result, "*   Hello World   *\n");
	Writen(STDOUT_FILENO, result, strlen(result));
	sprintf(result, "*   dlroW olleH   *\n");
	Writen(STDOUT_FILENO, result, strlen(result));
	sprintf(result, "*******************\n");
	Writen(STDOUT_FILENO, result, strlen(result));

	int rc = EventLoop();

    LogDebug("%s SHUTDOWN ", argv[0]);
	/* SHUTDOWN */
	close(sockfd);
	exit(0);
}
Esempio n. 5
0
	void Application::Run()
	{
		running_ = Initialize();
		while (running_)
		{
			clock_.beginFrame();
			sfx::Global::Input.Update();
			EventLoop();
			/*if (sf::Keyboard::isKeyPressed(sf::Keyboard::LAlt) && sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
			{
				running_ = false;
			}*/
			if (running_)
			{
				running_ = Update();
				if (running_)
				{
					window_.clear(sf::Color::Black);
					Render();
					window_.draw(hud_);
					window_.display();
				}
			}
			clock_.endFrame();
		}
		window_.close();
		CleanUp();
		Global::UnloadGlobalResources();
	}
Esempio n. 6
0
CocoDeviceWrapper::CocoDeviceWrapper(android_app* i_app) : app(i_app), jenv(nullptr), glwrap(nullptr), video(false)
{
	app->userData = this;
	app->onAppCmd = StateHandler;
	app->onInputEvent = InputHandler;

    JavaVMAttachArgs jvmArgs;
    jvmArgs.version = JNI_VERSION_1_6;
    jvmArgs.name = "NativeThread";
    jvmArgs.group = NULL;

	app->activity->vm->GetEnv((void**)&jenv, JNI_VERSION_1_6);
	if(app->activity->vm->AttachCurrentThread(&jenv, &jvmArgs) == JNI_ERR)
	{
		trace("ERROR(CocoDeviceWrapper.cpp): Could not AttachCurrentThread to JavaVM");
	}
	else
	{
		jclass jcls = jenv->GetObjectClass(app->activity->clazz);
		jmID_KeyboardShow = jenv->GetMethodID(jcls, "KeyboardShow", "()V");
		jmID_KeyboardHide = jenv->GetMethodID(jcls, "KeyboardHide", "()V");
		jmID_KeyboardToggle = jenv->GetMethodID(jcls, "KeyboardToggle", "()V");
		jmID_PlayVideo = jenv->GetMethodID(jcls, "PlayVideo", "()V");
		jmID_GetScreenRotation = jenv->GetMethodID(jcls, "GetScreenRotation", "()I");
		jmID_GetScreenIsPortrait = jenv->GetMethodID(jcls, "GetScreenIsPortrait", "()Z");
		jmID_GetScreenTop = jenv->GetMethodID(jcls, "GetScreenTop", "()I");
	}
	EventLoop();
}
Esempio n. 7
0
File: main.c Progetto: DeRampage/Mop
int main(int argc, char**argv)
{
	int errno =  0;
	srand(time(NULL));
	if (errno = PacMan())
	{
		return errno;
	}
	
	/* ToDo: add Timer-Callbacks for Goodies */
	//SDL_TimerID timer = SDL_AddTimer(200, NewGoodie, NULL);
	if(CheckEvents()){
		return 0;
	}
	SDL_TimerID timer = SDL_AddTimer(randomGTime(2000, 7000), NewGoodie, NULL);
	if(timer){
		printf("Timer erfolgreich erstellt!\n");
	}
	thrd_create(NULL, Enemy, NULL);
	
	
	/* Implementation of an enemy *********************************************/
	/* An enemy lives for 25 Steps and walks a bit slower than the player ... */
	/**************************************************************************/
	
	/* ToDo: move enemy into Thread */
	/* Already done */
	
	
	
	/* EventLoop */
	
	return EventLoop();
	
}
Esempio n. 8
0
File: demo.c Progetto: OpenMORDM/rgl
int
main(int argc, char *argv[])
{
   Display *dpy;
   WindowData winData;

   dpy = XOpenDisplay(NULL);
   if (!dpy) {
      printf("Error: couldn't open default display.\n");
      return -1;
   }

   MakeWindow(dpy, "glprocs test", 0, 0, 300, 300, &winData);
   XMapWindow(dpy, winData.window);
   glXMakeCurrent(dpy, winData.window, winData.context);

   InitializeOpenGL(&winData);

   EventLoop(&winData);

   glXDestroyContext(dpy, winData.context);
   XDestroyWindow(dpy, winData.window);
   XCloseDisplay(dpy);

   return 0;
}
ConnectionDispatcherTask::ConnectionDispatcherTask(int num_handlers,
                                                   int listen_fd)
    : NotifiableTask(MASTER_THREAD_ID), next_handler_(0) {
  RegisterEvent(
      listen_fd, EV_READ | EV_PERSIST,
      METHOD_AS_CALLBACK(ConnectionDispatcherTask, DispatchConnection), this);
  RegisterSignalEvent(SIGHUP, METHOD_AS_CALLBACK(NotifiableTask, ExitLoop),
                      this);

  // TODO(tianyu) Figure out what this initialization logic is doing and
  // potentially rewrite
  // register thread to epoch manager.
  if (concurrency::EpochManagerFactory::GetEpochType() ==
      EpochType::DECENTRALIZED_EPOCH) {
    for (size_t task_id = 0; task_id < (size_t)num_handlers; task_id++) {
      concurrency::EpochManagerFactory::GetInstance().RegisterThread(task_id);
    }
  }

  // create worker threads.
  for (int task_id = 0; task_id < num_handlers; task_id++) {
    auto handler = std::make_shared<ConnectionHandlerTask>(task_id);
    handlers_.push_back(handler);
    thread_pool.SubmitDedicatedTask([=] { handler->EventLoop(); });
  }
}
Esempio n. 10
0
Client::Client()
    : mMesgId(0) 
{ 
    mEpoller = NEW Epoller();
    mLoop = NEW EventLoop(mEpoller);
    mSock = NEW Socket(false);
}
Esempio n. 11
0
static
PVOID
EventThread(
    PVOID pContext
    )
{
    EventLoop((PSELECT_THREAD) pContext);

    return NULL;
}
Esempio n. 12
0
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/,
                     LPSTR /*lpCmdLine*/, int nCmdShow) {
    sprintf(szAppClass, "GameServer%d", (int) hInstance);
    if (!InitApplication(hInstance)) return (false);
    if (!InitInstance(hInstance, nCmdShow)) return (false);

    Initialize();
    EventLoop();
    return 0;
}
Esempio n. 13
0
static
PVOID
EventThread(
    PVOID pContext
    )
{
    EventLoop((PKQUEUE_THREAD) pContext);

    return NULL;
}
Esempio n. 14
0
static void Run(intf_thread_t *intf)
{
  intf_sys_t *sys = intf->p_sys;
  int fd;

  int canc = vlc_savecancel();

  RegisterCallbacks(intf);

  while(1) {
    msg_Info(intf, "Creating IRC connection...");

    fd = net_ConnectTCP(VLC_OBJECT(intf), sys->server, 6667);

    if(fd == -1) {
      msg_Err(intf, "Error connecting to server");
      return;
    }

    msg_Info(intf, "Connected to server");

    /* initialize context */
    sys->fd = fd;
    sys->line_loc = 0;

    SendBufferInit(intf);

    SendBufferAppend(intf, "NICK ");
    SendBufferAppend(intf, sys->nick);
    SendBufferAppend(intf, "\r\n");

    SendBufferAppend(intf, "USER ");
    SendBufferAppend(intf, sys->nick);
    SendBufferAppend(intf, " 8 * vlc\r\n");

    sys->playlist = pl_Get(intf);

    #ifdef STOP_HACK
    playlist_Pause(sys->playlist);
    input_thread_t * input = playlist_CurrentInput(sys->playlist);
    var_SetFloat(input, "position", 0.0);
    #endif

    EventLoop(fd, intf);

    free(sys->send_buffer->buffer);

    sleep(30);
  }

  free(sys);

  vlc_restorecancel(canc);
}
Esempio n. 15
0
int main(int argc, char *argv[])
{
	Initialize();
	MakeWindow();
	MakeMenu();
    
    InstallTimer();
    
	EventLoop();

	return 0;
}
Esempio n. 16
0
//=============================================================================
int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
               LPSTR lpCmdLine, int nCmdShow )
{
	LogMsg.CurMsg = MAXLOGMSGS-1;
	sprintf( szAppClass, "GameServer%d", hInstance);
	if (!InitApplication( hInstance))		return (FALSE);
    if (!InitInstance(hInstance, nCmdShow)) return (FALSE);

	Initialize();
	EventLoop();
    return 0;
}
Esempio n. 17
0
File: gmi.c Progetto: miellaby/v4p
UInt32 PilotMain(UInt16 launchCode, MemPtr cmdPBP, UInt16 launchFlags)
{

    Err err;
    if (launchCode == sysAppLaunchCmdNormalLaunch) {
        if ((err = StartApplication()) == 0) {
            EventLoop();
            StopApplication();
        }
    }
    return 0;
}
Esempio n. 18
0
void MenuBar::Execute(Ctrl *owner, Point p)
{
	static Vector<Ctrl *> ows; // Used to prevent another open local menu for single owner to be opened (repeated right-click)
	int level = ows.GetCount();
	if(IsEmpty() || FindIndex(ows, owner) >= 0)
		return;
	ows.Add(owner);
	PopUp(owner, p);
	EventLoop(this);
	CloseMenu();
	ows.SetCount(level);
}
Esempio n. 19
0
DWord
PilotMain(Word cmd, Ptr cmdPBP, Word launchFlags)
{
    if (cmd == sysAppLaunchCmdNormalLaunch)
    {
        StartApplication ();
        FrmGotoForm (mainForm);
        EventLoop ();
        StopApplication ();
    }
    return (0);
}
Esempio n. 20
0
ULong PilotMain( UInt launchCode, Ptr cmdPBP, UInt launchFlags )
{
	Err err=0;

	if( launchCode == sysAppLaunchCmdNormalLaunch ) {
		if( (err=StartApplication()) == 0 ) {
			EventLoop();
			StopApplication();
		}
	}

	return err;
}
Esempio n. 21
0
DWord
PilotMain (Word cmd, Ptr cmdPBP, Word launchFlags)
{
    int error;

    if (cmd == sysAppLaunchCmdNormalLaunch) {
	error = StartApplication();
	if (error) return error;
	EventLoop();
	StopApplication();
    }

    return 0;
}
Esempio n. 22
0
/** Process a menu action. */
int DoAction() {
   switch(GetMenuAction()) {
   case MENU_START:
      HideMenu();
      EventLoop();
      ShowMenu();
      return 1;
   case MENU_EXIT:
      HideMenu();
      return 0;
   default:
      return 1;
   }
}
Esempio n. 23
0
int  TopWindow::Run(bool appmodal)
{
	GuiLock __;
	LLOG("TopWindow::Run() <- " << typeid(*this).name());
	LLOG("Focus = " << UPP::Name(GetFocusCtrl()));
	if(!IsOpen())
		Open();
	if(!IsVisible()) Show();
	bool pinloop = inloop;
	int  pexitcode = exitcode;
	exitcode = Null;
	Vector<Ctrl *> es;
	if(appmodal)
		es = GetTopCtrls();
	else {
		Vector<Ctrl *> ws = GetTopCtrls();
		for(int i = 0; i < ws.GetCount(); i++)
			if(ws[i]->InLoop())
				es.Add(ws[i]);
		Ctrl *mw = GetMainWindow();
		if(mw) GatherWindowTree(mw, ws, es);
	}
	Vector< Ptr<Ctrl> > disabled = DisableCtrls(es, this);
#ifdef _DEBUG
	for(int d = 0; d < disabled.GetCount(); d++)
		LLOG("DisableCtrls[" << d << "] = " << UPP::Name(disabled[d]));
	LLOG("Running EventLoop in " << UPP::Name(this));
#endif
	EventLoop(this);
#ifdef _DEBUG
	LLOG("Finished EventLoop in " << UPP::Name(this));
	for(int e = 0; e < disabled.GetCount(); e++)
		LLOG("EnableCtrls[" << e << "] = " << UPP::Name(disabled[e]));
#endif
	EnableCtrls(disabled);
	if(IsNull(exitcode)) {
		WhenClose();
		if(IsNull(exitcode))
			DefaultBreak();
	}
	int q = exitcode;
	inloop = pinloop;
	exitcode = pexitcode;		
	LLOG("TopWindow::Run() = " << q << " -> " << typeid(*this).name());
#ifdef GUI_WIN
	LLOG("Focus = " << UPP::Name(GetFocusCtrl()) << ", raw " << (void *)::GetFocus());
#endif
	return q;
}
Esempio n. 24
0
int
main(int argc, char *argv[])
{
   char *dpyName = NULL;
   int i;

   if (argc == 1) {
      printf("manywin: open N simultaneous glx windows\n");
      printf("Usage:\n");
      printf("  manywin [-s] numWindows\n");
      printf("Options:\n");
      printf("  -s = swap immediately after drawing (see src code)\n");
      printf("Example:\n");
      printf("  manywin 10\n");
      return 0;
   }
   else {
      int n = 3;
      for (i = 1; i < argc; i++) {
         if (strcmp(argv[i], "-s") == 0) {
            SwapSeparate = GL_FALSE;
         }
         else if (strcmp(argv[i], "-display") == 0 && i < argc) {
            dpyName = argv[i+1];
            i++;
         }
         else {
            n = atoi(argv[i]);
         }
      }
      if (n < 1)
         n = 1;

      printf("%d windows\n", n);
      for (i = 0; i < n; i++) {
         char name[100];
         struct head *h;
         sprintf(name, "%d", i);
         h = AddHead(dpyName, name);
         if (h) {
            PrintInfo(h);
         }
      }
   }

   EventLoop();
   DestroyHeads();
   return 0;
}
Esempio n. 25
0
int main(int argc, char * argv[])
{
	uv_signal_t signals;
	uv_signal_init(uv_default_loop(), &signals);
	uv_signal_start(&signals, &_SignalFunc, SIGINT);
	int hInstance = 0; // TODO: getpid?
	sprintf( szAppClass, "Gate-Server%d", hInstance);
	if (!InitApplication( hInstance))		return (false);
    if (!InitInstance()) return (false);
	
	Initialize();
	EventLoop();

    return 0;
}
Esempio n. 26
0
int main( int argc, const char** argv )
{
    ParseOptions(argc, argv);
    ConvertCrLf = (strcmp(ConvertCrLfStr, "on") == 0);

    OpenSerialPort(&SerialPort, SP_MODE_READ|SP_MODE_WRITE);

    InstallSignalHandler();

    EventLoop();

    sp_close(SerialPort);
    sp_free_port(SerialPort);
    return 0;
}
Esempio n. 27
0
    virtual void Work()
    {
        // Open a database
        GetViewerMethods()->InvertBackgroundColor();
        GetViewerMethods()->OpenDatabase("/usr/gapps/visit/data/noise.silo");
        Synchronize();

        // Create a plot and draw it.
        int plotType = PlotIndex("Pseudocolor");
        if(plotType != INVALID_PLUGIN_INDEX)
        {
            debug1 << "Plot type = " << plotType << endl;
            GetViewerMethods()->AddPlot(plotType, "hardyglobal");
      
            int threeSlice = OperatorIndex("ThreeSlice");
            if(threeSlice != INVALID_PLUGIN_INDEX)
                GetViewerMethods()->AddOperator(threeSlice);
            GetViewerMethods()->DrawPlots();
        }
        Synchronize();

        // Save an image.
        GetViewerMethods()->SaveWindow();

        // Set some pseudocolor plot attributes using the base class'
        // SetValue methods.
        AttributeSubject *pcAtts = GetViewerState()->GetPlotAttributes(plotType);
        if(pcAtts != 0)
        {
            pcAtts->SetValue("min", 1.5);
            pcAtts->SetValue("minFlag", true);
            pcAtts->SetValue("max", 4.5);
            pcAtts->SetValue("maxFlag", true);
            pcAtts->SetValue("colorTableName", "calewhite");
            pcAtts->Notify();
            GetViewerMethods()->SetPlotOptions(plotType);
        }

        // Save an image.
        GetViewerMethods()->SaveWindow();

        // Enter an event loop so the program keeps running and we can
        // interact with the viewer.
        EventLoop();
    }
int
main(int argc, char *argv[])
{
   const char *dpyName = XDisplayName(NULL);

   struct window *h0, *h1, *h2, *h3;

   /* four windows and contexts sharing display lists and texture objects */
   h0 = AddWindow(dpyName,  10,  10, NULL);
   h1 = AddWindow(dpyName, 330,  10, h0);
   h2 = AddWindow(dpyName,  10, 350, h0);
   h3 = AddWindow(dpyName, 330, 350, h0);

   InitGLstuff(h0);

   EventLoop();
   return 0;
}
Esempio n. 29
0
/* Main entry point; it is unlikely you will need to change this except to
   handle other launch command codes */
UInt32 PilotMain(UInt16 cmd, void *cmdPBP, UInt16 launchFlags)
{
    UInt16 err;

    if (cmd == sysAppLaunchCmdNormalLaunch) {

	err = StartApplication();
	if (err) return err;

	EventLoop();
	StopApplication();

    } else {
	return sysErrParamErr;
    }

    return 0;
}
Esempio n. 30
0
int
main(int argc, char *argv[])
{
   const char *dpyName = XDisplayName(NULL);
   pthread_t t0, t1, t2, t3;
   struct thread_init_arg tia0, tia1, tia2, tia3;
   struct window *h0;

   XInitThreads();

   gDpy = XOpenDisplay(dpyName);
   if (!gDpy) {
      Error(dpyName, "Unable to open display");
      return -1;
   }

   if (initMainthread(gDpy, dpyName))
      return -1;

   /* four windows and contexts sharing display lists and texture objects */
   h0 = AddWindow(gDpy, dpyName,  10,  10, gCtx);
   (void) AddWindow(gDpy, dpyName, 330,  10, gCtx);
   (void) AddWindow(gDpy, dpyName,  10, 350, gCtx);
   (void) AddWindow(gDpy, dpyName, 330, 350, gCtx);

   if (!glXMakeCurrent(gDpy, h0->Win, gCtx)) {
      Error(dpyName, "glXMakeCurrent failed for init thread.");
      return -1;
   }

   InitGLstuff();

   tia0.id = 0;
   pthread_create(&t0, NULL, threadRunner, &tia0);
   tia1.id = 1;
   pthread_create(&t1, NULL, threadRunner, &tia1);
   tia2.id = 2;
   pthread_create(&t2, NULL, threadRunner, &tia2);
   tia3.id = 3;
   pthread_create(&t3, NULL, threadRunner, &tia3);
   EventLoop();
   return 0;
}