Exemple #1
0
    void WindowImpl::handleSurfaceCreation()
    {
        const EGLint surfaceAttribs[] =
        {
            JOP_CHECK_EGL_EXTENSION(EGL_KHR_gl_colorspace) ? EGL_VG_COLORSPACE : EGL_NONE, EGL_VG_COLORSPACE_sRGB,
            EGL_NONE
        };

        auto state = detail::ActivityState::get();
        auto win = state->window;

        if (win && win->m_surface == EGL_NO_SURFACE)
        {
            win->m_surface = eglCheck(eglCreateWindowSurface(getDisplay(), win->m_config, state->nativeWindow, surfaceAttribs));
            JOP_ASSERT(win->m_surface != EGL_NO_SURFACE, "Failed to create window surface!");

            if (win->m_context != EGL_NO_CONTEXT)
            {
                EGLBoolean success = eglCheck(eglMakeCurrent(getDisplay(), win->m_surface, win->m_surface, win->m_context));
                JOP_ASSERT(success == EGL_TRUE, "Failed to make context current!");
            }

            if (win->m_fullScreen)
                goFullscreen();

            updateSize(win->m_size, win->m_surface);
        }
    }
Exemple #2
0
//------------------------------------------------------------------------------
// pixelsToLatLon() - determine our lat lon position from a pixel X/Y
//------------------------------------------------------------------------------
void MapPage::pixelsToLatLon(const int x, const int y, double &lat, double &lon)
{
   double xpos = x;
   double ypos = y;

   // convert pixels position from top left to movement from center, so we
   // can base our cals from the center.
   if (getDisplay() != nullptr) {
      double myLat = 0, myLon = 0;
      double dLat = 0, dLon = 0;
      GLsizei vpW = 0, vpH = 0;
      getDisplay()->getViewportSize(&vpW, &vpH);
      GLdouble tl = 0, tr = 0, tb = 0, tt = 0, tn = 0, tf = 0;
      getDisplay()->getOrtho(tl, tr, tb, tt, tn, tf);

      // determine the middle of our viewing screen
      const double startX = (vpW / 2.0);
      const double startY = (vpH / 2.0);

      // find the position from our screen center (in pixels)
      xpos -= startX;
      ypos = startY - ypos;

      // we have to find our units per pixel
      const double unitsPerPixE = ((tr * 2) / vpW);
      const double unitsPerPixN = ((tt * 2) / vpH);

      // now from that we can determine our position in inches
      xpos *= unitsPerPixE;
      ypos *= unitsPerPixN;

      if (!isCentered) ypos -= displacement;

      // ok, now we can find our xpos and ypos in nautical miles
      xpos /= nm2Screen;
      ypos /= nm2Screen;

      if (!getNorthUp()) {
         LCreal acX = 0;
         LCreal acY = 0;
         earth2Aircraft( static_cast<LCreal>(xpos), static_cast<LCreal>(ypos), &acX, &acY);
         xpos = acX;
         ypos = acY;
      }

      // reference lat to figure off of (if centered())
      myLat = referenceLat;
      myLon = referenceLon;

      // now convert to degree from our reference lat/lon
      dLat = ypos / 60.0;
      dLon = xpos / (60.0 * cosineLatReference);

      myLat += dLat;
      myLon += dLon;

      lat = myLat;
      lon = myLon;
   }
}
/*
** ===================================================================
**     Method      :  BoxPri_Constructor 
**     Description :  Constructor del Box
** ===================================================================
*/
BoxPrincipal::BoxPrincipal(struct ConstructorBoxPrincipal * _constructor):Box(),timerPri(TIME_BETWEEN_PARS)
{
  msj_index=0; 
  msj_index_sup=0; 
  constructor=_constructor;
  constructor->flash->habilitar();  
  constructor->snsr1->print(getDisplay(0));  
  getDisplay(1).write("MEdicion");
}
Exemple #4
0
void XWindow::terminate(void)
{
    Inherited::doTerminate();

    if(getDisplay() != NULL && getContext() != NULL)
    {
        this->doDeactivate();
        
        glXDestroyContext(getDisplay(), getContext());
    }
}
//------------------------------------------------------------------------------
// getSymbol() - gets a symbol based on the pixel x,y (from center) position specified
//------------------------------------------------------------------------------
SlSymbol* SymbolLoader::getSymbol(const int xPixel, const int yPixel)
{
    SlSymbol* sym = 0;
    if (getDisplay() != 0) {

        // we have to do a little math and figure our pixel to inches value
        GLdouble l = 0, r = 0, b = 0, t = 0, n = 0, f = 0;
        GLsizei w = 0, h = 0;
        getDisplay()->getOrtho(l, r, b, t, n, f);
        getDisplay()->getViewportSize(&w, &h);
        double inchPerPixWidth = (r * 2) / w;
        double inchPerPixHeight = (t * 2) / h;

        // we assume our xPixel and yPixel are from the center
        double inchX = xPixel * inchPerPixWidth;
        double inchY = yPixel * inchPerPixHeight;

        // index of the closest symbol
        int id = -1;

        // our "snapping" cursor distance is basically 1 pixel in the y direction
        double cursorDist = 1 * inchPerPixHeight;

        double symX = 0;
        double symY = 0;
        double distX = 0;
        double distY = 0;
        double dist = 0;
        double lastDist = 500000;

        // now search our symbols for the closest symbol
        for (int i = 0; i < MAX_SYMBOLS; i++) {
            if (symbols[i] != 0) {
                symX = symbols[i]->getScreenXPos();
                symY = symbols[i]->getScreenYPos();
                distX = symX - inchX;
                distY = symY - inchY;
                dist = (distX * distX) + (distY * distY);
                if (dist < cursorDist) {
                    if (dist < lastDist) {
                        lastDist = dist;
                        id = i;
                    }
                }
            }
        }

        // If we found one then get a pointer to the symbol
        if (id != -1) sym = symbols[id];

    }
    return sym;
}
/*on1ms()*/
void FrenteCustomSD::on1ms(){
  /* refresco todo el frente cada 1 msg*barridos */
  
  
  if(barrido==DIGITOS*CANTIDAD_DISPLAYS/2){    //llegue al final?
    encenderLeds(leds);
    barrido=0;
    return;
  }
  
  apagarLeds();
  
  DisplaySD * display1 = getDisplaySD(barrido/DIGITOS);
  Display * display2 = getDisplay(barrido/DIGITOS);
    
  /* Tengo que encender un digito o checkear una tecla*/
  /*Corrimiento por scrolling*/
  if (scrollTimer.getFlag()){
    bool scrolling=FALSE;
    for(int i=0;i<CANTIDAD_DISPLAYS/2;i++){
      DisplaySD * sd = getDisplaySD(i);
      Display * d = getDisplay(i);
      if (sd->isScrolling())
      {
    	    sd->incrementarCorrimiento();
          scrolling=TRUE;  		    
      }
      
      if (d->isScrolling())
      {
    	    d->incrementarCorrimiento();
          scrolling=TRUE;  		    
      }
    }
    if(scrolling){
      scrollTimer.reset();
      scrollTimer.setTime(TIME_SCROLL);  
    }
  }
  
  /* el escaneo del teclado se hace luego del envio de la señal de ON
   del digito para que el pin PULL se encuentre estable */  
  
  seleccionarDigito(barrido);
  actualizarTeclas();
  display1->apagar();
  display2->apagar();
  
  display1->imprimirDigito(barrido%DIGITOS);
  display2->imprimirDigito(barrido%DIGITOS);
  barrido++;  //actualizo el paso de barrido
}
static jboolean jni_eglGetConfigs(JNIEnv *_env, jobject _this, jobject display,
        jobjectArray configs, jint config_size, jintArray num_config) {
    if (display == NULL || (configs != NULL && _env->GetArrayLength(configs) < config_size)
        || (num_config != NULL && _env->GetArrayLength(num_config) < 1)) {
        jniThrowException(_env, "java/lang/IllegalArgumentException", NULL);
        return JNI_FALSE;
    }
    EGLDisplay dpy = getDisplay(_env, display);
    jboolean success = JNI_FALSE;
    if (configs == NULL) {
        config_size = 0;
    }
    EGLConfig nativeConfigs[config_size];
    int num;
    success = eglGetConfigs(dpy, configs ? nativeConfigs : 0, config_size, &num);
    if (num_config != NULL) {
        _env->SetIntArrayRegion(num_config, 0, 1, (jint*) &num);
    }
    if (success && configs) {
        for (int i=0 ; i<num ; i++) {
            jobject obj = _env->NewObject(gConfig_class, gConfig_ctorID, (jint)nativeConfigs[i]);
            _env->SetObjectArrayElement(configs, i, obj);
        }
    }
    return success;
}
static jint jni_eglCreateWindowSurfaceTexture(JNIEnv *_env, jobject _this, jobject display,
        jobject config, jobject native_window, jintArray attrib_list) {
    if (display == NULL || config == NULL
        || !validAttribList(_env, attrib_list)) {
        jniThrowException(_env, "java/lang/IllegalArgumentException", NULL);
        return JNI_FALSE;
    }
    EGLDisplay dpy = getDisplay(_env, display);
    EGLContext cnf = getConfig(_env, config);
    sp<ANativeWindow> window;
    if (native_window == 0) {
not_valid_surface:
        jniThrowException(_env, "java/lang/IllegalArgumentException",
                "Make sure the SurfaceTexture is valid");
        return 0;
    }
    
    sp<SurfaceTexture> surfaceTexture(SurfaceTexture_getSurfaceTexture(_env, native_window));

    window = new SurfaceTextureClient(surfaceTexture);
    if (window == NULL)
        goto not_valid_surface;

    jint* base = beginNativeAttribList(_env, attrib_list);
    EGLSurface sur = eglCreateWindowSurface(dpy, cnf, window.get(), base);
    endNativeAttributeList(_env, attrib_list, base);
    return (jint)sur;
}
Exemple #9
0
// -------------------------------------------------------------------------------------------------------
// drawTexture() - Draws a tile at a specific position.
// -------------------------------------------------------------------------------------------------------
void MapDrawer::drawTexture(const int row, const int column, const int idx)
{
    if (pagers[idx] != 0 && myMap != 0 && getDisplay() != 0) {
        TextureTable& tbl = pagers[idx]->getTable();    
        BasicGL::Texture* newTex = dynamic_cast<BasicGL::Texture*>(tbl.getTexture(row, column));
        if (newTex != 0) {
            // Bind our texture and set up our modulation
            glBindTexture(GL_TEXTURE_2D, newTex->getTexture());
            glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);


            LCreal transX = (LCreal) column * pixPerTile * scalingEast[idx];
            LCreal transY = (LCreal) -row * pixPerTile * scalingNorth[idx];
            glPushMatrix();
                glTranslatef(GLfloat(transX), GLfloat(transY), 0.0f);
                glBegin(GL_POLYGON);
                    glTexCoord2f(0.0f, 0.0f); lcVertex2(0.0f, -pixPerTile * scalingNorth[idx]);
                    glTexCoord2f(1.0f, 0.0f); lcVertex2(pixPerTile * scalingEast[idx], -pixPerTile * scalingNorth[idx]);
                    glTexCoord2f(1.0f, 1.0f); lcVertex2(pixPerTile * scalingEast[idx], 0.0f);
                    glTexCoord2f(0.0f, 1.0f); lcVertex2(0.0f, 0.0f);
                glEnd();
            glPopMatrix();
        }
    }    
}
Exemple #10
0
// -----------------------------------------------------------------
// Name : setRetractible
// -----------------------------------------------------------------
void guiFrame::setRetractible(u8 uBorder)
{
    m_uRetractBorder = uBorder;
    m_fRetractTimer = 0;
    m_iRetractState = 2;  // shown
    m_bSticked = false;
    FREE(m_pStickGeo);
    FREE(m_pStickedGeo);
    if (uBorder != 0)
    {
        QuadData quad(0, 15, 0, 15, "stick", getDisplay());
        m_pStickGeo = new GeometryQuads(&quad, VB_Static);
        QuadData quad2(0, 15, 0, 15, "sticked", getDisplay());
        m_pStickedGeo = new GeometryQuads(&quad2, VB_Static);
    }
}
static jint jni_eglCreateWindowSurface(JNIEnv *_env, jobject _this, jobject display,
        jobject config, jobject native_window, jintArray attrib_list) {
    if (display == NULL || config == NULL
        || !validAttribList(_env, attrib_list)) {
        jniThrowException(_env, "java/lang/IllegalArgumentException", NULL);
        return JNI_FALSE;
    }
    EGLDisplay dpy = getDisplay(_env, display);
    EGLContext cnf = getConfig(_env, config);
    sp<ANativeWindow> window;
    if (native_window == NULL) {
not_valid_surface:
        jniThrowException(_env, "java/lang/IllegalArgumentException",
                "Make sure the SurfaceView or associated SurfaceHolder has a valid Surface");
        return 0;
    }

    window = android_view_Surface_getNativeWindow(_env, native_window);
    if (window == NULL)
        goto not_valid_surface;

    jint* base = beginNativeAttribList(_env, attrib_list);
    EGLSurface sur = eglCreateWindowSurface(dpy, cnf, window.get(), base);
    endNativeAttributeList(_env, attrib_list, base);
    return (jint)sur;
}
Exemple #12
0
void XAbstractGui::update_block(int block_number)
{
    Display     *dpy;
    Window       win;
    XImage      *img;

    if (!memory.has_changed(block_number))
    {
        return;
    }
    memory.reset_changed(block_number);

    dpy = getDisplay();
    win = getWindow();

    Byte const *src =
        memory.get_video_ram(vico1.get_value(), block_number);

    img = image[pixelSizeX - 1][pixelSizeY - 1];

    if (memory.is_video_bank_valid(vico1.get_value()))
    {
        CopyToZPixmap((Byte *)img->data, src, depth);

        auto divided_block = get_divided_block();
        if (divided_block >= 0 && (divided_block == block_number))
        {
            // first half display on the bottom of the window
            XPutImage(dpy, win, e2gc,
                      img, 0, 0, 0, (WINDOWHEIGHT -
                                (vico2.get_value() % BLOCKHEIGHT)) * pixelSizeY,
                      BLOCKWIDTH * pixelSizeX,
                      (vico2.get_value() % BLOCKHEIGHT) * pixelSizeY);
            // second half display on the top of window
            XPutImage(dpy, win, e2gc,
                      img, 0, (vico2.get_value() % YBLOCKS) * pixelSizeY,
                      0, 0, BLOCKWIDTH * pixelSizeX,
                      (BLOCKHEIGHT - (vico2.get_value() % BLOCKHEIGHT)) *
                      pixelSizeY);
        }
        else
        {
            XPutImage(dpy, win, e2gc,
                      img, 0, 0, 0,
                      ((block_number * BLOCKHEIGHT + WINDOWHEIGHT -
                        vico2.get_value()) % WINDOWHEIGHT) * pixelSizeY,
                      BLOCKWIDTH * pixelSizeX, BLOCKHEIGHT * pixelSizeY);
        }
    }
    else
    {
        // Invalid video bank selected: Always display an empty screen.
        CopyToZPixmap((Byte *)img->data, nullptr, depth);

        XPutImage(dpy, win, e2gc,
                  image[pixelSizeX - 1][pixelSizeY - 1], 0, 0, 0,
                  block_number * BLOCKHEIGHT * pixelSizeX,
                  BLOCKWIDTH * pixelSizeX, BLOCKHEIGHT * pixelSizeY);
    }
}
void EGLWindow::deactivate(void)
{
    eglMakeCurrent(getDisplay(), 
                   EGL_NO_SURFACE, 
                   EGL_NO_SURFACE, 
                   EGL_NO_CONTEXT);
}
static jint jni_eglCreateWindowSurface(JNIEnv *_env, jobject _this, jobject display,
        jobject config, jobject native_window, jintArray attrib_list) {
    if (display == NULL || config == NULL
        || !validAttribList(_env, attrib_list)) {
        doThrow(_env, "java/lang/IllegalArgumentException");
        return JNI_FALSE;
    }
    EGLDisplay dpy = getDisplay(_env, display);
    EGLContext cnf = getConfig(_env, config);
    Surface* window = 0;
    if (native_window == NULL) {
not_valid_surface:
        doThrow(_env, "java/lang/IllegalArgumentException",
                "Make sure the SurfaceView or associated SurfaceHolder has a valid Surface");
        return 0;
    }
    window = (Surface*)_env->GetIntField(native_window, gSurface_SurfaceFieldID);
    if (window == NULL)
        goto not_valid_surface;

    jint* base = beginNativeAttribList(_env, attrib_list);
    EGLSurface sur = eglCreateWindowSurface(dpy, cnf, window, base);
    endNativeAttributeList(_env, attrib_list, base);
    return (jint)sur;
}
static jboolean jni_eglChooseConfig(JNIEnv *_env, jobject _this, jobject display,
        jintArray attrib_list, jobjectArray configs, jint config_size, jintArray num_config) {
    if (display == NULL
        || !validAttribList(_env, attrib_list)
        || (configs != NULL && _env->GetArrayLength(configs) < config_size)
        || (num_config != NULL && _env->GetArrayLength(num_config) < 1)) {
        doThrow(_env, "java/lang/IllegalArgumentException");
        return JNI_FALSE;
    }
    EGLDisplay dpy = getDisplay(_env, display);
    jboolean success = JNI_FALSE;

    if (configs == NULL) {
        config_size = 0;
    }
    EGLConfig nativeConfigs[config_size];

    int num = 0;
    jint* attrib_base = beginNativeAttribList(_env, attrib_list);
    success = eglChooseConfig(dpy, attrib_base, configs ? nativeConfigs : 0, config_size, &num);
    endNativeAttributeList(_env, attrib_list, attrib_base);

    if (num_config != NULL) {
        _env->SetIntArrayRegion(num_config, 0, 1, (jint*) &num);
    }

    if (success && configs!=NULL) {
        for (int i=0 ; i<num ; i++) {
            jobject obj = _env->NewObject(gConfig_class, gConfig_ctorID, (jint)nativeConfigs[i]);
            _env->SetObjectArrayElement(configs, i, obj);
        }
    }
    return success;
}
Exemple #16
0
bool EGLSurfaceX11::swapBuffers()
{
	xcb_dri2_swap_buffers_cookie_t cookie;
	xcb_dri2_swap_buffers_reply_t *reply;
	int long swap_count = -1;

	const EGLDisplayX11 *pDisp = static_cast<const EGLDisplayX11 *>(&getDisplay());
	xcb_connection_t *c = pDisp->getXCBConnection();

	bool ret = pDisp->getEGLBridge()->swapBuffers();

	cookie = ::xcb_dri2_swap_buffers_unchecked(c, mXDrawable, 0, 0, 0, 0, 0, 0);
	reply  = ::xcb_dri2_swap_buffers_reply(c, cookie, NULL);

	if(reply)
	{
		swap_count = (((int long)reply->swap_hi) << 32) | reply->swap_lo;
		free(reply);
	}

	if(mCurrentBO)
	{
		::drm_intel_bo_unreference(mCurrentBO);
		mCurrentBO = NULL;
	}

	return ret && swap_count != -1;
}
bool ApiCase::getConfig (EGLConfig* config,const eglu::FilterList& filters)
{
	for (std::vector<eglu::ConfigInfo>::const_iterator cfgIter = m_eglTestCtx.getConfigs().begin(); cfgIter != m_eglTestCtx.getConfigs().end(); ++cfgIter)
	{
		if (filters.match(*cfgIter))
		{
			EGLint		numCfgs;
			EGLBoolean	ok;
			EGLint		attribs[] =
			{
				EGL_CONFIG_ID,			cfgIter->configId,
				EGL_TRANSPARENT_TYPE,	EGL_DONT_CARE,
				EGL_COLOR_BUFFER_TYPE,	EGL_DONT_CARE,
				EGL_RENDERABLE_TYPE,	EGL_DONT_CARE,
				EGL_SURFACE_TYPE,		EGL_DONT_CARE,
				EGL_NONE
			};

			ok = eglChooseConfig(getDisplay(), &attribs[0], config, 1, &numCfgs);
			expectTrue(ok);

			if (ok && numCfgs >= 1)
				return true;
			else
			{
				m_testCtx.getLog() << TestLog::Message << "// ERROR: expected at least one config with id " << cfgIter->configId << TestLog::EndMessage;
				if (m_testCtx.getTestResult() == QP_TEST_RESULT_PASS)
					m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "Got invalid value");
				return 0;
			}
		}
	}

	return DE_NULL;
}
static jlong jni_eglCreateWindowSurfaceTexture(JNIEnv *_env, jobject _this, jobject display,
        jobject config, jobject native_window, jintArray attrib_list) {
    if (display == NULL || config == NULL
        || !validAttribList(_env, attrib_list)) {
        jniThrowException(_env, "java/lang/IllegalArgumentException", NULL);
        return 0;
    }
    EGLDisplay dpy = getDisplay(_env, display);
    EGLContext cnf = getConfig(_env, config);
    sp<ANativeWindow> window;
    if (native_window == 0) {
not_valid_surface:
        jniThrowException(_env, "java/lang/IllegalArgumentException",
                "Make sure the SurfaceTexture is valid");
        return 0;
    }

    sp<IGraphicBufferProducer> producer(SurfaceTexture_getProducer(_env, native_window));
    window = new Surface(producer, true);
    if (window == NULL)
        goto not_valid_surface;

    jint* base = beginNativeAttribList(_env, attrib_list);
    EGLSurface sur = eglCreateWindowSurface(dpy, cnf, window.get(), base);
    endNativeAttributeList(_env, attrib_list, base);
    return reinterpret_cast<jlong>(sur);
}
void StreamingIndexBuffer::reserveSpace(UINT requiredSpace, GLenum type)
{
    if (requiredSpace > mBufferSize)
    {
        if (mIndexBuffer)
        {
            mIndexBuffer->Release();
            mIndexBuffer = NULL;
        }

        mBufferSize = std::max(requiredSpace, 2 * mBufferSize);

        D3DPOOL pool = getDisplay()->getBufferPool(D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY);
        HRESULT result = mDevice->CreateIndexBuffer(mBufferSize, D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, type == GL_UNSIGNED_INT ? D3DFMT_INDEX32 : D3DFMT_INDEX16, pool, &mIndexBuffer, NULL);
        mSerial = issueSerial();
    
        if (FAILED(result))
        {
            ERR("Out of memory allocating a vertex buffer of size %lu.", mBufferSize);
        }

        mWritePosition = 0;
    }
    else if (mWritePosition + requiredSpace > mBufferSize)   // Recycle
    {
        void *dummy;
        mIndexBuffer->Lock(0, 1, &dummy, D3DLOCK_DISCARD);
        mIndexBuffer->Unlock();

        mWritePosition = 0;
    }
}
Exemple #20
0
//------------------------------------------------------------------------------
// updateData --
//------------------------------------------------------------------------------
void Cursor::updateData(const LCreal dt)
{
   int ln = 0;
   int cp = 0;
   if (getDisplay()->focus() != 0) {
      setVisibility( getDisplay()->focus()->cursor(&ln,&cp) );
   }
   else {
      setVisibility(false);
   }

   if (isVisible()) {
      line(ln);
      column(cp);
      BaseClass::updateData(dt);
   }
}
bool NTScalar::attachDisplay(PVDisplay &pvDisplay) const
{
    PVStructurePtr dp = getDisplay();
    if (dp)
        return pvDisplay.attach(dp);
    else
        return false;
}
static jboolean jni_eglTerminate(JNIEnv *_env, jobject _this, jobject display) {
    if (display == NULL) {
        jniThrowException(_env, "java/lang/IllegalArgumentException", NULL);
        return JNI_FALSE;
    }
    EGLDisplay dpy = getDisplay(_env, display);
    return eglTerminate(dpy);
}
Exemple #23
0
//------------------------------------------------------------------------------
// onEntry() -- 
//------------------------------------------------------------------------------
bool Page::onEntry()
{
   // send our focus to our subpage, if we have one.
   if (subpage() != 0) {
      getDisplay()->focus( subpage() );
      subpage()->event(ON_ENTRY);
   }
   return true;
}
static jstring jni_eglQueryString(JNIEnv *_env, jobject _this, jobject display, jint name) {
    if (display == NULL) {
        jniThrowException(_env, "java/lang/IllegalArgumentException", NULL);
        return NULL;
    }
    EGLDisplay dpy = getDisplay(_env, display);
    const char* chars = eglQueryString(dpy, name);
    return _env->NewStringUTF(chars);
}
static jboolean jni_eglSwapBuffers(JNIEnv *_env, jobject _this, jobject display, jobject surface) {
    if (display == NULL || surface == NULL) {
        jniThrowException(_env, "java/lang/IllegalArgumentException", NULL);
        return JNI_FALSE;
    }
    EGLDisplay dpy = getDisplay(_env, display);
    EGLSurface sur = getSurface(_env, surface);
    return eglSwapBuffers(dpy, sur);
}
static jboolean jni_eglDestroyContext(JNIEnv *_env, jobject _this, jobject display, jobject context) {
    if (display == NULL || context == NULL) {
        jniThrowException(_env, "java/lang/IllegalArgumentException", NULL);
        return JNI_FALSE;
    }
    EGLDisplay dpy = getDisplay(_env, display);
    EGLContext ctx = getContext(_env, context);
    return eglDestroyContext(dpy, ctx);
}
egl_surface_t::egl_surface_t(egl_display_t* dpy, EGLConfig config,
                             EGLNativeWindowType win, EGLSurface surface,
                             egl_connection_t const* cnx) :
    egl_object_t(dpy), surface(surface), config(config), win(win), cnx(cnx)
{
    if (win) {
        getDisplay()->onWindowSurfaceCreated();
    }
}
Exemple #28
0
//------------------------------------------------------------------------------
// updateData() -- update non time-critical threads here
//------------------------------------------------------------------------------
void GhostHorizon::updateData(const LCreal dt)
{
    // Update our base class
    BaseClass::updateData(dt);

    // get our table to determine our min and max value
    LCreal maxPitch = 90;
    LCreal minPitch = -90;
    const Basic::Table1* table = getScalingTable();
    if (table != nullptr) {
        maxPitch = table->getMaxX();
        minPitch = table->getMinX();
    }
    LCreal value = getPreScaleInstValue();

    if (value <= minPitch/* || value >= pitchLim*/) {
        setVisibility(true);
        // scale our location value
        //location = -(location - margin);
        if (sColorName != nullptr) {
            BasicGL::Display* d = getDisplay();
            if (d != nullptr) {
                Basic::Color* c = d->getColor(sColorName->getString());
                if (c != nullptr) {
                    skyColor.set(c->red(), c->green(), c->blue());
                }
            }
        }
    }
    else if (value >= maxPitch) {
        setVisibility(true);
        //location = -(location + margin);
        if (gColorName != nullptr) {
            BasicGL::Display* d = getDisplay();
            if (d != nullptr) {
                Basic::Color* c = d->getColor(gColorName->getString());
                if (c != nullptr) {
                    groundColor.set(c->red(), c->green(), c->blue());
                }
            }
        }
    }
    else setVisibility(false);
}
Exemple #29
0
int main(int argc, char** argv)
{

  auto players = lionheart::getPlayers();
  std::shared_ptr<lionheart::Tournament> tournament;
  std::shared_ptr<lionheart::Player> keyPlayer;

  auto display = defaultDisplay();
  
  /*Parse command line*/
  if(argc >= 2)
  {
     //set display
    display = getDisplay(argv[1]);
  }
  if (argc >= 4) {
    // set player
    std::string playerName = "";
    for(int i=3;i<argc;++i)
    {
      playerName += argv[i];
      if(i!=argc-1)
      {
        playerName += " ";
      }
    }
    auto found = std::find_if(players.begin(), players.end(), [&](std::shared_ptr<lionheart::Player> p) -> bool
                                                              {
                                                                if (!p) return false;
                                                                return p->getBlazon().name == playerName;
                                                              });
    
    if(found != players.end())
    {
      keyPlayer = *found;
    }
    else
    {
      std::cerr << "Could not find player \"" << playerName << '"' << std::endl;
    }
  }
  if(argc >= 3)
  {
    //set type after setting player as it matters for some tournament types
    tournament = getTournament(argv[2],keyPlayer,players,display);
  }
  else
  {
    tournament = getTournament("",keyPlayer,players,display);
  }
  if(tournament)
  {
    std::cout << "Beginning tournament, please wait while paths are pre-computed" << std::endl;
    tournament->run();
  }
}
egl_surface_t::~egl_surface_t() {
    ANativeWindow* const window = win.get();
    if (window != NULL) {
        native_window_set_buffers_format(window, 0);
        if (native_window_api_disconnect(window, NATIVE_WINDOW_API_EGL)) {
            ALOGW("EGLNativeWindowType %p disconnect failed", window);
        }
        getDisplay()->onWindowSurfaceDestroyed();
    }
}