Пример #1
0
RendererHUDClassic::RendererHUDClassic( Instance* instance, Font* font )
	: RendererHUD( instance, font )
	, mSmoothRPY( Vector3f() )
	, mShader{ 0 }
	, mColorShader{ 0 }
{
	LoadVertexShader( &mShader, hud_vertices_shader, sizeof(hud_vertices_shader) + 1 );
	LoadFragmentShader( &mShader, hud_fragment_shader, sizeof(hud_fragment_shader) + 1 );
	createPipeline( &mShader );
	glUseProgram( mShader.mShader );
	glEnableVertexAttribArray( mShader.mVertexTexcoordID );
	glEnableVertexAttribArray( mShader.mVertexPositionID );
	glUseProgram( 0 );

	LoadVertexShader( &mColorShader, hud_color_vertices_shader, sizeof(hud_color_vertices_shader) + 1 );
	LoadFragmentShader( &mColorShader, hud_color_fragment_shader, sizeof(hud_color_fragment_shader) + 1 );
	createPipeline( &mColorShader );
	glUseProgram( mColorShader.mShader );
	glEnableVertexAttribArray( mColorShader.mVertexTexcoordID );
	glEnableVertexAttribArray( mColorShader.mVertexColorID );
	glEnableVertexAttribArray( mColorShader.mVertexPositionID );
	glUseProgram( 0 );

	Compute();
}
Пример #2
0
//==============================================================================================================================
bool MaterialShader::Initialize()
{
    ConstantBuffer<ZShadeSandboxLighting::cbMaterialShadingBuffer> shadingCB(m_pD3DSystem);
    shadingCB.Initialize(PAD16(sizeof(ZShadeSandboxLighting::cbMaterialShadingBuffer)));
    m_pShadingCB = shadingCB.Buffer();

    ConstantBuffer<cbMatrixBufferLight> matrixCB(m_pD3DSystem);
    matrixCB.Initialize(PAD16(sizeof(cbMatrixBufferLight)));
    m_pMatrixCB = matrixCB.Buffer();

    ConstantBuffer<ZShadeSandboxLighting::cbLightBuffer> lightCB(m_pD3DSystem);
    lightCB.Initialize(PAD16(sizeof(ZShadeSandboxLighting::cbLightBuffer)));
    m_pLightCB = lightCB.Buffer();

    ConstantBuffer<ZShadeSandboxLighting::cbSunLightBuffer> sunCB(m_pD3DSystem);
    sunCB.Initialize(PAD16(sizeof(ZShadeSandboxLighting::cbSunLightBuffer)));
    m_pSunCB = sunCB.Buffer();

    ClearInputLayout();

    LoadPixelShader("MaterialShaderPS");
    LoadPixelShader("MaterialShaderWireframePS");

    SetInputLayoutDesc("MaterialShader", ZShadeSandboxMesh::VertexLayout::mesh_layout_pos_normal_tex, 3);
    LoadVertexShader("MaterialShaderVS");
    AssignVertexShaderLayout("MaterialShader");

    SetInputLayoutDesc("MaterialShaderInstance", ZShadeSandboxMesh::VertexLayout::mesh_layout_pos_normal_tex_instance, 4);
    LoadVertexShader("MaterialShaderInstanceVS");
    AssignVertexShaderLayout("MaterialShaderInstance");

    return true;
}
Пример #3
0
/*
================================================================================================
idRenderProgManager::FindVertexShader
================================================================================================
*/
int idRenderProgManager::FindVertexShader( const char* name )
{
	for( int i = 0; i < vertexShaders.Num(); i++ )
	{
		if( vertexShaders[i].name.Icmp( name ) == 0 )
		{
			LoadVertexShader( i );
			return i;
		}
	}
	vertexShader_t shader;
	shader.name = name;
	int index = vertexShaders.Append( shader );
	LoadVertexShader( index );
	currentVertexShader = index;
	
	// RB: removed idStr::Icmp( name, "heatHaze.vfp" ) == 0  hack
	// this requires r_useUniformArrays 1
	for( int i = 0; i < vertexShaders[index].uniforms.Num(); i++ )
	{
		if( vertexShaders[index].uniforms[i] == RENDERPARM_ENABLE_SKINNING )
		{
			vertexShaders[index].usesJoints = true;
			vertexShaders[index].optionalSkinning = true;
		}
	}
	// RB end
	
	return index;
}
Пример #4
0
// 初期化をする
Shader *Shader_Initialize()
{
	Shader *self = new Shader();

	self->depthmap_vs = LoadVertexShader("shader/depthmap.vs.vso");
	self->depthmap_ps = LoadPixelShader("shader/depthmap.ps.pso");
	self->phong_vs = LoadVertexShader("shader/phong.vs.vso");
	self->phong_ps = LoadPixelShader("shader/phong.ps.pso");

	self->active_pass = -1;
	self->depthmap_screen = create_depthmap_buffer();

	return self;
}
Пример #5
0
//==============================================================================================================================
bool DeferredShader::Initialize()
{
	ConstantBuffer<cbPackBuffer> packCB(m_pD3DSystem);
	packCB.Initialize(PAD16(sizeof(cbPackBuffer)));
	m_pPackCB = packCB.Buffer();
	
	ConstantBuffer<cbMatrixBuffer> matrixCB(m_pD3DSystem);
	matrixCB.Initialize(PAD16(sizeof(cbMatrixBuffer)));
	m_pMatrixCB = matrixCB.Buffer();
	
	ConstantBuffer<cbMatrixBuffer2> matrix2CB(m_pD3DSystem);
	matrix2CB.Initialize(PAD16(sizeof(cbMatrixBuffer2)));
	m_pMatrix2CB = matrix2CB.Buffer();
	
	ClearInputLayout();
	
	SetInputLayoutDesc("DeferredShader", ZShadeSandboxMesh::VertexLayout::mesh_layout_pos_normal_tex, 3);
	
	LoadVertexShader("DeferredShaderVS");
	LoadPixelShader("DeferredShaderPS");
	LoadPixelShader("DeferredShaderWireframePS");
	
	AssignVertexShaderLayout("DeferredShader");
	
	return true;
}
Пример #6
0
// Initialises the given render method (vertex + pixel shader), returns true on success
bool LoadMethod( int method )
{
	// If the vertex shader for this method has not already been initialised
	if (!renderMethods[method].vertexShader)
	{
		// Load the vertex shader file specified above, storing resultant DirectX data
		if (!LoadVertexShader( renderMethods[method].vertexShaderFile,
                               &renderMethods[method].vertexShader,
		                       &renderMethods[method].vertexConsts ))
		{
			return false;
		}
	}
	if (!renderMethods[method].pixelShader)
	{
		// Load the vertex shader file specified above, storing resultant DirectX data
		if (!LoadPixelShader( renderMethods[method].pixelShaderFile,
		                      &renderMethods[method].pixelShader,
		                      &renderMethods[method].pixelConsts ))
		{
			return false;
		}
	}

	if (!renderMethods[method].vertexDecl)
	{
		if (FAILED(g_pd3dDevice->CreateVertexDeclaration( renderMethods[method].vertexElts,
		                                                  &renderMethods[method].vertexDecl )))
		{
			return false;
		}
	}

	return true;
}
Пример #7
0
ShaderProgram_t *InitProgram (const char *vsName, const char *fsName)
{
    char		buf[1024];
    VertexShader_t	*vsh = 0;
    FragmentShader_t	*fsh = 0;
    ShaderProgram_t	*prog;

    if (vsName != 0) {
      // load the vertex shader
	if ((vsh = LoadVertexShader (vsName)) == 0)
	    exit (1);
    }

    if (fsName != 0) {
      // load the vertex shader
	if ((fsh = LoadFragmentShader (fsName)) == 0)
	    exit (1);
    }

    if ((prog = CreateShaderProgram (vsh, fsh)) == 0)
	exit (1);

    FreeVertexShader (vsh);
    FreeFragmentShader (fsh);

    return prog;
}
	bool ILine::Load(IDirect3DDevice9 * i_direct3dDevice
#ifdef EAE2014_SHOULDALLRETURNVALUESBECHECKED
		, std::string* o_errorMessage
#endif
		)
	{
		if (!LoadFragmentShader(s_FragmentShaderPath, i_direct3dDevice,
#ifdef EAE2014_SHOULDALLRETURNVALUESBECHECKED
			o_errorMessage
#endif
			))
		{
			return false;
		}

		if (!LoadVertexShader(s_VertexShaderPath, i_direct3dDevice,
#ifdef EAE2014_SHOULDALLRETURNVALUESBECHECKED
			o_errorMessage
#endif
			))
		{
			return false;
		}

		return true;
	}
Пример #9
0
OpenGLRenderer::OpenGLRenderer()
{
	m_programID = 0;

	GLenum err = glewInit();
	if (err != GLEW_OK)
	{
		LogManager::getInstance().error((const char*)glewGetErrorString(err));
	}

	m_programID = glCreateProgram();

	GLuint vertexShader = LoadVertexShader("triangles.vert");
	glAttachShader(m_programID, vertexShader);

	GLuint fragmentShader = LoadFragShader("triangles.frag");
	glAttachShader(m_programID, fragmentShader);

	glLinkProgram(m_programID);

	glDeleteShader(vertexShader);
	glDeleteShader(fragmentShader);

	glUseProgram(m_programID);
}
Пример #10
0
void OBS::DrawPreview(const Vect2 &renderFrameSize, const Vect2 &renderFrameOffset, const Vect2 &renderFrameCtrlSize, int curRenderTarget, PreviewDrawType type)
{
    LoadVertexShader(mainVertexShader);
    LoadPixelShader(mainPixelShader);

    Ortho(0.0f, renderFrameCtrlSize.x, renderFrameCtrlSize.y, 0.0f, -100.0f, 100.0f);
    if(type != Preview_Projector
       && (renderFrameCtrlSize.x != oldRenderFrameCtrlWidth
           || renderFrameCtrlSize.y != oldRenderFrameCtrlHeight))
    {
        // User is drag resizing the window. We don't recreate the swap chains so our coordinates are wrong
        SetViewport(0.0f, 0.0f, (float)oldRenderFrameCtrlWidth, (float)oldRenderFrameCtrlHeight);
    }
    else
        SetViewport(0.0f, 0.0f, renderFrameCtrlSize.x, renderFrameCtrlSize.y);

    // Draw background (Black if fullscreen/projector, window colour otherwise)
    if(type == Preview_Fullscreen || type == Preview_Projector)
        ClearColorBuffer(0x000000);
    else
        ClearColorBuffer(GetSysColor(COLOR_BTNFACE));

    if(bTransitioning)
    {
        BlendFunction(GS_BLEND_ONE, GS_BLEND_ZERO);
        DrawSprite(transitionTexture, 0xFFFFFFFF,
                renderFrameOffset.x, renderFrameOffset.y,
                renderFrameOffset.x + renderFrameSize.x, renderFrameOffset.y + renderFrameSize.y);
        BlendFunction(GS_BLEND_FACTOR, GS_BLEND_INVFACTOR, transitionAlpha);
    }

    DrawSprite(mainRenderTextures[curRenderTarget], 0xFFFFFFFF,
            renderFrameOffset.x, renderFrameOffset.y,
            renderFrameOffset.x + renderFrameSize.x, renderFrameOffset.y + renderFrameSize.y);
}
Пример #11
0
void D3D10System::UnloadAllData()
{
    LoadVertexShader(NULL);
    LoadPixelShader(NULL);
    LoadVertexBuffer(NULL);
    for(UINT i=0; i<8; i++)
    {
        LoadSamplerState(NULL, i);
        LoadTexture(NULL, i);
    }

    UINT zeroVal = 0;
    LPVOID nullBuff[8];
    float bla[4] = {1.0f, 1.0f, 1.0f, 1.0f};

    zero(nullBuff, sizeof(nullBuff));

    d3d->VSSetConstantBuffers(0, 1, (ID3D10Buffer**)nullBuff);
    d3d->PSSetConstantBuffers(0, 1, (ID3D10Buffer**)nullBuff);
    d3d->OMSetDepthStencilState(NULL, 0);
    d3d->PSSetSamplers(0, 1, (ID3D10SamplerState**)nullBuff);
    d3d->OMSetBlendState(NULL, bla, 0xFFFFFFFF);
    d3d->OMSetRenderTargets(1, (ID3D10RenderTargetView**)nullBuff, NULL);
    d3d->IASetVertexBuffers(0, 8, (ID3D10Buffer**)nullBuff, &zeroVal, &zeroVal);
    d3d->PSSetShaderResources(0, 8, (ID3D10ShaderResourceView**)nullBuff);
    d3d->IASetInputLayout(NULL);
    d3d->PSSetShader(NULL);
    d3d->VSSetShader(NULL);
    d3d->RSSetState(NULL);
}
//==============================================================================================================================
bool TerrainTessellationQuadShadowShader::Initialize()
{
	ConstantBuffer<cTessellationBuffer> tessellationCB(m_pD3DSystem);
	tessellationCB.Initialize(PAD16(sizeof(cTessellationBuffer)));
	m_pTessellationCB = tessellationCB.Buffer();
	
	ConstantBuffer<cDomainConstBuffer> domainCB(m_pD3DSystem);
	domainCB.Initialize(PAD16(sizeof(cDomainConstBuffer)));
	m_pDomainCB = domainCB.Buffer();

	ConstantBuffer<cMatrixBuffer> matrixBufferCB(m_pD3DSystem);
	matrixBufferCB.Initialize(PAD16(sizeof(cMatrixBuffer)));
	m_pMatrixBufferCB = matrixBufferCB.Buffer();
	
	ClearInputLayout();
	SetInputLayoutDesc("TerrainTessellationQuadShadowShader", ZShadeSandboxMesh::VertexLayout::mesh_layout_pos_tex, 2);
	
	LoadVertexShader("TerrainTessellationQuadVS");
	LoadHullShader("TerrainTessellationQuadShadowHS");
	LoadDomainShader("TerrainTessellationQuadDS");
	LoadPixelShader("TerrainTessellationShadowPS");
	
	AssignVertexShaderLayout("TerrainTessellationQuadShadowShader");
	
	return true;
}
Пример #13
0
	void Shader::Compile(const std::string &pVSName, const std::string &pFSName, const std::string &pGSName){
		std::string all = String(pVSName)+pFSName+pGSName;

		Shader* tmp = ResourceManager::Call().Get<Shader>(all);
		if(tmp != 0){
			//Shader existe deja, on copie ses identifiants dans celui ci
			mProgram = tmp->mProgram;
		}else{
			//Shader n'existe pas, on le cree

			// Ajout du shader au ResourceManager
			ResourceManager::Call().Add(all, this);

			// Chargement des fichiers shaders
			LoadVertexShader(pVSName);
			LoadFragmentShader(pFSName);
			if(!pGSName.empty())
				LoadGeometryShader(pGSName);

			// Creation du shader mProgram
			mProgram = glCreateProgram();

			// Linkage des deux shaders précédemment créés
			glAttachShader(mProgram, mVShader);
			glAttachShader(mProgram, mFShader);
			if(mGShader)
				glAttachShader(mProgram, mGShader);

			// Linkage du mProgramme a OGL
			glLinkProgram(mProgram);

			GLint error;
			glGetProgramiv(mProgram, GL_LINK_STATUS, &error);
			if(!error){
				char log[1024];
				glGetProgramInfoLog(mProgram, 1024, NULL, log);
				if(mVShader)
					glDeleteShader(mVShader);
				if(mFShader)
					glDeleteShader(mFShader);
				if(mGShader)
					glDeleteShader(mGShader);
				throw Exception(String("Shader Link Error :\n")+log);
			}
		
			// Destruction des Shaders. ils sont maintenant dans le program
			glDeleteShader(mVShader);
			glDeleteShader(mFShader);
			if(mGShader)
				glDeleteShader(mGShader);

			// Attribution des texCoords
			glUseProgram(mProgram);
			glUniform1i(glGetUniformLocation(mProgram, "tex"), 0);
			glBindFragDataLocation(mProgram, 0, "finalColor");
			glUseProgram(0);
		}
	}
Пример #14
0
void AllignedQuadEffect::Init()
{
    LoadVertexShader( "H:/Projects VS C++/My VoxelEngine/VoxelGame 0.09/MyFramework/AllignedQuadEffect.hlsl" );
    LoadPixelShader( "H:/Projects VS C++/My VoxelEngine/VoxelGame 0.09/MyFramework/AllignedQuadEffect.hlsl" );

    D3DXHANDLE hMyTexture = m_pixelShaderConstantTable->GetConstantByName( nullptr, "myTexture" );

    UINT count;
    m_pixelShaderConstantTable->GetConstantDesc( hMyTexture, &m_myTextureConstantDesk, &count );
}
//==============================================================================================================================
bool AmbientLightDeferredShader::Initialize()
{
	ConstantBuffer<cbDeferredLightBuffer> lightCB(m_pD3DSystem);
	lightCB.Initialize(PAD16(sizeof(cbDeferredLightBuffer)));
	m_pLightCB = lightCB.Buffer();
	
	LoadVertexShader("AmbientLightDeferredVS");
	LoadPixelShader("AmbientLightDeferredPS");
	LoadPixelShader("AmbientLightDeferredWireframePS");
	
	return true;
}
//////////////////////////////////////////////////////////////////////
// powi¹zanie shadera wierzcho³ków, reprezentowanego przez kod
// Ÿród³owy, z obiektem programu; w razie potrzeby tworzony
// jest nowy obiekt programu
//////////////////////////////////////////////////////////////////////
void AttachVertexShader( GLuint &program, const char **src )
{
    // odczyt kodu shadera i jego kompilacja
    GLuint shader = LoadVertexShader( src );

    // w razie potrzeby tworzymy obiekt programu
    if( !glIsProgram( program ) )
        program = glCreateProgram();

    // do³¹czenie obiektu shadera do obiektu programu
    glAttachShader( program, shader );
}
//==============================================================================================================================
bool DebugGBufferDeferredShader::Initialize()
{
	ConstantBuffer<cbInvMatrixBuffer> matrixCB(m_pD3DSystem);
	matrixCB.Initialize(PAD16(sizeof(cbInvMatrixBuffer)));
	m_pMatrixCB = matrixCB.Buffer();

	LoadVertexShader("DebugGBufferDeferredVS");
	LoadPixelShader("DebugGBufferDeferredPS");
	LoadPixelShader("DebugGBufferDepthDeferredPS");
	LoadPixelShader("DebugGBufferDeferredWireframePS");
	
	return true;
}
	bool Sprite::Load(const char* i_TexturePath, const sRectangle &i_texcoords, const sSprite &i_spriteDetails, IDirect3DDevice9* i_direct3dDevice
#ifdef EAE2014_SHOULDALLRETURNVALUESBECHECKED
		, std::string* o_errorMessage
#endif
		)
	{
		assert(i_TexturePath && s_FragmentShaderPath && s_VertexShaderPath && s_SamplerName && i_direct3dDevice);

		//Load the shader from the path
		if (!LoadFragmentShader(s_FragmentShaderPath, m_direct3dDevice
#ifdef EAE2014_SHOULDALLRETURNVALUESBECHECKED
			, o_errorMessage
#endif		
			))
		{
			return false;
		}

		//Load the shader from the path
		if (!LoadVertexShader(s_VertexShaderPath, m_direct3dDevice
#ifdef EAE2014_SHOULDALLRETURNVALUESBECHECKED
			, o_errorMessage
#endif		
			))
		{
			return false;
		}

		if (!LoadTextureAndSamplerRegister(i_TexturePath, s_SamplerName, m_direct3dDevice
#ifdef EAE2014_SHOULDALLRETURNVALUESBECHECKED
			, o_errorMessage
#endif
			))
		{
#ifdef EAE2014_SHOULDALLRETURNVALUESBECHECKED
			
#endif
			return false;
		}

		if (!CreateSpriteDrawInfoandFillVertexBuffer(i_spriteDetails, i_texcoords))
		{
#ifdef EAE2014_SHOULDALLRETURNVALUESBECHECKED

#endif
			return false;
		}

		return true;
	}
Пример #19
0
// ステージの初期化処理
void Stage_Initialize( void )
{
	// ステージモデルの読み込み
	stg.ModelHandle = MV1LoadModel( "ColTestStage.mqo" ) ;

	// モデル全体のコリジョン情報のセットアップ
	MV1SetupCollInfo( stg.ModelHandle, -1 ) ;


	// 作成する画像のフォーマットを不動小数点型で1チャンネル、16ビットにする
	SetDrawValidFloatTypeGraphCreateFlag( TRUE ) ;
	SetCreateDrawValidGraphChannelNum( 1 ) ;
	SetCreateGraphColorBitDepth( 16 ) ;

	// 影用深度記録画像の作成
	DepthBufferGraphHandle = MakeScreen( 4096, 4096, FALSE ) ;

	// 設定を元に戻す
	SetDrawValidFloatTypeGraphCreateFlag( FALSE ) ;
	SetCreateDrawValidGraphChannelNum( 4 ) ;
	SetCreateGraphColorBitDepth( 32 ) ;

	// 深度記録画像描画用の頂点シェーダーを読み込む
	Skin4_DepthShadow_Step1_VertexShader = LoadVertexShader( "SkinMesh4_DepthShadow_Step1VS.vso" ) ;
	Normal_DepthShadow_Step1_VertexShader = LoadVertexShader( "NormalMesh_DepthShadow_Step1VS.vso" ) ;

	// 深度記録画像描画用のピクセルシェーダーを読み込む
	DepthShadow_Step1_PixelShader = LoadPixelShader( "DepthShadow_Step1PS.pso" ) ;

	// 深度記録画像を使ったディレクショナルライト一つの描画用頂点シェーダーを読み込む
	Skin4_DirLight_DepthShadow_Step2_VertexShader = LoadVertexShader( "SkinMesh4_DirLight_DepthShadow_Step2VS.vso" ) ;
	Normal_DirLight_DepthShadow_Step2_VertexShader = LoadVertexShader( "NormalMesh_DirLight_DepthShadow_Step2VS.vso" ) ;

	// 深度記録画像を使ったディレクショナルライト一つの描画用ピクセルシェーダーを読み込む
	DirLight_DepthShadow_Step2_PixelShader = LoadPixelShader( "DirLight_DepthShadow_Step2PS.pso" ) ;
}
// powi¹zanie shadera wierzcho³ków i shadera fragmentów,
// reprezentowanego przez kod Ÿród³owy, z obiektem programu;
// w razie potrzeby tworzony jest nowy obiekt programu
//////////////////////////////////////////////////////////////////////
void AttachVertexFragmentShader( GLuint &program, const char **vsSrc, const char **fsSrc )
{
    // odczyt kodu shadera wierzcho³ków i jego kompilacja
    GLuint vShader = LoadVertexShader( vsSrc );

    // odczyt kodu shadera fragmentów i jego kompilacja
    GLuint fShader = LoadFragmentShader( fsSrc );

    // w razie potrzeby tworzymy obiekt programu
    if( !glIsProgram( program ) )
        program = glCreateProgram();

    // do³¹czenie obiektów shaderów do obiektu programu
    glAttachShader( program, vShader );
    glAttachShader( program, fShader );
}
//==============================================================================================================================
bool ShadowMapBuildShader::Initialize()
{
	ConstantBuffer<cbShadowMapConst> shadowMapCB(m_pD3DSystem);
	shadowMapCB.Initialize(PAD16(sizeof(cbShadowMapConst)));
	m_pShadowMapCB = shadowMapCB.Buffer();
	
	ClearInputLayout();
	//SetInputLayoutDesc("ShadowMapBuildShader", ZShadeSandboxMesh::VertexLayout::mesh_layout_pos, 1);
	SetInputLayoutDesc("ShadowMapBuildShader", ZShadeSandboxMesh::VertexLayout::mesh_layout_pos_normal_tex, 3);
	
	LoadVertexShader("ShadowMapBuilderVS");
	LoadPixelShader("ShadowMapBuilderPS");
	
	AssignVertexShaderLayout("ShadowMapBuildShader");
	
	return true;
}
Пример #22
0
//=============================================================================
// draw
//=============================================================================
void GameScore::Draw(void)
{
	auto graphic_device = GET_GRAPHIC_DEVICE();
	auto basic_vs = graphic_device->LoadVertexShader("resources/shader/basic.vsc");
	auto basic_ps = graphic_device->LoadPixelShader("resources/shader/basic.psc");

	//スコア数字の描画
	for (int j = 0; j < (unsigned int)TEAM::MAX; j++)
	{
		for (int i = 0; i < SCORE_DIGIT; i++)
		{
			basic_vs->SetValue("_world_matrix", (f32*)&num_object_[j][i]->GetMatrix(), sizeof(float4x4));
			basic_ps->SetTexture("_texture_sampler", num_object_[j][i]->GetTexture(digit_num_[j][i]));
			num_object_[j][i]->Draw();
		}
	}
}
//////////////////////////////////////////////////////////////////////
// powi¹zanie shadera wierzcho³ków, shadera geometrii i shadera
// fragmentów, reprezentowanego przez kod Ÿród³owy w plikach, z obiektem
// programu; w razie potrzeby tworzony jest nowy obiekt programu
//////////////////////////////////////////////////////////////////////
void AttachVertexGeometryFragmentShader( GLuint &program, const char *vsName, const char *gsName, const char *fsName )
{
    // odczyt kodu shadera wierzcho³ków z pliku i jego kompilacja
    GLuint vShader = LoadVertexShader( vsName );

    // odczyt kodu shadera geometrii z pliku i jego kompilacja
    GLuint gShader = LoadGeometryShader( gsName );

    // odczyt kodu shadera fragmentów z pliku i jego kompilacja
    GLuint fShader = LoadFragmentShader( fsName );

    // w razie potrzeby tworzymy obiekt programu
    if( !glIsProgram( program ) )
        program = glCreateProgram();

    // do³¹czenie obiektów shaderów do obiektu programu
    glAttachShader( program, vShader );
    glAttachShader( program, gShader );
    glAttachShader( program, fShader );
}
Пример #24
0
//==============================================================================================================================
bool OBJMeshShader::Initialize()
{
	ConstantBuffer<cbOBJShadingConst> objShadingCB(m_pD3DSystem);
	objShadingCB.Initialize(PAD16(sizeof(cbOBJShadingConst)));
	m_pOBJShadingCB = objShadingCB.Buffer();
	
	ConstantBuffer<cbMatrixBuffer> matrixBufferCB(m_pD3DSystem);
	matrixBufferCB.Initialize(PAD16(sizeof(cbMatrixBuffer)));
	m_pMatrixBufferCB = matrixBufferCB.Buffer();
	
	ClearInputLayout();
	SetInputLayoutDesc("OBJMeshShader", ZShadeSandboxMesh::VertexLayout::mesh_layout_pos_normal_tex, 3);
	
	LoadVertexShader("OBJMeshVS");
	LoadPixelShader("OBJMeshPS");
	LoadPixelShader("OBJMeshWireframePS");
	
	AssignVertexShaderLayout("OBJMeshShader");
	
	return true;
}
//==============================================================================================================================
bool TriMaterialTessellationShader::Initialize()
{
	ConstantBuffer<cTessellationBuffer> tessellationCB(m_pD3DSystem);
	tessellationCB.Initialize(PAD16(sizeof(cTessellationBuffer)));
	m_pTessellationCB = tessellationCB.Buffer();
	
	ConstantBuffer<Const_Per_Frame> perFrameCB(m_pD3DSystem);
	perFrameCB.Initialize(PAD16(sizeof(Const_Per_Frame)));
	m_pPerFrameCB = perFrameCB.Buffer();
	
	ConstantBuffer<Const_Per_Object> perObjectCB(m_pD3DSystem);
	perObjectCB.Initialize(PAD16(sizeof(Const_Per_Object)));
	m_pPerObjectCB = perObjectCB.Buffer();
	
	ConstantBuffer<ZShadeSandboxLighting::cbLightBuffer> lightCB(m_pD3DSystem);
	lightCB.Initialize(PAD16(sizeof(ZShadeSandboxLighting::cbLightBuffer)));
	m_pLightCB = lightCB.Buffer();
	
	ConstantBuffer<ZShadeSandboxLighting::cbSunLightBuffer> sunCB(m_pD3DSystem);
	sunCB.Initialize(PAD16(sizeof(ZShadeSandboxLighting::cbSunLightBuffer)));
	m_pSunCB = sunCB.Buffer();
	
	ClearInputLayout();
	
	SetInputLayoutDesc("TriMaterialTessellationShader", ZShadeSandboxMesh::VertexLayout::mesh_layout_pos_normal_tex, 3);
	
	LoadVertexShader("MaterialTessellationShaderVS");
	LoadHullShader("TriMaterialTessellationShaderHS");
	LoadDomainShader("TriMaterialTessellationShaderDS");
	LoadPixelShader("MaterialTessellationShaderPS");
	LoadPixelShader("MaterialTessellationShaderWireframePS");
	
	AssignVertexShaderLayout("TriMaterialTessellationShader");
	
	bFlipHorizontally = false;
	bFlipVertically = false;
	
	return true;
}
Пример #26
0
/*
================================================================================================
idRenderProgManager::LoadAllShaders()
================================================================================================
*/
void idRenderProgManager::LoadAllShaders()
{
	for( int i = 0; i < vertexShaders.Num(); i++ )
	{
		LoadVertexShader( i );
	}
	for( int i = 0; i < fragmentShaders.Num(); i++ )
	{
		LoadFragmentShader( i );
	}
	
	for( int i = 0; i < glslPrograms.Num(); ++i )
	{
		if( glslPrograms[i].vertexShaderIndex == -1 || glslPrograms[i].fragmentShaderIndex == -1 )
		{
			// RB: skip reloading because we didn't load it initially
			continue;
		}
		
		LoadGLSLProgram( i, glslPrograms[i].vertexShaderIndex, glslPrograms[i].fragmentShaderIndex );
	}
}
//==============================================================================================================================
bool TerrainTessellationQuadSSAOShader::Initialize()
{
	ConstantBuffer<cTessellationBuffer> tessellationCB(m_pD3DSystem);
	tessellationCB.Initialize(PAD16(sizeof(cTessellationBuffer)));
	m_pTessellationCB = tessellationCB.Buffer();

	ConstantBuffer<cDomainConstBuffer> domainCB(m_pD3DSystem);
	domainCB.Initialize(PAD16(sizeof(cDomainConstBuffer)));
	m_pDomainCB = domainCB.Buffer();

	ConstantBuffer<cMatrixBuffer> matrixBufferCB(m_pD3DSystem);
	matrixBufferCB.Initialize(PAD16(sizeof(cMatrixBuffer)));
	m_pMatrixBufferCB = matrixBufferCB.Buffer();

	ConstantBuffer<cShadingConstBuffer> shadingCB(m_pD3DSystem);
	shadingCB.Initialize(PAD16(sizeof(cShadingConstBuffer)));
	m_pShadingCB = shadingCB.Buffer();

	ConstantBuffer<ZShadeSandboxLighting::cbLightBuffer> lightCB(m_pD3DSystem);
	lightCB.Initialize(PAD16(sizeof(ZShadeSandboxLighting::cbLightBuffer)));
	m_pLightCB = lightCB.Buffer();

	ConstantBuffer<ZShadeSandboxLighting::cbSunLightBuffer> sunCB(m_pD3DSystem);
	sunCB.Initialize(PAD16(sizeof(ZShadeSandboxLighting::cbSunLightBuffer)));
	m_pSunCB = sunCB.Buffer();

	ClearInputLayout();
	SetInputLayoutDesc("TerrainTessellationQuadSSAOShader", ZShadeSandboxMesh::VertexLayout::mesh_layout_pos_tex, 2);

	LoadVertexShader("TerrainTessellationQuadVS");
	LoadHullShader("TerrainTessellationQuadShadowHS");
	LoadDomainShader("TerrainTessellationQuadDS");
	LoadPixelShader("TerrainTessellationNormalDepthPS");

	AssignVertexShaderLayout("TerrainTessellationQuadSSAOShader");

	return true;
}
BOOL DoInit(HWND hWnd)
{
  // Initialize Direct3D
  InitD3D(&g_pD3D, &g_pD3DDevice, hWnd);

  // Load the base mesh
  LoadMesh(&g_BaseMesh, g_pD3DDevice, "..\\Data\\Base.x", "..\\Data\\");

  // Load the collection of meshes used for demo
  LoadMesh(&g_MorphMeshes, NULL, g_pD3DDevice, "..\\Data\\Dummy.x", "..\\Data\\", MORPHFVF);

  // Load the morphing animation set and map animations to meshes
  g_MorphAnim.Load("..\\Data\\dummy.x");
  g_MorphAnim.Map(g_MorphMeshes);

  // Load the vertex shader
  LoadVertexShader(&g_VS, g_pD3DDevice, "Morph.vsh", g_MorphMeshDecl, &g_Decl);

  // Create the backdrop
  sBackdropVertex BackdropVerts[4] = {
    {   0.0f,   0.0, 1.0, 1.0f, 0.0f, 0.0f },
    { 640.0f,   0.0, 1.0, 1.0f, 1.0f, 0.0f },
    {   0.0f, 480.0, 1.0, 1.0f, 0.0f, 1.0f },
    { 640.0f, 480.0, 1.0, 1.0f, 1.0f, 1.0f }
  };
  g_pD3DDevice->CreateVertexBuffer(sizeof(BackdropVerts), D3DUSAGE_WRITEONLY, BACKDROPFVF, D3DPOOL_DEFAULT, &g_BackdropVB, NULL);
  char *Ptr;
  g_BackdropVB->Lock(0,0, (void**)&Ptr, 0);
  memcpy(Ptr, BackdropVerts, sizeof(BackdropVerts));
  g_BackdropVB->Unlock();
  D3DXCreateTextureFromFile(g_pD3DDevice, "..\\Data\\Backdrop.bmp", &g_BackdropTexture);

  // Play the song
  PlaySound("..\\Data\\dance.wav", NULL,  SND_ASYNC | SND_LOOP);

  return TRUE;
}
Пример #29
0
 void CShader::Create()
 {
     DEBUG(3, __FUNCTION__, "Compiling");
     Compile(LoadVertexShader(), LoadFragmentShader());
 }
Пример #30
0
	bool ShaderManager :: LoadVertexShader ( const char * filename, const char * prefix )
	{        
		return LoadVertexShader ( &filename, 1, prefix );
	}