Beispiel #1
0
bool WaterObject::onAdd()
{
   if ( !Parent::onAdd() )
      return false;

   Con::NotifyDelegate clbk( this, &WaterObject::_onDisableTrueRelfections );   
   Con::addVariableNotify( "$pref::Water::disableTrueReflections", clbk );

   if ( isClientObject() )
   {
      GFXStateBlockDesc desc;
      desc.blendDefined = true;
      desc.blendEnable = true;
      desc.blendSrc = GFXBlendSrcAlpha;
      desc.blendDest = GFXBlendInvSrcAlpha;
      desc.zDefined = true;
      desc.zEnable = false;
      desc.cullDefined = true;
      desc.cullMode = GFXCullNone;
      mUnderwaterSB = GFX->createStateBlock( desc );

      initTextures();
      
      if ( mFullReflect && !smDisableTrueReflections )
         mPlaneReflector.registerReflector( this, &mReflectorDesc );
   }

   return true;
}
Beispiel #2
0
void WaterObject::onRemove()
{
   Con::NotifyDelegate clbk( this, &WaterObject::_onDisableTrueRelfections ); 
   Con::removeVariableNotify( "$pref::Water::disableTrueReflections", clbk );

   if ( isClientObject() )
   {
      mPlaneReflector.unregisterReflector();
      cleanupMaterials();
   }

   Parent::onRemove();
}
static void alarm_event_handler(struct device *dev, u32_t id)
{
	const struct counter_nrfx_config *config = get_nrfx_config(dev);
	counter_alarm_callback_t clbk = config->ch_data[id].callback;
	u32_t cc_val;

	if (!clbk) {
		return;
	}

	cc_val = nrfx_timer_capture_get(&config->timer, ID_TO_CC(id));
	_disable(dev, id);
	clbk(dev, id, cc_val, config->ch_data[id].user_data);
}
Beispiel #4
0
bool GUIlistPopup::ProcessChildren(GUI_MOUSE_EVENT _event, int _x, int _y)
{
	if (isvisible)
	{
		//see if any children have been clicked
		int eventid = -1;
		for (UINT i = rootelements.size(); i > 0; --i)
		{
			eventid = rootelements[i - 1]->ProcessMouse(_event, _x, _y);
			if (eventid != -1) break;
		}

		if (eventid != -1)
		{
			if (eventid == LISTPOPUPOK)
			{
				//invoke the callback function and tell it what item was selected
				if (clbk(list->GetSelected(), usrdata))
				{
					//if the callback returns true, close the popup
					close();
				}
			}
			else if (eventid == LISTPOPUPCANCEL)
			{
				//invoke the callback function and tell it no item was selected
				clbk(-1, usrdata);
				//close the popup regardless of what the callback returned
				close();
			}
		}
		//something has processed an event, and even if we don't care about it here, we still need a redraw
		return true;
	}

	return false;
}
Beispiel #5
0
void GFXGLDevice::initGLState()
{  
   // We don't currently need to sync device state with a known good place because we are
   // going to set everything in GFXGLStateBlock, but if we change our GFXGLStateBlock strategy, this may
   // need to happen.
   
   // Deal with the card profiler here when we know we have a valid context.
   mCardProfiler = new GFXGLCardProfiler();
   mCardProfiler->init(); 
   glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, (GLint*)&mMaxShaderTextures);
   // JTH: Needs removed, ffp
   //glGetIntegerv(GL_MAX_TEXTURE_UNITS, (GLint*)&mMaxFFTextures);
   glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, (GLint*)&mMaxTRColors);
   mMaxTRColors = getMin( mMaxTRColors, (U32)(GFXTextureTarget::MaxRenderSlotId-1) );
   
   glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
   
   // [JTH 5/6/2016] GLSL 1.50 is really SM 4.0
   // Setting mPixelShaderVersion to 3.0 will allow Advanced Lighting to run.   
   mPixelShaderVersion = 3.0;

	// Set capability extensions.
   mCapabilities.anisotropicFiltering = mCardProfiler->queryProfile("GL_EXT_texture_filter_anisotropic");
   mCapabilities.bufferStorage = mCardProfiler->queryProfile("GL_ARB_buffer_storage");
   mCapabilities.shaderModel5 = mCardProfiler->queryProfile("GL_ARB_gpu_shader5");
   mCapabilities.textureStorage = mCardProfiler->queryProfile("GL_ARB_texture_storage");
   mCapabilities.samplerObjects = mCardProfiler->queryProfile("GL_ARB_sampler_objects");
   mCapabilities.copyImage = mCardProfiler->queryProfile("GL_ARB_copy_image");
   mCapabilities.vertexAttributeBinding = mCardProfiler->queryProfile("GL_ARB_vertex_attrib_binding");

   String vendorStr = (const char*)glGetString( GL_VENDOR );
   if( vendorStr.find("NVIDIA", 0, String::NoCase | String::Left) != String::NPos)
      mUseGlMap = false;
   
   // Workaround for all Mac's, has a problem using glMap* with volatile buffers
#ifdef TORQUE_OS_MAC
   mUseGlMap = false;
#endif

#if TORQUE_DEBUG
   if( gglHasExtension(ARB_debug_output) )
   {
      glEnable(GL_DEBUG_OUTPUT);
      glDebugMessageCallbackARB(glDebugCallback, NULL);
      glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
      GLuint unusedIds = 0;
      glDebugMessageControlARB(GL_DONT_CARE,
            GL_DONT_CARE,
            GL_DONT_CARE,
            0,
            &unusedIds,
            GL_TRUE);
   }
   else if(gglHasExtension(AMD_debug_output))
   {
      glEnable(GL_DEBUG_OUTPUT);
      glDebugMessageCallbackAMD(glAmdDebugCallback, NULL);      
      //glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
      GLuint unusedIds = 0;
      glDebugMessageEnableAMD(GL_DONT_CARE, GL_DONT_CARE, 0,&unusedIds, GL_TRUE);
   }
#endif

   PlatformGL::setVSync(smDisableVSync ? 0 : 1);

   //install vsync callback
   Con::NotifyDelegate clbk(this, &GFXGLDevice::vsyncCallback);
   Con::addVariableNotify("$pref::Video::disableVerticalSync", clbk);

   //OpenGL 3 need a binded VAO for render
   GLuint vao;
   glGenVertexArrays(1, &vao);
   glBindVertexArray(vao);
}