View Full Version : How to draw an image from openCL?
07-09-2011, 10:08 AM
Hi, im trying to do a 3D engine. I want to do most of the engine math on the GPU, so im using openCL. The problem im having is, how to get the image from video memory on my screen? Copying to host memory is too slow to get atleast 60fps. OpenCL does not seem to have any direct drawing functions. I found something about sharing a texture with OpenGL and then let OpenGL draw it. But after exploring OpenGL a bit .. that is really not the way I would like to do it(too complicated as my knowledge of OpenGL is close to 0). Also I couldnt find any simple tutorial on how to do it. All tutorials have 500-2000 lines of code, multiple source code files.. and do a lot of other stuff I dont need/understand.
So is there actualy any simple solution .. or a simple tutorial for C++ or Java on how to do it?.
07-10-2011, 11:30 PM
I think that sharing a texture with OpenGL is the simple solution to rendering images generated in OpenCL.
I'm wondering a bit about what you are really trying to do. You say you want to make a 3D engine, but don't want to use OpenGL because its to complicated so you choose OpenCL instead. I don't see how it could be any less complicated using OpenCL since OpenGL is designed to do 3D rendering and OpenCL is not.
07-11-2011, 06:41 AM
I meant complicated to do it because I first have to learn openGL, and then the image sharing. (lots of work/time consuming, due to the lack of simple tutorials as I mentioned)
The thing is, I want to build a 3D engine from the botom up. All the math, and then have full power to adjust things/rendering algorythms as I need.(openGL is an API that does all the stuff for you) The only reason I want to use openCL is to get extra power from GPU, since rendering a sceene on a higher resolution is a killer for the CPU.
Ps: if you have any experience with image sharing for C++, got any links for usefull tutorials or something to learn it? .. I only found sufficient tutorials for C# and the code didint look like anything I could write into C++
07-12-2011, 04:17 AM
So this is more of a project for learning vector algebra, geometry, trigonometry, and compute science rather than with the purpose of producing something that will be useful^* later? I don't know what you would want to do that would be easier to implement as a complete rendering engine in OpenCL compared to learning OpenGL and how to set that up to do whatever it is that you want to do.
Whatever the case, I know of no way to render directly from OpenCL, so sharing a texture with OpenGL is still the way to go even if this is the only thing you need OpenGL for. Someone who knows of other ways should let us know.
Regarding tutorials, I have never used image sharing myself and thus never looked for one but I can see what I can do tonight.
* Don't take my choice of wording here to hardly. There might be circumstances where the extra generality of a OpenCL renderer over OpenGL is required, but I've seen some complicated stuff done with OpenGL as well.
07-12-2011, 01:05 PM
I began trying to make a really small c++ example that renders a OpenCL generated image using OpenGL, but it turned out to require quite a bit of code. More than I can write on an evening. A decent tutorial with proper error checking and descriptive comments will likely be more than a few hundred lines of code, and will probably contain
.. multiple source code files and do a lot of other stuff I don't need/understand.
I think that the best thing you can do is to understand it.
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.