문제

For a project I want to implement my own Z-buffer. I know the algorithm and how to implement this. Because I do not want to write an entire graphics engine I was planning on using OpenGL, the problem is, how can I combine my own algorithm with openGL?

I read somewhere that I could calculate everything myself and then pass the data per pixel to GLDrawPixels() but that seems a bit overkill. The point is that I don't want to implement triangulation algorithms etc..

My goal is to use openGL up until the wireframe, then use my own z-buffer algorithm and then use openGL again to draw the final picture. (for my project, the z-buffer is the only thing that matters, including light and shadows that is). Is there a way this can be done or do I have to implement everything myself and let openGL just draw the endresult?

Sincerely

도움이 되었습니까?

해결책

You could set the colour of the vertices you are drawing to their z-values by calculating their distance 'manually'. But I think it's possible to bind the z-buffer as a texture and then draw a large quad covering with screen with the z-buffer texture on it.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top