本文整理汇总了C++中shader函数的典型用法代码示例。如果您正苦于以下问题:C++ shader函数的具体用法?C++ shader怎么用?C++ shader使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了shader函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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;
}
示例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;
}
示例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");
}
示例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);
}
}
}
}
示例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));
}
示例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();
}
示例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 );
}
示例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();
}
示例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();
}
}
示例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);
}
}
}
示例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));
}
示例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);
}
示例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();
}