本文整理汇总了C++中VertexShader类的典型用法代码示例。如果您正苦于以下问题:C++ VertexShader类的具体用法?C++ VertexShader怎么用?C++ VertexShader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VertexShader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetMeshMaterialGOC
void GameObjectMaterialComponentsWidget::on_m_VSPropsButton_clicked()
{
if(!m_IsReady)
{
return;
}
MeshMaterialGOC* meshMat = GetMeshMaterialGOC();
if(meshMat == nullptr)
{
return;
}
VertexShader* vs = meshMat->GetVertexShaderResource();
if(vs == nullptr)
{
return;
}
ShaderProperties* vsProps = meshMat->GetVertexShaderProperties();
GameObjectShaderPropsDialog shaderPropsDiag(meshMat->GetName(), vs->GetName(), m_GameApp->GetGameAssetManager(), vsProps);
shaderPropsDiag.exec();
}
示例2: make_prog
static Program make_prog(void)
{
Program prog;
VertexShader vs;
vs.Source(
"#version 330\n"
"uniform mat4 ProjectionMatrix, CameraMatrix, ModelMatrix;"
"mat4 Matrix = ProjectionMatrix*CameraMatrix*ModelMatrix;"
"in vec4 Position;"
"void main(void)"
"{"
" gl_Position = Matrix*Position;"
"}"
);
FragmentShader fs;
fs.Source(
"#version 330\n"
"void main(void){ }"
);
prog.AttachShader(vs).AttachShader(fs);
prog.Link().Validate().Use();
return std::move(prog);
}
示例3: make
static Program make(void)
{
Program prog;
VertexShader vs;
vs.Source(
"#version 330\n"
"uniform vec2 ScreenSize;"
"in vec4 Position;"
"in vec2 TexCoord;"
"out vec2 vertTexCoord;"
"void main(void)"
"{"
" gl_Position = Position;"
" vertTexCoord = TexCoord*ScreenSize;"
"}"
).Compile();
FragmentShader fs;
fs.Source(
"#version 330\n"
"uniform sampler1D Palette;"
"uniform sampler2DRect Tex;"
"in vec2 vertTexCoord;"
"out vec4 fragColor;"
"void main(void)"
"{"
" float Overdraw = texture(Tex, vertTexCoord).r;"
" fragColor = texture(Palette, Overdraw);"
"}"
).Compile();
prog.AttachShader(vs).AttachShader(fs).Link().Use();
return std::move(prog);
}
示例4: make_vs
// Makes the common shared vertex shader
static VertexShader make_vs(void)
{
VertexShader shader;
shader.Source(
"#version 140\n"
"uniform mat4 ProjectionMatrix, CameraMatrix, ModelMatrix;"
"in vec4 Position;"
"in vec3 Normal;"
"in vec2 TexCoord;"
"out vec2 vertTexCoord;"
"out vec3 vertNormal;"
"out vec3 vertLight;"
"uniform vec3 LightPos;"
"void main(void)"
"{"
" vertTexCoord = TexCoord;"
" gl_Position = ModelMatrix * Position;"
" vertNormal = mat3(ModelMatrix)*Normal;"
" vertLight = LightPos - gl_Position.xyz;"
" gl_Position = ProjectionMatrix * CameraMatrix * gl_Position;"
"}"
);
shader.Compile();
return shader;
}
示例5:
void ShaderManager<RS>::init()
{
//construct safe default shader
VertexShader<RS>* dv = 0;
FragmentShader<RS>* df = 0;
dv = new VertexShader<RS>();
df = new FragmentShader<RS>();
Vertex def;
def.addVector3("POSITION");
def.finalize();
dv->associateVertex(def);
if(RS == RS_DX11)
{
dv->initFromDef(Defaults::shaderDefDX, Defaults::vertexFunc);
df->initFromDef(Defaults::shaderDefDX, Defaults::fragmentFunc);
}
else
{
dv->initFromDef(Defaults::shaderDefGL, Defaults::vertexFunc);
df->initFromDef(Defaults::shaderDefGL, Defaults::fragmentFunc);
}
vShaders[Defaults::mapName][Defaults::mapName] = dv;
fShaders[Defaults::mapName][Defaults::mapName] = df;
}
示例6: initalize
bool MicroManagerTest::initalize(float width, float height)
{
VertexShader vertexShader;
vertexShader.set( mData->sManager.loadVertexFromFile(&md3d, L"EngineVSPosNormalUV") );
mData->ps = mData->sManager.loadPixelFromFile(&md3d, L"PSPosNormalUV");
VertexShaderHandle modelShader = VertexShaderManager::newVertexShader( vertexShader );
md3d.getDeviceContext()->PSSetShader(mData->ps,NULL,NULL);
Procedural::MeshBuilderType mbt;
Procedural::BoxGenerator bg;
bg.addToMeshBuilder( mbt );
auto mesh = mbt.toMeshVertexCPU();
mData->model = ModelBuilder::makeStaticGeometryModel( md3d, VertexTypeManager::getVertexType(VertexTypeManager::Pos_Normal_UV), D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST, mesh->toMeshCPU() );
ModelManager::fromHandle(mData->model).mVSShader = modelShader;
mbt.clear();
Procedural::SphereGenerator sg(1,128,128);
sg.addToMeshBuilder( mbt );
auto meshSphere = mbt.toMeshVertexCPU();
mData->sphere = ModelBuilder::makeStaticGeometryModel( md3d, VertexTypeManager::getVertexType(VertexTypeManager::Pos_Normal_UV), D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST, meshSphere->toMeshCPU() );
ModelManager::fromHandle(mData->sphere).mVSShader = modelShader;
mData->cam.setPerspectiveFOV( DirectX::XMConvertToRadians(45),width / height, 0.1, 500 );
mData->cam.lookAt( .0f,.0f,.0f );
mData->cam.setPosition( .0f, .0f, -30.0f );
mData->cam.setRotationEuler( .0f,.0f,.0f);
int count = 0;
MaterialHandle fakeMaterial;
// Generate the box Array and positions
for( float xPos = -10.0f; xPos < 10.0f; xPos += 2.0f )
{
for( float yPos = -10.0f; yPos < 10.0f; yPos += 2.0f )
{
count++;
BoxDemo2 bx = {xPos, yPos, 0.0f, 0.0f, 0.0f, 0.0f, mData->mang->newRi( count % 2 == 0 ? mData->model : mData->sphere, fakeMaterial )};
mData->boxes.push_back( bx );
}
}
mIsOk = true;
matrix proj;
mData->cam.getProjData( &proj );
mData->mang->displayUpdate( proj );
return mIsOk;
}
示例7: runtime_error
ShaderProgram::ShaderProgram(
const string &filename,
const VertexShader &vertexShader,
const FragmentShader &fragmentShader) : _name(filename), _handle(0), _linked(0)
{
try
{
if (vertexShader.fail()) throw std::runtime_error("Invalid vertex shader");
if (fragmentShader.fail()) throw std::runtime_error("Invalid fragment shader");
if (GLEW_VERSION_2_0)
{
// Create program and attach vertex and fragment shaders
_handle = glCreateProgram();
glAttachShader(_handle, vertexShader.handle());
glAttachShader(_handle, fragmentShader.handle());
// Perform link stage
glLinkProgram(_handle);
glGetProgramiv(_handle, GL_LINK_STATUS, &_linked);
// Validate program
glValidateProgram(_handle);
printInfoLog();
// Check for success
if (GL_FALSE == _linked)
throw std::runtime_error("Link stage failed");
}
else if (GLEW_VERSION_1_5)
{
// Create program and attach vertex and fragment shaders
_handle = glCreateProgramObjectARB();
glAttachObjectARB(_handle, vertexShader.handle());
glAttachObjectARB(_handle, fragmentShader.handle());
// Perform link stage
glLinkProgramARB(_handle);
glGetObjectParameterivARB(_handle, GL_OBJECT_LINK_STATUS_ARB, &_linked);
// Validate program
glValidateProgramARB(_handle);
printInfoLog();
// Check for success
if (GL_FALSE == _linked)
throw std::runtime_error("Link stage failed");
}
cout << "* Shader \"" << _name << "\" successfully linked" << endl;
}
catch (std::runtime_error &err)
{
cerr << "Error: Faild to create shader " << _name << endl;
cerr << "Reason: " << err.what() << endl;
}
}
示例8: make_prog
static Program make_prog(void)
{
VertexShader vs;
vs.Source(
"#version 130\n"
"uniform mat4 ProjectionMatrix, ModelMatrix, CameraMatrix;"
"uniform vec4 ClipPlane;"
"attribute vec4 Position;"
"attribute vec2 TexCoord;"
"varying vec2 vertTexCoord;"
"void main(void)"
"{"
" vertTexCoord = TexCoord;"
" gl_Position = "
" ModelMatrix *"
" Position;"
" gl_ClipDistance[0] = dot(ClipPlane, gl_Position);"
" gl_Position = "
" ProjectionMatrix *"
" CameraMatrix *"
" gl_Position;"
"}"
);
vs.Compile();
FragmentShader fs;
fs.Source(
"#version 130\n"
"varying vec2 vertTexCoord;"
"void main(void)"
"{"
" float i = ("
" int(vertTexCoord.x*36) % 2+"
" int(vertTexCoord.y*24) % 2"
" ) % 2;"
" if(gl_FrontFacing)"
" {"
" gl_FragColor = vec4(1-i/2, 1-i/2, 1-i/2, 1.0);"
" }"
" else"
" {"
" gl_FragColor = vec4(0+i/2, 0+i/2, 0+i/2, 1.0);"
" }"
"}"
);
fs.Compile();
Program prog;
prog.AttachShader(vs);
prog.AttachShader(fs);
prog.Link();
prog.Use();
return prog;
}
示例9: PostLink
//----------------------------------------------------------------------------
void LightAmbEffect::PostLink ()
{
VisualEffect::PostLink();
VisualPass* pass = mTechniques[0]->GetPass(0);
VertexShader* vshader = pass->GetVertexShader();
PixelShader* pshader = pass->GetPixelShader();
vshader->SetBaseRegisters(msVRegisters);
vshader->SetPrograms(msVPrograms);
pshader->SetPrograms(msPPrograms);
}
示例10:
//----------------------------------------------------------------------------
void Texture2ColorBlendEffect::PostLink ()
{
VisualEffect::PostLink();
VisualPass* pass = mTechniques[0]->GetPass(0);
VertexShader* vshader = pass->GetVertexShader();
PixelShader* pshader = pass->GetPixelShader();
vshader->SetBaseRegisters(msVRegisters);
vshader->SetPrograms(msVPrograms);
pshader->SetTextureUnits(msPTextureUnits);
pshader->SetPrograms(msPPrograms);
}
示例11: kIStr
//----------------------------------------------------------------------------
VertexShader* VertexShader::Load (const char* acFilename)
{
// open stream, load
ifstream kIStr(acFilename,ios::in|ios::binary);
if ( !kIStr )
return NULL;
VertexShader* pkShader = new VertexShader;
pkShader->Read(kIStr);
kIStr.close();
return pkShader;
}
示例12: PostLink
//----------------------------------------------------------------------------
void JunglerMaterial::PostLink ()
{
Material::PostLink();
MaterialPass* pass = mTechniques[0]->GetPass(0);
VertexShader* vshader = pass->GetVertexShader();
PixelShader* pshader = pass->GetPixelShader();
vshader->SetBaseRegisters(msVRegisters);
vshader->SetPrograms(msVPrograms);
pshader->SetTextureUnits(msPTextureUnits);
pshader->SetPrograms(msPPrograms);
}
示例13: CreateVertexShader
/**
* @brief
* Creates a vertex shader and sets the shader source code
*/
VertexShader *ShaderLanguage::CreateVertexShader(const String &sSourceCode, const String &sProfile, const String &sArguments, const String &sEntry)
{
// Create the vertex shader instance
VertexShader *pVertexShader = CreateVertexShader();
// Set the vertex shader source code
if (pVertexShader)
pVertexShader->SetSourceCode(sSourceCode, sProfile, sArguments, sEntry);
// Return the created vertex shader instance
return pVertexShader;
}
示例14: VertexShader
//----------------------------------------------------------------------------
VertexColor4TextureEffect::VertexColor4TextureEffect (
Shader::SamplerFilter filter, Shader::SamplerCoordinate coordinate0,
Shader::SamplerCoordinate coordinate1)
{
VertexShader* vshader = new0 VertexShader("Wm5.VertexColorTexture",
3, 3, 1, 0, false);
vshader->SetInput(0, "modelPosition", Shader::VT_FLOAT3,
Shader::VS_POSITION);
vshader->SetInput(1, "modelTCoord", Shader::VT_FLOAT2,
Shader::VS_TEXCOORD0);
vshader->SetInput(2, "modelColor", Shader::VT_FLOAT4,
Shader::VS_COLOR0);
vshader->SetOutput(0, "clipPosition", Shader::VT_FLOAT4,
Shader::VS_POSITION);
vshader->SetOutput(1, "vertexTCoord", Shader::VT_FLOAT2,
Shader::VS_TEXCOORD0);
vshader->SetOutput(2, "vertexColor", Shader::VT_FLOAT4,
Shader::VS_COLOR0);
vshader->SetConstant(0, "PVWMatrix", 4);
vshader->SetBaseRegisters(msVRegisters);
vshader->SetPrograms(msVPrograms);
PixelShader* pshader = new0 PixelShader("Wm5.VertexColorTexture",
2, 1, 0, 1, false);
pshader->SetInput(0, "vertexColor", Shader::VT_FLOAT4,
Shader::VS_COLOR0);
pshader->SetInput(1, "vertexTCoord", Shader::VT_FLOAT2,
Shader::VS_TEXCOORD0);
pshader->SetOutput(0, "pixelColor", Shader::VT_FLOAT4,
Shader::VS_COLOR0);
pshader->SetSampler(0, "BaseSampler", Shader::ST_2D);
pshader->SetFilter(0, filter);
pshader->SetCoordinate(0, 0, coordinate0);
pshader->SetCoordinate(0, 1, coordinate1);
pshader->SetTextureUnits(msPTextureUnits);
pshader->SetPrograms(msPPrograms);
VisualPass* pass = new0 VisualPass();
pass->SetVertexShader(vshader);
pass->SetPixelShader(pshader);
pass->SetAlphaState(new0 AlphaState());
pass->SetCullState(new0 CullState());
pass->SetDepthState(new0 DepthState());
pass->SetOffsetState(new0 OffsetState());
pass->SetStencilState(new0 StencilState());
pass->SetWireState(new0 WireState());
VisualTechnique* technique = new0 VisualTechnique();
technique->InsertPass(pass);
InsertTechnique(technique);
}
示例15: VertexShader
//----------------------------------------------------------------------------
LightSptPerPixEffect::LightSptPerPixEffect ()
{
VertexShader* vshader = new0 VertexShader("Wm5.LightSptPerPix",
2, 3, 1, 0, false);
vshader->SetInput(0, "modelPosition", Shader::VT_FLOAT3,
Shader::VS_POSITION);
vshader->SetInput(1, "modelNormal", Shader::VT_FLOAT3,
Shader::VS_TEXCOORD1);
vshader->SetOutput(0, "clipPosition", Shader::VT_FLOAT4,
Shader::VS_POSITION);
vshader->SetOutput(1, "vertexPosition", Shader::VT_FLOAT3,
Shader::VS_TEXCOORD0);
vshader->SetOutput(2, "vertexNormal", Shader::VT_FLOAT3,
Shader::VS_TEXCOORD1);
vshader->SetConstant(0, "PVWMatrix", 4);
vshader->SetBaseRegisters(msVRegisters);
vshader->SetPrograms(msVPrograms);
PixelShader* pshader = new0 PixelShader("Wm5.LightSptPerPix",
2, 1, 13, 0, false);
pshader->SetInput(0, "vertexPosition", Shader::VT_FLOAT3,
Shader::VS_TEXCOORD0);
pshader->SetInput(1, "vertexNormal", Shader::VT_FLOAT3,
Shader::VS_TEXCOORD1);
pshader->SetOutput(0, "pixelColor", Shader::VT_FLOAT4,
Shader::VS_COLOR0);
pshader->SetConstant(0, "WMatrix", 4);
pshader->SetConstant(1, "CameraModelPosition", 1);
pshader->SetConstant(2, "MaterialEmissive", 1);
pshader->SetConstant(3, "MaterialAmbient", 1);
pshader->SetConstant(4, "MaterialDiffuse", 1);
pshader->SetConstant(5, "MaterialSpecular", 1);
pshader->SetConstant(6, "LightModelPosition", 1);
pshader->SetConstant(7, "LightModelDirection", 1);
pshader->SetConstant(8, "LightAmbient", 1);
pshader->SetConstant(9, "LightDiffuse", 1);
pshader->SetConstant(10, "LightSpecular", 1);
pshader->SetConstant(11, "LightSpotCutoff", 1);
pshader->SetConstant(12, "LightAttenuation", 1);
pshader->SetBaseRegisters(msPRegisters);
pshader->SetPrograms(msPPrograms);
VisualPass* pass = new0 VisualPass();
pass->SetVertexShader(vshader);
pass->SetPixelShader(pshader);
pass->SetAlphaState(new0 AlphaState());
pass->SetCullState(new0 CullState());
pass->SetDepthState(new0 DepthState());
pass->SetOffsetState(new0 OffsetState());
pass->SetStencilState(new0 StencilState());
pass->SetWireState(new0 WireState());
VisualTechnique* technique = new0 VisualTechnique();
technique->InsertPass(pass);
InsertTechnique(technique);
}