Closed sasmaster closed 10 years ago
See for example here (lines 273-277): https://github.com/matus-chochlik/oglplus/blob/develop/example/oglplus/030_rain.cpp
or here (297-301): https://github.com/matus-chochlik/oglplus/blob/develop/example/oglplus/027_flow.cpp
Ok,great and clearing specific buffer:
glClearBufferuiv()
?
Not done yet, I'll have a look at it in a couple of hours.
OK, commit 2c5d432adbb9fe2600a1db885748258e39e0049d adds several new functions, wrapping glClearBuffer*, which can be used in the following ways:
using oglplus;
Context gl;
const GLfloat clear_color_f = {0.7f, 0.7f, 0.7f, 0.0f};
// clear GL_COLOR DRAW_BUFFER0
gl.ClearColorBuffer(0, clear_color_f);
// clear GL_COLOR DRAW_BUFFER1
gl.ClearColorBuffer(1, clear_color_f);
//
// and also
// clear GL_BACK DRAW_BUFFER0
gl.ClearColorBuffer(ColorBuffer::Back, 0, clear_color_f);
// clear GL_LEFT DRAW_BUFFER4
gl.ClearColorBuffer(ColorBuffer::Left, 4, clear_color_f);
// etc... versions for GLint[] and GLuint are also available
//
// depth / stencil:
gl.ClearDepthBuffer(1.0f);
gl.ClearStencilBuffer(0);
gl.ClearDepthStencil(1.0f, 2);
I see also there is a lack of Buffer flag - GL_MAP_INVALIDATE_BUFFER_BIT .I found only read and write.I need to do smth like that:
glMapBufferRange(GL_UNIFORM_BUFFER, 0, NUM_INSTANCES) * sizeof(mat4), GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT)
Another question ,does unbindBuffer() also unmaps ?
New buffer maps bit added in commit 128b350080f80bcdc9d67231e37c912b332c1679 to use them do:
using oglplus;
BufferRawMap buf_map(
Buffer::Target::Uniform,
offs, size,
BufferMapAccess::Write|
BufferMapAccess::InvalidateBuffer
);
// use buf_map here.. will be unmapped when buf_map goes out of scope
oglplus::Buffer::Unbind(target) binds the name 0 to the specified target. It does not explicitly unbind any maps.
As far as I recall the OpenGL specs on buffer mapping, the unmapping should be controlled separately. The thing is, while the buffer stays mapped it can't be used till it's unmapped. So for example if I update the data of the buffer during the render loop, I must unmap it before binding it to the shader stage. On Jan 12, 2014 10:16 AM, "Matus Chochlik" notifications@github.com wrote:
New buffer maps bit added in commit 128b350https://github.com/matus-chochlik/oglplus/commit/128b350080f80bcdc9d67231e37c912b332c1679to use them do:
using oglplus; BufferRawMap buf_map( Buffer::Target::Uniform, offs, size, BufferMapAccess::Write| BufferMapAccess::InvalidateBuffer ); // use buf_map here.. will be unmapped when buf_map goes out of scope
oglplus::Buffer::Unbind(target) binds the name 0 to the specified target. It does not explicitly unbind any maps.
— Reply to this email directly or view it on GitHubhttps://github.com/matus-chochlik/oglplus/issues/45#issuecomment-32117665 .
Put the buffer map into a separate block:
Buffer buffer;
BufferTarget target = ...
buffer.Bind(Target)
{
BufferRawMap buf_map(target, offs, size, map_bits);
// do whatever you need with the map
// when the map goes out of scope here it gets unmapped
}
Buffer::Unbind(target);
Ok, I've added another option. You can explicitly unmap the buffer before it is destroyed by calling BufferRawMap::Unmap() as in:
Buffer buffer;
BufferTarget target = ...
buffer.Bind(target)
BufferRawMap buf_map(target, offs, size, map_bits);
// do whatever you need with the map
buf_map.Unmap();
Buffer::Unbind(target);
That's great! Thanks.
On Sun, Jan 12, 2014 at 3:18 PM, Matus Chochlik notifications@github.comwrote:
Ok, I've added another option. You can explicitly unmap the buffer before it is destroyed by calling BufferRawMap::Unmap() as in:
Buffer buffer; BufferTarget target = ...
buffer.Bind(target) BufferRawMap buf_map(target, offs, size, map_bits); // do whatever you need with the map buf_map.Unmap(); Buffer::Unbind(target);
— Reply to this email directly or view it on GitHubhttps://github.com/matus-chochlik/oglplus/issues/45#issuecomment-32122244 .
Michael Ivanov Independent Pixel Commander onlygraphix.com Tel:+972 54 4962254
NP
Sorry Matus, from where should I pull it?
On Sun, Jan 12, 2014 at 8:22 PM, Matus Chochlik notifications@github.comwrote:
Closed #45 https://github.com/matus-chochlik/oglplus/issues/45.
— Reply to this email directly or view it on GitHubhttps://github.com/matus-chochlik/oglplus/issues/45 .
Michael Ivanov Independent Pixel Commander onlygraphix.com Tel:+972 54 4962254
It's on the develop branch.
Btw, where did you learn such a level of meta programming?. I am still trying to figure out how your uniforms template works ....Especially how you decay uniform params to specific glUniform ... On Jan 13, 2014 7:18 PM, "Matus Chochlik" notifications@github.com wrote:
It's on the develop branch.
— Reply to this email directly or view it on GitHubhttps://github.com/matus-chochlik/oglplus/issues/45#issuecomment-32189985 .
I started by playing with Loki, then Boost MPL, Fusion, Lambda, Phoenix & Co. and then I started working on the Mirror reflection utilities: here is a older version: http://kifri.fri.uniza.sk/~chochlik/mirror-lib/html/
and here a yet unfinished attempt at rewriting it: https://github.com/matus-chochlik/mirror
Hmm, thanks. Will check it out. I bought "Advanced C++ meta programming " .but it doesn't explain some stuff I see in OGLPlus. On Jan 24, 2014 1:17 PM, "Matus Chochlik" notifications@github.com wrote:
I started by playing with Loki, then Boost MPL, Fusion, Lambda, Phoenix & Co. and then I started working on the Mirror reflection utilities: here is a older version: http://kifri.fri.uniza.sk/~chochlik/mirror-lib/html/
and here a yet unfinished attempt at rewriting it: https://github.com/matus-chochlik/mirror
— Reply to this email directly or view it on GitHubhttps://github.com/matus-chochlik/oglplus/issues/45#issuecomment-33215025 .
The Uniform and and also VertexAttrib functions are selected in the following way:
The GL naming convention is quite intelligent so the various Uniform*
and VertexAttrib*
functions are wrapped by the OGLPLUS_AUX_VARPARA_*_FNS
macros into functions with the same name but with additional parameters that help to select the data type of the function and the number of values that the function accepts. These generated functions are then called from inside of the Uniform::Set functions, where you know what is the template parameter of the Uniform template.
Well, for me it wasn't clear how the proper macro variation being selected as I see you print them all into the class template . So the compiler then removes all the rest which don't fit template incoming parameters? On Jan 24, 2014 1:38 PM, "Matus Chochlik" notifications@github.com wrote:
The Uniform and and also VertexAttrib functions are selected in the following way: The GL naming convention is quite intelligent so the various Uniform* and VertexAttrib* functions are wrapped by the OGLPLUS_AUXVARPARA*_FNSmacros into functions with the same name but with additional parameters that help to select the data type of the function and the number of values that the function accepts. These generated functions are then called from inside of the Uniform::Set functions, where you know what is the template parameter of the Uniform template.
— Reply to this email directly or view it on GitHubhttps://github.com/matus-chochlik/oglplus/issues/45#issuecomment-33216158 .
Yeah, the functions are all there in the UniformSetters / VertexAttribSetters and the right ones get called based on what type of Uniform<T>
s are used in your code.
Hi Matus.Are there examples how to setup separate shader object programs?
On Fri, Jan 24, 2014 at 1:49 PM, Matus Chochlik notifications@github.comwrote:
Yeah, the functions are all there in the UniformSetters / VertexAttribSetters and the right ones get called based on what type of Uniform
s are used in your code. Reply to this email directly or view it on GitHubhttps://github.com/matus-chochlik/oglplus/issues/45#issuecomment-33216821 .
Michael Ivanov Independent Pixel Commander onlygraphix.com Tel:+972 54 4962254
Ok,I think I found it - example 024
On Wed, Feb 5, 2014 at 9:24 PM, Michael IV explomaster@gmail.com wrote:
Hi Matus.Are there examples how to setup separate shader object programs?
On Fri, Jan 24, 2014 at 1:49 PM, Matus Chochlik notifications@github.comwrote:
Yeah, the functions are all there in the UniformSetters / VertexAttribSetters and the right ones get called based on what type of Uniform
s are used in your code. Reply to this email directly or view it on GitHubhttps://github.com/matus-chochlik/oglplus/issues/45#issuecomment-33216821 .
Michael Ivanov Independent Pixel Commander onlygraphix.com Tel:+972 54 4962254
Michael Ivanov Independent Pixel Commander onlygraphix.com Tel:+972 54 4962254
Sorry for not responding sooner, I was out of office and I'm quite busy with other things lately :-/ Yes, there are several examples using separate shader objects and program pipelines for example: https://github.com/matus-chochlik/oglplus/blob/develop/example/oglplus/024_extruded_torus.cpp https://github.com/matus-chochlik/oglplus/blob/develop/example/oglplus/029_shadow_mapping.cpp https://github.com/matus-chochlik/oglplus/blob/develop/example/oglplus/031_sketch.cpp https://github.com/matus-chochlik/oglplus/blob/develop/example/oglplus/033_metal_and_glass.cpp https://github.com/matus-chochlik/oglplus/blob/develop/example/oglplus/034_billiard_balls.cpp etc.
Hi Matus.Did you add my deferred renderer to the examples?
On Wed, Feb 5, 2014 at 11:20 PM, Matus Chochlik notifications@github.comwrote:
Sorry for not responding sooner, I was out of office and I'm quite busy with other things lately :-/ Yes, there are several examples using separate shader objects and program pipelines for example:
https://github.com/matus-chochlik/oglplus/blob/develop/example/oglplus/024_extruded_torus.cpp
https://github.com/matus-chochlik/oglplus/blob/develop/example/oglplus/029_shadow_mapping.cpp
https://github.com/matus-chochlik/oglplus/blob/develop/example/oglplus/031_sketch.cpp
https://github.com/matus-chochlik/oglplus/blob/develop/example/oglplus/033_metal_and_glass.cpp
Reply to this email directly or view it on GitHubhttps://github.com/matus-chochlik/oglplus/issues/45#issuecomment-34247796 .
Michael Ivanov Independent Pixel Commander onlygraphix.com Tel:+972 54 4962254
Hi Michael, I've got it half-integrated on a local branch on one of my machines, but it is not ready yet. I'll need to do some larger updates to the build system, because right now it builds only with g++. I have however, in the meantime added a link to your article to the http://oglplus.org/ website.
No problem.let me know if you need any help.
On Sun, Feb 23, 2014 at 6:42 PM, Matus Chochlik notifications@github.comwrote:
Hi Michael, I've got it half-integrated on a local branch on one of my machines, but it is not ready yet. I'll need to do some larger updates to the build system, because right now it builds only with g++. I have however, in the meantime added a link to your article to the http://oglplus.org/ website.
Reply to this email directly or view it on GitHubhttps://github.com/matus-chochlik/oglplus/issues/45#issuecomment-35835866 .
Michael Ivanov Independent Pixel Commander onlygraphix.com Tel:+972 54 4962254
Hi! I can't find how I can do this with OGLPlus: static const GLenum draw_buffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 };
glDrawBuffers(2, draw_buffers);
I found gl.DrawBuffers() accepts ColorBuffer which has no enums for color attachments.