Skip to content

Commit 331c43d

Browse files
committed
Tutorials - clean the framebuffer access demo
1 parent 4c57eb2 commit 331c43d

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

tutorials/31_framebuffer_access/main.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,18 +192,20 @@ int main()
192192
//
193193
// We are going to take the frame_buffer_resolved data, and use it as a material texture for a plane.
194194

195+
// access framebuffer data.
195196
size_t size = 0;
196197
CHECK(rprFrameBufferGetInfo(frame_buffer_resolved, RPR_FRAMEBUFFER_DATA, 0, NULL, &size));
197198
float* buffer = new float[size / sizeof(float)];
198199
CHECK(rprFrameBufferGetInfo(frame_buffer_resolved, RPR_FRAMEBUFFER_DATA, size, buffer, 0));
199200

200201

201-
//Apply this buffer as a texture
202+
//Apply this data as a texture material to the plane.
202203

203204
rpr_material_node diffuse1=nullptr;
204205
rpr_material_node tex=nullptr;
205206
rpr_image img1=nullptr;
206207
{
208+
// create the image from the data of the previous framebuffer
207209
rpr_image_format format;
208210
format.num_components = 4;
209211
format.type = RPR_COMPONENT_TYPE_FLOAT32;
@@ -213,17 +215,21 @@ int main()
213215
desc2.image_row_pitch = 0;
214216
desc2.image_slice_pitch = 0;
215217
desc2.image_depth = 0;
216-
217218
CHECK(rprContextCreateImage(context, format, &desc2, buffer, &img1));
219+
220+
// create the image sampler material
218221
CHECK(rprMaterialSystemCreateNode(matsys, RPR_MATERIAL_NODE_IMAGE_TEXTURE, &tex));
222+
219223
// Set image data
220224
CHECK(rprMaterialNodeSetInputImageDataByKey(tex, RPR_MATERIAL_INPUT_DATA, img1));
221-
CHECK(rprMaterialSystemCreateNode(matsys, RPR_MATERIAL_NODE_DIFFUSE, &diffuse1));
222-
// Set diffuse color parameter to gray
223225

226+
// create a simple diffuse material
227+
CHECK(rprMaterialSystemCreateNode(matsys, RPR_MATERIAL_NODE_DIFFUSE, &diffuse1));
228+
229+
// apply the built texture as color
224230
CHECK(rprMaterialNodeSetInputNByKey(diffuse1, RPR_MATERIAL_INPUT_COLOR, tex));
225-
//CHECK(rprMaterialNodeSetInputFByKey(diffuse1, RPR_MATERIAL_INPUT_COLOR, 1,0,0,0));
226-
231+
232+
// plane now uses this diffuse as material.
227233
CHECK(rprShapeSetMaterial(plane, diffuse1));
228234
}
229235

0 commit comments

Comments
 (0)