本文整理汇总了C++中shader函数的典型用法代码示例。如果您正苦于以下问题:C++ shader函数的具体用法?C++ shader怎么用?C++ shader使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了shader函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: trace
color trace(ray * primary) {
if (primary->depth > 0) {
VNorm(&primary->d);
reset_intersection(primary->intstruct);
intersect_objects(primary);
return shader(primary);
}
/* if ray is truncated, return the background as its color */
return primary->scene->background;
}
开发者ID:BigR-Lab,项目名称:CodeRes_Cpp,代码行数:11,代码来源:trace_rest.cpp
示例2: py_glGetShaderInfoLog
static PyObject* py_glGetShaderInfoLog(PyObject *, PyObject *args) {
CHECK_ARG_COUNT(args, 1);
Uint shader(PyTuple_GetItem(args, 0));
GLint len=0;
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &len);
//GLchar *log = new GLchar[len+1];
Array1D<Char> log(len+1);
glGetShaderInfoLog(shader, len, NULL, log);
return PyString_FromString(log);
//delete[] log;
}
开发者ID:gatgui,项目名称:pygl,代码行数:11,代码来源:gl_2_0.cpp
示例3: py_glGetShaderSource
static PyObject* py_glGetShaderSource(PyObject *, PyObject *args) {
CHECK_ARG_COUNT(args, 1);
Uint shader(PyTuple_GetItem(args, 0));
GLint len=0;
glGetShaderiv(shader, GL_SHADER_SOURCE_LENGTH, &len);
//GLchar *src = new GLchar[len+1];
Array1D<Char> src(len+1);
glGetShaderSource(shader, len, NULL, src);
return PyString_FromString(src);
//delete[] src;
}
开发者ID:gatgui,项目名称:pygl,代码行数:11,代码来源:gl_2_0.cpp
示例4: ShaderFromLiteral
inline Shader ShaderFromLiteral(
ShaderType shader_type,
const char* lit,
size_t size
)
{
Shader shader(shader_type);
shader.Source(StrCRef(lit, size));
shader.Compile();
return shader;
}
开发者ID:AdamSimpson,项目名称:oglplus,代码行数:11,代码来源:shader_literals.hpp
示例5: CoreParticleSystem
inline CoreParticleSystem(CoreEngine* engine, CoreNode* parent) :
engine_(engine),
parent_(parent),
life_(0.0f),
type_(ET_POINT),
accumulator_(0.0f),
frame_id_(0),
inherit_velocity_(true) {
shader("Particle");
}
开发者ID:mfichman,项目名称:jet-game-engine,代码行数:11,代码来源:CoreParticleSystem.hpp
示例6: Vec3f
void TinyRenderer::renderObjectDepth(TinyRenderObjectData& renderData)
{
int width = renderData.m_rgbColorBuffer.get_width();
int height = renderData.m_rgbColorBuffer.get_height();
Vec3f light_dir_local = Vec3f(renderData.m_lightDirWorld[0], renderData.m_lightDirWorld[1], renderData.m_lightDirWorld[2]);
float light_distance = renderData.m_lightDistance;
Model* model = renderData.m_model;
if (0 == model)
return;
renderData.m_viewportMatrix = viewport(0, 0, width, height);
float* shadowBufferPtr = (renderData.m_shadowBuffer && renderData.m_shadowBuffer->size()) ? &renderData.m_shadowBuffer->at(0) : 0;
int* segmentationMaskBufferPtr = 0;
TGAImage depthFrame(width, height, TGAImage::RGB);
{
// light target is set to be the origin, and the up direction is set to be vertical up.
Matrix lightViewMatrix = lookat(light_dir_local * light_distance, Vec3f(0.0, 0.0, 0.0), Vec3f(0.0, 0.0, 1.0));
Matrix lightModelViewMatrix = lightViewMatrix * renderData.m_modelMatrix;
Matrix lightViewProjectionMatrix = renderData.m_projectionMatrix;
Vec3f localScaling(renderData.m_localScaling[0], renderData.m_localScaling[1], renderData.m_localScaling[2]);
DepthShader shader(model, lightModelViewMatrix, lightViewProjectionMatrix, renderData.m_modelMatrix, localScaling, light_distance);
for (int i = 0; i < model->nfaces(); i++)
{
for (int j = 0; j < 3; j++)
{
shader.vertex(i, j);
}
mat<4, 3, float> stackTris[3];
b3AlignedObjectArray<mat<4, 3, float> > clippedTriangles;
clippedTriangles.initializeFromBuffer(stackTris, 0, 3);
bool hasClipped = clipTriangleAgainstNearplane(shader.varying_tri, clippedTriangles);
if (hasClipped)
{
for (int t = 0; t < clippedTriangles.size(); t++)
{
triangleClipped(clippedTriangles[t], shader.varying_tri, shader, depthFrame, shadowBufferPtr, segmentationMaskBufferPtr, renderData.m_viewportMatrix, renderData.m_objectIndex);
}
}
else
{
triangle(shader.varying_tri, shader, depthFrame, shadowBufferPtr, segmentationMaskBufferPtr, renderData.m_viewportMatrix, renderData.m_objectIndex);
}
}
}
}
开发者ID:bulletphysics,项目名称:bullet3,代码行数:54,代码来源:TinyRenderer.cpp
示例7: canAttachDetachShader
void canAttachDetachShader()
{
ShaderProgram shaderProgram;
Shader shader(Shader::FRAGMENT_SHADER);
QVERIFY(shaderProgram.attach(shader));
QVERIFY(shaderProgram.has(shader));
QVERIFY(shaderProgram.detach(shader));
QVERIFY(!shaderProgram.has(shader));
}
开发者ID:spoonless,项目名称:shadercreator,代码行数:12,代码来源:shaderprogramtest.cpp
示例8: outlineShader
//----------
void Scene::drawOutlines() {
ofShader & outlineShader(shader("outlineIndex"));
outlineShader.begin();
outlineShader.setUniform1i("elementHover", this->elementUnderCursor);
outlineShader.setUniform1i("nodeSelection", this->nodeSelected);
outlineShader.setUniform1i("nodeHover", this->nodeUnderCursor);
outlineShader.setUniformTexture("texIndex", indexBuffer, 2);
outlineShader.setUniform1i("elementCount", this->elements.size());
outlineShader.setUniform1f("indexScaling", GRABSCENE_INDEX_SCALE);
drawFullscreen(indexBuffer);
outlineShader.end();
}
开发者ID:elliotwoods,项目名称:ofxGrabScene,代码行数:13,代码来源:Scene.cpp
示例9: switch
Color<real> MaterialShader<real>::Shade()
{
// Create the shader depending on the material type
switch( mMaterial.GetMaterialType() )
{
case Material::TypeBlinnPhong:
{
BlinnPhongShader<real> shader( mRayTracer, mScene , static_cast<const BlinnPhongMaterial<real>&>( mMaterial ), mRay, mIntersection, mRecursionDepth );
return shader.Shade();
}
case Material::TypeEnvironment:
{
EnvironmentShader<real> shader( mRayTracer, mScene , static_cast<const EnvironmentMaterial<real>&>( mMaterial ), mRay, mIntersection, mRecursionDepth );
return shader.Shade();
}
}
// If the shader doesn't exist (should never get there)
return Color<real>( 0, 0, 0, 1 );
}
开发者ID:gnuvince,项目名称:ift3355-tp2,代码行数:21,代码来源:MaterialShader.cpp
示例10: bufferVBO
void BoundingBox::draw()
{
// bind the buffers
bufferVBO().bind();
bufferIBO().bind();
// enable the shader attributes (our buffers)
shader()->enableAttributeArray(vertexLocation());
shader()->enableAttributeArray(colorLocation());
// set our buffers into shader
shader()->setAttributeBuffer(vertexLocation(), GL_FLOAT, 0, 3, sizeof(Vertex));
shader()->setAttributeBuffer(colorLocation(), GL_FLOAT, 12, 4, sizeof(Vertex));
// draw primitives
glDrawElements(GL_LINES, indexCount(), GL_UNSIGNED_SHORT, 0);
// disable the shader attributes (our buffers)
shader()->disableAttributeArray(vertexLocation());
shader()->disableAttributeArray(colorLocation());
// release the buffers
bufferVBO().release();
bufferIBO().release();
}
开发者ID:hsimpson,项目名称:qparticles,代码行数:27,代码来源:boundingbox.cpp
示例11: thread_run
void thread_run(DeviceTask *task)
{
flush_texture_buffers();
if(task->type == DeviceTask::FILM_CONVERT) {
film_convert(*task, task->buffer, task->rgba_byte, task->rgba_half);
}
else if(task->type == DeviceTask::SHADER) {
shader(*task);
}
else if(task->type == DeviceTask::RENDER) {
RenderTile tile;
DenoisingTask denoising(this);
/* Allocate buffer for kernel globals */
device_only_memory<KernelGlobalsDummy> kgbuffer(this, "kernel_globals");
kgbuffer.alloc_to_device(1);
/* Keep rendering tiles until done. */
while(task->acquire_tile(this, tile)) {
if(tile.task == RenderTile::PATH_TRACE) {
assert(tile.task == RenderTile::PATH_TRACE);
scoped_timer timer(&tile.buffers->render_time);
split_kernel->path_trace(task,
tile,
kgbuffer,
*const_mem_map["__data"]);
/* Complete kernel execution before release tile. */
/* This helps in multi-device render;
* The device that reaches the critical-section function
* release_tile waits (stalling other devices from entering
* release_tile) for all kernels to complete. If device1 (a
* slow-render device) reaches release_tile first then it would
* stall device2 (a fast-render device) from proceeding to render
* next tile.
*/
clFinish(cqCommandQueue);
}
else if(tile.task == RenderTile::DENOISE) {
tile.sample = tile.start_sample + tile.num_samples;
denoise(tile, denoising, *task);
task->update_progress(&tile, tile.w*tile.h);
}
task->release_tile(tile);
}
kgbuffer.free();
}
}
开发者ID:mgschwan,项目名称:blensor,代码行数:52,代码来源:opencl_split.cpp
示例12: thread_run
void thread_run(DeviceTask *task)
{
if(task->type == DeviceTask::FILM_CONVERT) {
film_convert(*task, task->buffer, task->rgba_byte, task->rgba_half);
}
else if(task->type == DeviceTask::SHADER) {
shader(*task);
}
else if(task->type == DeviceTask::RENDER) {
RenderTile tile;
DenoisingTask denoising(this, *task);
/* Keep rendering tiles until done. */
while(task->acquire_tile(this, tile)) {
if(tile.task == RenderTile::PATH_TRACE) {
int start_sample = tile.start_sample;
int end_sample = tile.start_sample + tile.num_samples;
for(int sample = start_sample; sample < end_sample; sample++) {
if(task->get_cancel()) {
if(task->need_finish_queue == false)
break;
}
path_trace(tile, sample);
tile.sample = sample + 1;
task->update_progress(&tile, tile.w*tile.h);
}
/* Complete kernel execution before release tile */
/* This helps in multi-device render;
* The device that reaches the critical-section function
* release_tile waits (stalling other devices from entering
* release_tile) for all kernels to complete. If device1 (a
* slow-render device) reaches release_tile first then it would
* stall device2 (a fast-render device) from proceeding to render
* next tile.
*/
clFinish(cqCommandQueue);
}
else if(tile.task == RenderTile::DENOISE) {
tile.sample = tile.start_sample + tile.num_samples;
denoise(tile, denoising);
task->update_progress(&tile, tile.w*tile.h);
}
task->release_tile(tile);
}
}
}
开发者ID:Ichthyostega,项目名称:blender,代码行数:52,代码来源:opencl_mega.cpp
示例13: glAssert
void Compass::renderAxisOutline(RenderContext& renderContext, const Mat4x4f& transformation, const Color& color) {
glAssert(glDepthMask(GL_FALSE));
glAssert(glLineWidth(3.0f));
glAssert(glPolygonMode(GL_FRONT, GL_LINE));
ActiveShader shader(renderContext.shaderManager(), Shaders::CompassOutlineShader);
shader.set("Color", color);
renderAxis(renderContext, transformation);
glAssert(glDepthMask(GL_TRUE));
glAssert(glLineWidth(1.0f));
glAssert(glPolygonMode(GL_FRONT, GL_FILL));
}
开发者ID:Gustavo6046,项目名称:TrenchBroom,代码行数:13,代码来源:Compass.cpp
示例14: set_layout
bool UnlitMaterialSystem::init(Context& context, const MaterialSystemContext& material_system_context)
{
set_layout(StandartGeometryLayout::handle);
if (!context.shader_manager.get(shader(), material_system_context.shader_name))
return false;
transform_uniform_ = context.uniform_pool.create();
UniformBuffer& uniform = context.uniform_pool.get(transform_uniform_);
UniformBufferDesc uniform_buffer_desc;
uniform_buffer_desc.size = sizeof(TransformSimpleData);
uniform_buffer_desc.unit = perframe_data_unit;
return uniform.init(uniform_buffer_desc);
}
开发者ID:icedmaster,项目名称:mhe,代码行数:13,代码来源:unlit_material_system.cpp
示例15: glGetBooleanv
//---------
void Handles::Rotate::draw() const {
if (parent == 0 || !this->enabled)
return;
GLboolean hadLighting;
glGetBooleanv(GL_LIGHTING, &hadLighting);
if (hadLighting)
ofDisableLighting();
parent->getNode().transformGL();
ofPushMatrix();
ofScale(scale, scale, scale);
ofPushStyle();
shader("fixed").begin();
this->rotateAxis();
this->setStyleFill();
fill.draw();
this->setStyleLine();
line.draw();
shader("fixed").end();
ofSetColor(255);
if (this->rollover) {
ofTranslate(0, GRABSCENE_HANDLES_RADIUS_1 + GRABSCENE_HANDLES_RADIUS_2 * 2);
ofSetDrawBitmapMode(OF_BITMAPMODE_MODEL_BILLBOARD);
ofDrawBitmapString(this->getReading(), ofPoint());
}
ofPopStyle();
ofPopMatrix();
parent->getNode().restoreTransformGL();
if (hadLighting)
ofEnableLighting();
}
开发者ID:obviousjim,项目名称:ofxGrabScene,代码行数:40,代码来源:Rotate.cpp
示例16: shader
void Application::Update()
{
Shader shader("shaders/texture.vs", "shaders/texture.frag");
Texture texture("textures/texture1.jpg");
glm::vec3 cubePositions[] = {
glm::vec3( 0.0f, 0.0f, 0.0f),
glm::vec3( 2.0f, 5.0f, -15.0f),
glm::vec3(-1.5f, -2.2f, -2.5f),
glm::vec3(-3.8f, -2.0f, -12.3f),
glm::vec3( 2.4f, -0.4f, -3.5f),
glm::vec3(-1.7f, 3.0f, -7.5f),
glm::vec3( 1.3f, -2.0f, -2.5f),
glm::vec3( 1.5f, 2.0f, -2.5f),
glm::vec3( 1.5f, 0.2f, -1.5f),
glm::vec3(-1.3f, 1.0f, -1.5f)
};
while (!m_Window.IsClosed())
{
Mesh mesh = MeshGenerator::CreateCube();
Mesh mesh2 = MeshGenerator::CreateCube();
m_Window.Update();
ProcessInput();
shader.Bind();
// Create transformations
glm::mat4 view = m_Camera.GetViewMatrix();
glm::mat4 projection = glm::perspective(glm::radians(m_Camera.GetFOV()), (GLfloat)m_Window.GetWidth() / (GLfloat)m_Window.GetHeight(), m_Camera.GetNear(), m_Camera.GetFar());
// Send matrices to the shader
shader.SetUniform("view", view);
shader.SetUniform("projection", projection);
m_Renderer.Begin();
m_Renderer.AddRenderable(cubePositions[0], glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.5f, 0.5f, 0.5f), &mesh, texture.GetID(), m_Camera.GetFrustum());
m_Renderer.AddRenderable(cubePositions[2], glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(1.0f, 1.0f, 1.0f), &mesh2, texture.GetID(), m_Camera.GetFrustum());
m_Renderer.End();
m_Renderer.Render();
}
Quit();
}
开发者ID:tnam,项目名称:MGD_Game_Engine,代码行数:51,代码来源:Application.cpp
示例17: run_ex2
int run_ex2() {
setup();
// Build and compile our shader program
// Load GLSL Shader Source from File
std::unique_ptr<Shader> shader(
Shader::LoadFromFile("bin/ch1_5_4.vert", "bin/ch1_5.frag"));
vao->bind();
{
glBindBuffer(GL_ARRAY_BUFFER, VBO);
glBufferData(GL_ARRAY_BUFFER, sizeof(vertices), vertices, GL_STATIC_DRAW);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(GLfloat),
(GLvoid *)0);
glEnableVertexAttribArray(0);
}
vao->unbind();
while (!WINDOWMANAGER.shouldCloseWindow()) {
// Check if any events have been activiated (key pressed, mouse moved etc.)
// and call corresponding response functions
glfwPollEvents();
// Render
// Clear the colorbuffer
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
shader->activate();
shader->getUniformHandler("xOffset")->uniform1f(0.5f);
vao->bind();
glDrawArrays(GL_TRIANGLES, 0, 3);
vao->unbind();
// Swap the screen buffers
WINDOWMANAGER.swapBuffers();
GLenum err;
err = glGetError();
if (err != GL_NO_ERROR) {
LOG(ERROR) << "OpenGL error detected: 0x" << std::hex << err;
break;
}
}
glfwTerminate();
return 0;
}
开发者ID:master-g,项目名称:kocolle,代码行数:51,代码来源:ch1_5.cpp
示例18: TF_DEBUG
/*static*/
SdfPath
UsdImaging_MaterialStrategy::GetBinding(UsdShadeMaterial const& material)
{
TF_DEBUG(USDIMAGING_SHADERS).Msg("\t Look: %s\n",
material.GetPath().GetText());
// ---------------------------------------------------------------------- //
// Hydra-only shader style - displayLook:bxdf
// ---------------------------------------------------------------------- //
if (UsdRelationship matRel = UsdHydraLookAPI(material).GetBxdfRel()) {
TF_DEBUG(USDIMAGING_SHADERS).Msg("\t LookRel: %s\n",
matRel.GetPath().GetText());
UsdShadeShader shader(
UsdImaging_MaterialStrategy::GetTargetedShader(
material.GetPrim(),
matRel));
if (shader) {
TF_DEBUG(USDIMAGING_SHADERS).Msg("\t UsdShade binding found: %s\n",
shader.GetPath().GetText());
return shader.GetPath();
}
}
// ---------------------------------------------------------------------- //
// Deprecated shader style - hydraLook:Surface
// ---------------------------------------------------------------------- //
TfToken hdSurf("hydraLook:surface");
TfToken surfType("HydraPbsSurface");
if (UsdRelationship matRel = material.GetPrim().GetRelationship(hdSurf)) {
TF_DEBUG(USDIMAGING_SHADERS).Msg("\t LookRel: %s\n",
matRel.GetPath().GetText());
if (UsdPrim shader =
UsdImaging_MaterialStrategy::GetTargetedShader(
material.GetPrim(),
matRel)) {
if (TF_VERIFY(shader.GetTypeName() == surfType)) {
TF_DEBUG(USDIMAGING_SHADERS).Msg(
"\t Deprecated binding found: %s\n",
shader.GetPath().GetText());
return shader.GetPath();
}
}
}
return SdfPath::EmptyPath();
}
开发者ID:lvxejay,项目名称:USD,代码行数:52,代码来源:inheritedCache.cpp
示例19: shader
void ShaderGLTest::addFile() {
#ifndef MAGNUM_TARGET_GLES
Shader shader(Version::GL210, Shader::Type::Fragment);
#else
Shader shader(Version::GLES200, Shader::Type::Fragment);
#endif
shader.addFile(Utility::Directory::join(SHADERGLTEST_FILES_DIR, "shader.glsl"));
#ifndef MAGNUM_TARGET_GLES
CORRADE_COMPARE(shader.sources(), (std::vector<std::string>{
"#version 120\n",
"#line 1 1\n",
"void main() {}\n"
}));
#else
CORRADE_COMPARE(shader.sources(), (std::vector<std::string>{
"#version 100\n",
"#line 1 1\n",
"void main() {}\n"
}));
#endif
}
开发者ID:Driky,项目名称:magnum,代码行数:23,代码来源:ShaderGLTest.cpp
示例20: glUniform1i
CScreenSizeQuad::CScreenSizeQuad(void)
{
//generate the cube object
shader.LoadFromFile(GL_VERTEX_SHADER, "shaders/fullscreen_quad_shader.vert");
shader.LoadFromFile(GL_FRAGMENT_SHADER, "shaders/fullscreen_quad_shader.frag");
shader.CreateAndLinkProgram();
shader.Use();
shader.AddAttribute("vVertex");
shader.AddAttribute("vUV");
shader.AddUniform("textureMap");
glUniform1i(shader("textureMap"), 0);
shader.UnUse();
glm::vec2* vertices=new glm::vec2[4];
vertices[0]=glm::vec2(-1,-1);
vertices[1]=glm::vec2( 1,-1);
vertices[2]=glm::vec2( 1, 1);
vertices[3]=glm::vec2(-1, 1);
total_indices = 2*3;
GLushort* indices = new GLushort[total_indices];
int count = 0;
//fill indices array
GLushort* id=&indices[0];
*id++ = 0; *id++ = 1; *id++ = 2;
*id++ = 0; *id++ = 2; *id++ = 3;
//setup vao and vbo stuff
glGenVertexArrays(1, &vaoID);
glGenBuffers(1, &vboVerticesID);
glGenBuffers(1, &vboIndicesID);
glBindVertexArray(vaoID);
glBindBuffer (GL_ARRAY_BUFFER, vboVerticesID);
glBufferData (GL_ARRAY_BUFFER, 8*sizeof(glm::vec3), &vertices[0], GL_STATIC_DRAW);
glEnableVertexAttribArray(shader["vVertex"]);
glVertexAttribPointer(shader["vVertex"], 2, GL_FLOAT, GL_FALSE,0,0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vboIndicesID);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(GLushort)*total_indices, &indices[0], GL_STATIC_DRAW);
glBindVertexArray(0);
delete [] indices;
delete [] vertices;
}
开发者ID:EiffelOberon,项目名称:opengl33_dev_cookbook_2013,代码行数:50,代码来源:ScreenSizeQuad.cpp
注:本文中的shader函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论