Пример #1
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    connect(ui->btnGuardar,SIGNAL(clicked()),this,SLOT(openDisplay()));
}
Пример #2
0
 XWindow::XWindow(Utilities::Memory::MemoryManager* const, unsigned int w, unsigned int h,
                  unsigned int, bool fullscreen)
     : fbConfig(0), window(0)
 {
     openDisplay();
     findFrameBufferConfiguration();
     createWindow(w, h, fullscreen);
 }
Пример #3
0
static Display *
defaultXDisplay()
{ DisplayObj d = CurrentDisplay(NIL);
  DisplayWsXref r;

  openDisplay(d);
  r = d->ws_ref;

  return r->display_xref;
}
Пример #4
0
int main(void) {
    if (!openDisplay()) {
        return 1;
    }

    grab(getKeys(), getButtons());

    while (1) {
        nextEvent();
        processEvent();
    }
}
    int DisplayDispatcher::setDispProp(int cmd,int param0,int param1,int param2)
    {
        switch(cmd)
        {
            case  DISPLAY_CMD_SETDISPPARA:
                return  setDisplayParameter(param0,param1,param2);

            case  DISPLAY_CMD_CHANGEDISPMODE:
                return  changeDisplayMode(param0,param1,param2);

            case  DISPLAY_CMD_CLOSEDISP:
                return  closeDisplay(param0);

            case  DISPLAY_CMD_OPENDISP:
                return  openDisplay(param0);

            case  DISPLAY_CMD_GETDISPCOUNT:
                return  getDisplayCount();

            case DISPLAY_CMD_GETDISPLAYMODE:
                return  getDisplayMode();

            case DISPLAY_CMD_GETDISPPARA:
                return  getDisplayParameter(param0,param1);

            case DISPLAY_CMD_GETHDMISTATUS:
                return  getHdmiStatus();

            case DISPLAY_CMD_GETMASTERDISP:
                return  getMasterDisplay();

            case DISPLAY_CMD_GETMAXHDMIMODE:
                return  getMaxHdmiMode();

            case DISPLAY_CMD_GETMAXWIDTHDISP:
                return  getMaxWidthDisplay();

            case DISPLAY_CMD_GETTVSTATUS:
                return  getTvDacStatus();

            case DISPLAY_CMD_SETMASTERDISP:
                return  setMasterDisplay(param0);

            case DISPLAY_CMD_SETDISPMODE:
                return  setDisplayMode(param0);

            default:
                LOGE("Display Cmd not Support!\n");
                return  -1;
        }
    }
Пример #6
0
X11UIEngine::X11UIEngine() : 
  _display(NULL),
  _fd(-1),
  _screen(-1),
  _root(0),
  _gc(0),
  _visual(NULL),
  _colorMap(0),
  _xim(0),
  _numButtons(0),
  _xShm(false),
  _xPrivateColorMap(false),
  _xForcePixmap(true),
  _xDontLogUnsupportedBpp(false),
  _wmClientLeader(0),
  _atomNames(X11UIEngine_atomNames)
{
  _wakeUpPipe[0] = -1;
  _wakeUpPipe[1] = -1;
  
  // Make sure that there is no garbage in these arrays.
  MemOps::zero(_atomList, X11_ATOM_COUNT * sizeof(XAtom));
  MemOps::zero(&_keyMap , sizeof(_keyMap));
  MemOps::zero(&_XLib   , sizeof(_XLib));
  MemOps::zero(&_XExt   , sizeof(_XExt));
  MemOps::zero(&_XRender, sizeof(_XRender));

  if (openXlib() != ERR_OK)
    return;

  if (openDisplay() != ERR_OK)
    return;
  
  initDisplay();
  initKeyboard();
  initMouse();

  _eventLoop.adopt(fog_new X11UIEventLoopImpl(this));
  _isInitialized = true;
}
Пример #7
0
int main(int argc, char *argv[]) {
	mandelPars pars;
	int i,k,x,y,level,*res,check;
	int xoff,yoff, thrCheck;
	long double reStep,imStep;
	Toolbox **Tool;
	pthread_t *thrP;
	
	printf("\n");
	printf("This program starts by drawing the default Mandelbrot region\n");
	printf("When done, you can click with the mouse on an area of interest\n");
	printf("and the program will zoom at this point\n");
	printf("\n");
	printf("Press enter to continue\n");
	getchar();
	
	pars.rePixels = WinW; /* never changes */
	pars.imPixels = WinH; /* never changes */
	
	/* default mandelbrot region */
	
	pars.reBeg = (long double) -2.0;
	pars.reEnd = (long double) 1.0;
	pars.imBeg = (long double) -1.5;
	pars.imEnd = (long double) 1.5;
	
	reStep = (pars.reEnd - pars.reBeg) / pars.rePixels;
	imStep = (pars.imEnd - pars.imBeg) / pars.imPixels;
	
	printf("enter max iterations (50): ");
	scanf("%d",&pars.maxIterations);
	printf("enter no of slices: ");
	scanf("%d",&pars.slices);
	
	/* adjust slices to divide win height */
	
	while (WinH % pars.slices != 0) { pars.slices++;}
	
	/* allocate result and ready arrays */
	
	res = (int *) malloc(sizeof(int)*pars.rePixels*pars.imPixels);
	
	
	/* open window for drawing results */
	
	openDisplay();
	openWin(argv[0], WinW, WinH);
	
	
	level = 1;
	
	if (NULL== (Tool=(Toolbox**)malloc(sizeof(Toolbox)*pars.slices))){
		perror ("Memory Error");
	}
	
	
	
	for (i=0; i<pars.slices; i++){
		
		if (NULL== (Tool[i]=(Toolbox*)malloc(sizeof(Toolbox)*pars.slices))){
			perror ("Memory Error");
		}
		
		
		
		if (NULL==(Tool[i]->mand=(mandelPars*)malloc(sizeof(mandelPars)))){
			
			perror ("Memory error");
		}
		Tool[i]->mand=&pars;
		
		
		
		
		if (NULL==(Tool[i]->res=(int*)malloc(sizeof(int)))){
			perror ("Memory error");
		}
		Tool[i]->res= res;
		Tool[i]->count=i;
		Tool[i]->rd=-1;	
		
		
		
		
		
		if (NULL== (thrP=(pthread_t*)malloc(sizeof(pthread_t)*pars.slices))){
			perror ("Memory Error");
		}
		thrCheck = pthread_create( &thrP[i], NULL,calcMandel , (void *)Tool[i]);
		if(thrCheck)
		{
			fprintf(stderr,"Error - pthread_create() return code: %d\n",thrCheck);
			exit(EXIT_FAILURE);
		}
		
	}
	
	
	while (1) {
		
		clearWin();
		
		printf("computing for level %d:\n",level);
		printf("reBeg=%Lf reEnd=%Lf reStep=%Lf\n",pars.reBeg,pars.reEnd,reStep);
		printf("imBeg=%Lf imEnd=%Lf imStep=%Lf\n",pars.imBeg,pars.imEnd,imStep);
		printf("maxIterations=%d\n",pars.maxIterations);
		
		
		for (i=0; i<pars.slices; i++) { 
			Tool[i]->level=&level;
			Tool[i]->rd=0;
			
		}
		
		
		
		/* busywait (and draw results) until all slices done */
		
		k=0;
		while (k!=pars.slices) {
			for (i=0; i<pars.slices; i++) {
				
				while (Tool[i]->rd!=1){
					if (0!=(check= sched_yield())){
						perror ("Thread");
					}
					
				}
					
					for (y=i*(pars.imPixels/pars.slices); y<(i+1)*(pars.imPixels/pars.slices); y++) {
						
						for (x=0; x<pars.rePixels; x++) {
							setColor(pickColor(res[y*pars.rePixels+x],pars.maxIterations));
							drawPoint(x,y);
							
						}
					}
					
					k++; Tool[i]->rd=2;
			}
		}
		
		
		/* get next focus/zoom point */
		
		
		
		getMouseCoords(&x,&y);
		xoff = WinW/2 - x;
		yoff = WinH/2 - (WinH-y);
		
		/* adjust focus */
		
		pars.reBeg = pars.reBeg - xoff*reStep;
		pars.reEnd = pars.reBeg + reStep*pars.rePixels;
		pars.imBeg = pars.imBeg - yoff*reStep;
		pars.imEnd = pars.imBeg + reStep*pars.imPixels;
		
		/* zoom in */
		
		reStep = reStep*ZoomStepFactor; 
		imStep = imStep*ZoomStepFactor;
		pars.reBeg = pars.reBeg + (pars.reEnd-pars.reBeg)/2 - reStep*pars.rePixels/2;
		pars.reEnd = pars.reBeg+reStep*pars.rePixels;
		pars.imBeg = pars.imBeg + (pars.imEnd-pars.imBeg)/2 - imStep*pars.imPixels/2;
		pars.imEnd = pars.imBeg+imStep*pars.imPixels;
		pars.maxIterations = pars.maxIterations*ZoomIterationFactor;
		
		level++;
		
	} 
	
	/* never reach this point; for cosmetic reasons */
	
	free(res);
	
	
	closeWin();
	closeDisplay();
	
}
Пример #8
0
static PyObject *
setRootResource(PyObject *s, PyObject *args)
{
    Display *dpy;
    Window  root;
    Resource **resources, **p;
    char *key, *val, *rstring;
    int fnd, nrec;

    if (!PyArg_ParseTuple(args, "ss", &key, &val)) {
	return NULL;
    }

    if (openDisplay(&dpy, &root) < 0) {
	PyErr_SetString(PyExc_SystemError, "Could not open display.");
	return NULL;
    }

    resources = getCurrentResources(dpy);
    fnd = 0;
    nrec = 0;
    if (resources) {
	p = resources;
	while (*p) {
	    if (!strcmp(key, (*p)->key)) {
		free((*p)->val);
		(*p)->val = strdup(val);
		fnd = 1;
		break;
	    }

	    p++;
	}

	p = resources;
	while (*p) {
	    nrec++;
	    p++;
	}
    }

    if (!fnd) {
	Resource *newrec;

	newrec = (Resource *) malloc(sizeof(Resource));
	newrec->key = strdup(key);
	newrec->val = strdup(val);

	if (nrec > 0)
	    resources = (Resource **) realloc(resources, (nrec+2) * sizeof(Resource *));
	else
	    resources = (Resource **) malloc(2*sizeof(Resource *));

	resources[nrec] = newrec;
	resources[nrec+1] = NULL;
    }

    rstring = NULL;
    p = resources;
    while (*p) {
	int len;
	char *tmpstr;

	len = strlen((*p)->key) + strlen((*p)->val) + 3;
	tmpstr = (char *) malloc(len*sizeof(char));
	strcpy(tmpstr, (*p)->key);
	strcat(tmpstr, ":");
	strcat(tmpstr, (*p)->val);
	strcat(tmpstr, "\n");

	if (rstring) {
	    rstring = (char *)realloc(rstring, (strlen(rstring)+len+1)*sizeof(char));
	    strcat(rstring, tmpstr);
	} else {
	    rstring = tmpstr;
	}

	p++;
    }

    XChangeProperty(dpy, root, XA_RESOURCE_MANAGER, XA_STRING, 
		    8, PropModeReplace, (unsigned char *)rstring,
		    strlen(rstring));

    free(rstring);
    freeResources(resources);

    closeDisplay(dpy);

    Py_INCREF(Py_None);
    return Py_None;
}
JNIEXPORT jlong JNICALL Java_org_lwjgl_opengl_LinuxDisplay_openDisplay(JNIEnv *env, jclass clazz) {
	return openDisplay(env);
}
Пример #10
0
int main(int argc, char *argv[]) {
  mandel_Pars pars;
  int i, j, x, y, k, nofslices, level, thread_status;
  int xoff,yoff;
  long double reEnd,imEnd,reCenter,imCenter;
  pthread_t *thread_workers;

  printf("\n");
  printf("This program starts by drawing the default Mandelbrot region\n");
  printf("When done, you can click with the mouse on an area of interest\n");
  printf("and the program will automatically zoom around this point\n");
  printf("\n");
  printf("Press enter to continue\n");
  getchar();

  pars.reSteps = WinW; /* never changes */
  pars.imSteps = WinH; /* never changes */

  /* default mandelbrot region */

  pars.reBeg = (long double) -2.0;
  reEnd = (long double) 1.0;
  pars.imBeg = (long double) -1.5;
  imEnd = (long double) 1.5;
  pars.reInc = (reEnd - pars.reBeg) / pars.reSteps;
  pars.imInc = (imEnd - pars.imBeg) / pars.imSteps;

  printf("enter max iterations (50): ");
  scanf("%d",&maxIterations);
  printf("enter no of slices: ");
  scanf("%d",&nofslices);

  /* adjust slices to divide win height */

  while (WinH % nofslices != 0) { nofslices++;}

  /* allocate slice parameter and result arrays */

  slices = (mandel_Pars *) malloc(sizeof(mandel_Pars)*nofslices);
  res = (int *) malloc(sizeof(int)*pars.reSteps*pars.imSteps);


  //workers init
  thread_workers = (pthread_t*)malloc(sizeof(pthread_t)*nofslices);
  work_status=(int *)malloc(sizeof(int)*nofslices);
  for(i=0;i<nofslices;i++)work_status[i]=-1;
  for(i=0;i<nofslices;i++){
      thread_status=pthread_create(&thread_workers[i], NULL, workers, (void*)(intptr_t)i);
      if(thread_status){
          perror("Fail create thread\n");
          exit(1);
      }
  }

  /* open window for drawing results */

  openDisplay();
  openWin(argv[0], WinW, WinH);

  level = 1;

  while (1) {

    clearWin();

    mandel_Slice(&pars,nofslices,slices);

    for(i=0;i<nofslices;i++)work_status[i]=0;

    i=0;
    y=0;
    while(i<nofslices){

        for(k=0;work_status[k]!=1;k++)if((k+1)==nofslices)k=-1;

        for(i++, work_status[k]=2, j=0;j<slices[k].imSteps;j++,y++){
            for(x=0;x<slices[k].reSteps;x++){
                setColor(pickColor(res[y*slices[k].reSteps+x],maxIterations));
                drawPoint(x, y);
            }
        }

        printf("thread no. %d finish draw\n", k);

    }

    /* get next focus/zoom point */

    getMouseCoords(&x,&y);
    xoff = x;
    yoff = WinH-y;

    /* adjust region and zoom factor  */

    reCenter = pars.reBeg + xoff*pars.reInc;
    imCenter = pars.imBeg + yoff*pars.imInc;
    pars.reInc = pars.reInc*ZoomStepFactor;
    pars.imInc = pars.imInc*ZoomStepFactor;
    pars.reBeg = reCenter - (WinW/2)*pars.reInc;
    pars.imBeg = imCenter - (WinH/2)*pars.imInc;

    maxIterations = maxIterations*ZoomIterationFactor;
    level++;

  }

  /* never reach this point; for cosmetic reasons */

  free(work_status);
  free(thread_workers);
  free(slices);
  free(res);

  closeWin();
  closeDisplay();

}
Пример #11
0
static void display_winOpen(void)
{
  openDisplay();
}
Пример #12
0
static void display_winOpen(int argc, char *dropFiles[])
{
  openDisplay();
}