当前位置: 首页>>代码示例>>C++>>正文


C++ IShader类代码示例

本文整理汇总了C++中IShader的典型用法代码示例。如果您正苦于以下问题:C++ IShader类的具体用法?C++ IShader怎么用?C++ IShader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了IShader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: while

int ShaderModuleRepository::releaseProgram(IProgram *p)
{
    if(!p)
        return -1;
    ProgVec::iterator it = m_programs.begin();
    while(it != m_programs.end())
    {
        if((*it).p == p)
        {
            int a = p->getProgram(); //for debug
            int c = --(*it).refCnt;
#ifdef _DEBUG
                LOGD("Program %d (", (*it).p->getProgram() );
                IShader* pshd;
                for(int ii=0; pshd = (*it).p->getShader(ii); ii++)
                    LOGD("%s ", pshd->getName());
                LOGD(") ");
#endif
            if(c <= 0)
            {
#ifdef _DEBUG
                LOGD("no more used. REMOVING it from ShaderModuleRepository\n", a);
#endif
                m_programs.erase(it);
                return 0;
            } else
#ifdef _DEBUG
                LOGD("still used (%d). KEEPING it in ShaderModuleRepository\n", a, c);
#endif
                return c;
        }
        ++it;
    }
    return -1;
}
开发者ID:RylauChelmi,项目名称:nvFX,代码行数:35,代码来源:FxLib.cpp

示例2: construct_shaders

  void construct_shaders()
  {
    IShader* global_shader = shader_for_remap("*");

    unsigned int numSurfaces = m_model->GetNumSurfaces();
    m_shaders.reserve(numSurfaces);
    // now go through our surface and find our shaders, remap if needed
    for(unsigned int j = 0; j < numSurfaces; j++ )
    {
      const char* surfShaderName = m_model->GetShaderNameForSurface(j);
      IShader* shader = shader_for_remap(surfShaderName);
      // Determine which shader it is going to be
      if( !shader ) {
        if( global_shader ) {
          shader = global_shader;
        } else {
          shader = QERApp_Shader_ForName(surfShaderName);
        }
      }
      // Add reference
      shader->IncRef();
      // Done, continue
      m_shaders.push_back( shader );
    }
  }
开发者ID:siliconemilk,项目名称:q3map3,代码行数:25,代码来源:remap.cpp

示例3: AddFaceWithTextureScaled

void AddFaceWithTextureScaled(scene::Node* brush, vec3_t va, vec3_t vb, vec3_t vc,
                              const char* texture, bool bVertScale, bool bHorScale,
                              float minX, float minY, float maxX, float maxY)
{
    qtexture_t* pqtTexInfo;

    // TTimo: there used to be a call to pfnHasShader here
    //   this was not necessary. In Radiant everything is shader.
    //   If a texture doesn't have a shader script, a default shader object is used.
    // The IShader object was leaking also
    // collect texture info: sizes, etc
    IShader* i = QERApp_Shader_ForName(texture);
    pqtTexInfo = i->getTexture();	// shader width/height doesn't come out properly

    if(pqtTexInfo)
    {
        float scale[2] = {0.5f, 0.5f};
        float shift[2] = {0, 0};

        if(bHorScale)
        {
            int texWidth = pqtTexInfo->width;
            float width = maxX - minX;

            scale[0] = width/texWidth;
            shift[0] = -(float)((int)maxX%(int)width)/scale[0];
        }

        if(bVertScale)
        {
            int texHeight = pqtTexInfo->height;
            float height = maxY - minY;

            scale[1] = height/texHeight;
            shift[1] = (float)((int)minY%(int)height)/scale[1];
        }

        _QERFaceData addFace;
        FillDefaultTexture(&addFace, va, vb, vc, texture);
        addFace.m_texdef.scale[0] = scale[0];
        addFace.m_texdef.scale[1] = scale[1];
        addFace.m_texdef.shift[0] = shift[0];
        addFace.m_texdef.shift[1] = shift[1];

#if 0
        brush->m_brush->addPlane(addFace.m_p0, addFace.m_p1, addFace.m_p2, addFace.m_texdef);
#endif
    }
    else
    {
        // shouldn't even get here, as default missing texture should be returned if
        // texture doesn't exist, but just in case
        AddFaceWithTexture(brush, va, vb, vc, texture, FALSE);
        Sys_ERROR("BobToolz::Invalid Texture Name-> %s", texture);
    }
    // the IShader is not kept referenced, DecRef it
    i->DecRef();
}
开发者ID:ChunHungLiu,项目名称:GtkRadiant,代码行数:58,代码来源:shapes.cpp

示例4: AddFaceWithTextureScaled

void AddFaceWithTextureScaled(scene::Node& brush, vec3_t va, vec3_t vb, vec3_t vc, 
							  const char* texture, bool bVertScale, bool bHorScale, 
							  float minX, float minY, float maxX, float maxY)
{
	qtexture_t* pqtTexInfo;

  // TTimo: there used to be a call to pfnHasShader here
  //   this was not necessary. In Radiant everything is shader.
  //   If a texture doesn't have a shader script, a default shader object is used.
  // The IShader object was leaking also
	// collect texture info: sizes, etc
	IShader* i = GlobalShaderSystem().getShaderForName(texture);
  pqtTexInfo = i->getTexture();	// shader width/height doesn't come out properly

	if(pqtTexInfo)
	{
		float scale[2] = {0.5f, 0.5f};
		float shift[2] = {0, 0};

		if(bHorScale)
		{
			float width = maxX - minX;

			scale[0] = width/pqtTexInfo->width;
			shift[0] = -(float)((int)maxX%(int)width)/scale[0];
		}

		if(bVertScale)
		{
			float height = maxY - minY;

			scale[1] = height/pqtTexInfo->height;
			shift[1] = (float)((int)minY%(int)height)/scale[1];
		}

		_QERFaceData addFace;
		FillDefaultTexture(&addFace, va, vb, vc, texture);
		addFace.m_texdef.scale[0] = scale[0];
		addFace.m_texdef.scale[1] = scale[1];
		addFace.m_texdef.shift[0] = shift[0];
		addFace.m_texdef.shift[1] = shift[1];

    GlobalBrushCreator().Brush_addFace(brush, addFace);
	}
	else
	{
		// shouldn't even get here, as default missing texture should be returned if
		// texture doesn't exist, but just in case
		AddFaceWithTexture(brush, va, vb, vc, texture, false);
		globalErrorStream() << "BobToolz::Invalid Texture Name-> " << texture;
	}
  // the IShader is not kept referenced, DecRef it
  i->DecRef();
}
开发者ID:clbr,项目名称:netradiant,代码行数:54,代码来源:shapes.cpp

示例5: sentry

	// GTK CALLBACKS
	void TexturePreviewCombo::_onExpose (GtkWidget* widget, GdkEventExpose* ev, TexturePreviewCombo* self)
	{
		// Grab the GLWidget with sentry
		gtkutil::GLWidgetSentry sentry(widget);

		// Initialise viewport
		glClearColor(0.3, 0.3, 0.3, 0);
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
		glDisable( GL_DEPTH_TEST);
		glEnable( GL_TEXTURE_2D);

		// If no texture is loaded, leave window blank
		if (self->_texName.empty())
			return;

		glMatrixMode( GL_PROJECTION);
		glLoadIdentity();
		glOrtho(0, 1, 0, 1, -1, 1);

		// Get a reference to the selected shader
		IShader* shader = GlobalShaderSystem().getShaderForName(self->_texName);

		// Bind the texture from the shader
		GLTexture* tex = shader->getTexture();
		glBindTexture(GL_TEXTURE_2D, tex->texture_number);

		// Calculate the correct aspect ratio for preview
		float aspect = float(tex->width) / float(tex->height);
		float hfWidth, hfHeight;
		if (aspect > 1.0) {
			hfWidth = 0.5;
			hfHeight = 0.5 / aspect;
		} else {
			hfHeight = 0.5;
			hfWidth = 0.5 * aspect;
		}

		// Draw a polygon
		glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
		glColor3f(1, 1, 1);
		glBegin( GL_QUADS);
		glTexCoord2i(0, 1);
		glVertex2f(0.5 - hfWidth, 0.5 - hfHeight);
		glTexCoord2i(1, 1);
		glVertex2f(0.5 + hfWidth, 0.5 - hfHeight);
		glTexCoord2i(1, 0);
		glVertex2f(0.5 + hfWidth, 0.5 + hfHeight);
		glTexCoord2i(0, 0);
		glVertex2f(0.5 - hfWidth, 0.5 + hfHeight);
		glEnd();

		shader->DecRef();
	}
开发者ID:AresAndy,项目名称:ufoai,代码行数:54,代码来源:TexturePreviewCombo.cpp

示例6: ReleaseForShaderFile

void CShaderArray::ReleaseForShaderFile( const char *name ){
	int i;
	// decref
	for ( i = 0; i < CPtrArray::GetSize(); i++ )
	{
		IShader *pShader = static_cast < IShader * >( CPtrArray::GetAt( i ) );
		if ( !strcmp( name, pShader->getShaderFileName() ) ) {
			pShader->DecRef();
			CPtrArray::RemoveAt( i );
			i--;    // get ready for next loop
		}
	}
}
开发者ID:0bsidian,项目名称:GtkRadiant,代码行数:13,代码来源:shaders.cpp

示例7: Triangle

  void Triangle(Matrix43f float_clip_coords, IShader& shader) {
    Matrix43i clip_coords = Round(float_clip_coords);

    Vector2i min_bound = { Min(clip_coords[0]), Min(clip_coords[1]) };
    Vector2i max_bound = { Max(clip_coords[0]), Max(clip_coords[1]) };

    min_bound.x = std::max(min_bound.x, 0);
    min_bound.y = std::max(min_bound.y, 0);

    max_bound.x = std::min(max_bound.x, this->get_width() - 1);
    max_bound.y = std::min(max_bound.y, this->get_height() - 1);

    Vector2i a = { clip_coords[0][0], clip_coords[1][0] };
    Vector2i b = { clip_coords[0][1], clip_coords[1][1] };
    Vector2i c = { clip_coords[0][2], clip_coords[1][2] };

    TGAColor color;
    for (int x = min_bound.x; x <= max_bound.x; ++x) {
      for (int y = min_bound.y; y <= max_bound.y; ++y) {
        Vector3f bc = Barycentric(a, b, c, Vector2i{ x, y });
        if (bc.x < 0 || bc.y < 0 || bc.z < 0) {
          continue;
        }

        bool discard = shader.Fragment(bc, color);
        if (!discard) {
          float z_depth = bc * float_clip_coords[2];
          this->Set(x, y, z_depth, color);
        }
      }
    }
  }
开发者ID:olage,项目名称:renderer,代码行数:32,代码来源:main.cpp

示例8: find_clicked

static void find_clicked( GtkWidget *widget, gpointer data ){
	GtkWidget *menu, *item;
	menu = gtk_menu_new();

	for ( int i = 0; i < QERApp_GetActiveShaderCount(); i++ )
	{
		IShader *pShader = QERApp_ActiveShader_ForIndex( i );

		item = gtk_menu_item_new_with_label( pShader->getName() );
		g_signal_connect( G_OBJECT( item ), "activate", G_CALLBACK( popup_selected ), data );
		gtk_widget_show( item );
		gtk_menu_shell_append( GTK_MENU_SHELL( menu ), item );
	}

	gtk_menu_popup( GTK_MENU( menu ), NULL, NULL, NULL, NULL, 1, GDK_CURRENT_TIME );
}
开发者ID:TTimo,项目名称:GtkRadiant,代码行数:16,代码来源:findtexturedialog.cpp

示例9: PrintShaderContents

void PrintShaderContents( int dllID )
{
    IShaderDLLInternal *pShaderDLL = g_ShaderDLLs[dllID].m_pInternal;
    int nShaders = pShaderDLL->ShaderCount();
    int i;
    printf( "<H2>%s</H2><BR>\n", g_ShaderDLLs[dllID].m_Filename );
    printf( "<dl>\n" ); // define list
    for( i = 0; i < nShaders; i++ )
    {
        IShader *pShader = pShaderDLL->GetShader( i );
        printf( "<A HREF=\"#%s_%s\">\n", g_ShaderDLLs[dllID].m_Filename, pShader->GetName() );
        printf( "<dt>%s</A>\n", pShader->GetName() );
//		int nParams = pShader->GetNumParams();
    }
    printf( "</dl>\n" ); // end define list
}
开发者ID:steadyfield,项目名称:SourceEngine2007,代码行数:16,代码来源:dumpmatsyshelp.cpp

示例10: LoadShader

IShader* ResMgr::LoadShader(const std::string& vsh, const std::string& fsh)
{
    std::string key = vsh + fsh;
    std::map<std::string , IShader*>::iterator result = m_shaders.find(key);
    if(result!= m_shaders.end())
    {
        IShader* pRes = result->second;
        return pRes;
    }

    IShader* pShader = (IShader*)GetMgr()->Create("Shader");
    pShader->SetResMgr(this);
    pShader->Load(vsh.c_str(), fsh.c_str());
    m_shaders[key] = pShader;
    return pShader;
}
开发者ID:zozoiiiiii,项目名称:yy,代码行数:16,代码来源:res_mgr.cpp

示例11: DrawWaypoints

void SceneManager::DrawWaypoints(IShader& shader)
{
	std::map<unsigned int, AIPath>::iterator iter = m_AIPaths.begin();

	for (iter; iter != m_AIPaths.end(); ++iter)
	{
		if (iter->second.IsVisible())
		{
			std::vector<glm::vec3> path = iter->second.GetWaypoints();
			for (int i = 0; i < path.size(); ++i)
			{
				glm::mat4 translation;
				translation = glm::translate(translation, path[i]);
				shader.SetWorldMatrix(translation);
				m_miscObjects["waypoint"]->Draw();

				if (iter->second.IsClosed())
				{
					if (path.size() > 1 && (i - 1) < path.size())
					{
						glBegin(GL_LINES);
						glm::vec3 cpos = path[i - 1];
						glm::vec3 npos = path[i];
						glm::vec3 min = cpos - npos;
						glVertex3f(0, 5, 0);
						glVertex3f(min.x, min.y + 5, min.z);
						glEnd();
					}

					if (path.size() > 2 && (i) == path.size() - 1)
					{
						glBegin(GL_LINES);
						glm::vec3 cpos = path[0];
						glm::vec3 npos = path[path.size() - 1];
						glm::vec3 min = cpos - npos;
						glVertex3f(0, 5, 0);
						glVertex3f(min.x, min.y + 5, min.z);
						glEnd();
					}
				}
				else
				{
					if (path.size() > 1 && (i - 1) < path.size())
					{
						glBegin(GL_LINES);
						glm::vec3 cpos = path[i - 1];
						glm::vec3 npos = path[i];
						glm::vec3 min = cpos - npos;
						glVertex3f(0, 5, 0);
						glVertex3f(min.x, min.y + 5, min.z);
						glEnd();
					}
				}
			}
		}
	}
}
开发者ID:trezor555,项目名称:Editor,代码行数:57,代码来源:SceneManager.cpp

示例12: PrintShaderHelp

void PrintShaderHelp( int dllID )
{
    IShaderDLLInternal *pShaderDLL = g_ShaderDLLs[dllID].m_pInternal;
    int nShaders = pShaderDLL->ShaderCount();
    int i;
    printf( "<H2>%s</H2><BR>\n", g_ShaderDLLs[dllID].m_Filename );
    printf( "<dl>\n" ); // define list
    for( i = 0; i < nShaders; i++ )
    {
        IShader *pShader = pShaderDLL->GetShader( i );
        printf( "<A NAME=\"%s_%s\"></A>\n", g_ShaderDLLs[dllID].m_Filename, pShader->GetName() );
        printf( "<dt>%s<dl>\n", pShader->GetName() );
        int nParams = pShader->GetNumParams();
        int j;
        for( j = 0; j < nParams; j++ )
        {
            printf( "<dt>%s\n<dd>%s\n",
                    pShader->GetParamName( j ),
                    pShader->GetParamHelp( j )
                  );
        }
        printf( "</dl><br>\n" ); // end define list
    }
    printf( "</dl>\n" ); // end define list
}
开发者ID:steadyfield,项目名称:SourceEngine2007,代码行数:25,代码来源:dumpmatsyshelp.cpp

示例13: GlobalTexturePrefix_get

void ShaderChooser::shaderSelectionChanged(const std::string& shaderName, GtkListStore* listStore) {
	if (_targetEntry != NULL) {
		const char *value = shaderName.c_str();
		if (_stripTextureDir)
			value += GlobalTexturePrefix_get().size();
		gtk_entry_set_text(GTK_ENTRY(_targetEntry), value);
	}

	// Propagate the call up to the client (e.g. SurfaceInspector)
	if (_client != NULL) {
		_client->shaderSelectionChanged(shaderName);
	}

	// Get the shader, and its image map if possible
	IShader* shader = _selector.getSelectedShader();
	if (shader != NULL) {
		// Pass the call to the static member
		ShaderSelector::displayShaderInfo(shader, listStore);

		shader->DecRef();
	}
}
开发者ID:MyWifeRules,项目名称:ufoai-1,代码行数:22,代码来源:ShaderChooser.cpp

示例14:

IProgram*   ShaderModuleRepository::findProgram(ShaderType type, int numShaders, IShader ** pShaders)
{
    int sz = (int)m_programs.size();
    for(int i=0; i<sz; i++)
    {
        IProgram* p = m_programs[i].p;
        if(numShaders != p->getNumShaders())
            continue;
        int j;
        for(j=0; j<numShaders; j++)
        {
            ShaderType t;
            IShader* pShd;
            pShd = p->getShader(0, &t);
            if(t != type)
                return NULL;
            if((pShd == NULL) || (findShader(pShd->getName()) == NULL) )
                break;
        }
        if(j == numShaders)
            return p;
    }
    return NULL;
}
开发者ID:RylauChelmi,项目名称:nvFX,代码行数:24,代码来源:FxLib.cpp

示例15: DrawTempWaypoints

void SceneManager::DrawTempWaypoints(IShader& shader, AIPath& tempPath)
{
	std::vector<glm::vec3> path = tempPath.GetWaypoints();
	for (int i = 0; i < path.size(); ++i)
	{
		glm::mat4 translation;
		translation = glm::translate(translation, path[i]);
		shader.SetWorldMatrix(translation);
		m_miscObjects["waypoint"]->Draw();
		if (tempPath.IsClosed())
		{
			if (path.size() > 1 && (i - 1) < path.size())
			{
				glBegin(GL_LINES);
				glm::vec3 cpos = path[i - 1];
				glm::vec3 npos = path[i];
				glm::vec3 min = cpos - npos;
				glVertex3f(0, 5, 0);
				glVertex3f(min.x, min.y + 5, min.z);
				glEnd();
			}

			if (path.size() > 2 && (i) == path.size()-1)
			{
				glBegin(GL_LINES);
				glm::vec3 cpos = path[0];
				glm::vec3 npos = path[path.size() - 1];
				glm::vec3 min = cpos - npos;
				glVertex3f(0, 5, 0);
				glVertex3f(min.x, min.y + 5, min.z);
				glEnd();
			}
		}
		else
		{
			if (path.size() > 1 && (i - 1) < path.size())
			{
				glBegin(GL_LINES);
				glm::vec3 cpos = path[i - 1];
				glm::vec3 npos = path[i];
				glm::vec3 min = cpos - npos;
				glVertex3f(0, 5, 0);
				glVertex3f(min.x, min.y + 5, min.z);
				glEnd();
			}
		}
	}
}
开发者ID:trezor555,项目名称:Editor,代码行数:48,代码来源:SceneManager.cpp


注:本文中的IShader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。