Simple non-event driven rendering question

Started by
3 comments, last by V-man 12 years, 3 months ago

[color=#000000][font=verdana, arial, helvetica, sans-serif]I am trying to write a simple program that would render a large number of 3D models (simple triangular meshes, no fancy shading or lighting), and then run some computer vision processing with each of the rendered images.[/font]

[color=#000000][font=verdana, arial, helvetica, sans-serif]I presumed it would be simple to create a function that reads in an array of triangles and a camera matrix and returns an image; however, I have been unsuccessful thus far.[/font]

[color=#000000][font=verdana, arial, helvetica, sans-serif]People have recommended GLUT to me, but I do not need many of the interactive UI features that complicate GLUT (I don't even need the image to show up on the screen). The event-driven nature of GLUT is absolutely unnecessary for me and overly complicates what I'm trying to do. All I would like is to be able to have a function my program can call, which takes in a 3D model and camera matrix, and returns an image.[/font]

[color=#000000][font=verdana, arial, helvetica, sans-serif]Does anyone have any recommendations, or could point me towards a code sample or tutorial that would show how to do something like this?[/font]

[color=#000000][font=verdana, arial, helvetica, sans-serif]Thanks![/font]

Advertisement
You can render your models, and get a reference to the actual screen (back?) buffer. I have never done this so I can't say anything beyond that, but it's a pointer on what to do.
Render the objects onto a frame buffer object and get the data from there. Basically a common render to texture.

People have recommended GLUT to me, but I do not need many of the interactive UI features that complicate GLUT (I don't even need the image to show up on the screen).

What you want is typically referred to as 'offscreen rendering'. Unfortunately, OpenGL is largely geared towards rendering images to the screen, and while there is some support for offscreen rendering, I don't know of any portable way to obtain an offscreen rendering context - you are probably going to have to get down-and-dirty with your platform's windowing API.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]


What you want is typically referred to as 'offscreen rendering'. Unfortunately, OpenGL is largely geared towards rendering images to the screen, and while there is some support for offscreen rendering, I don't know of any portable way to obtain an offscreen rendering context - you are probably going to have to get down-and-dirty with your platform's windowing API.

Mesa has a platform independent offscreen rendering layer. It's very easy to use; allocate the rendering context, pass it a user-allocated memory buffer to render to and the buffer contains the image when the rendering is complete.
If you are on Windows, the solution is to make the window non visible. Create a render buffer and render to it and get it back with a glReadPixels.

http://www.opengl.org/wiki/FAQ#Offscreen_Rendering
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

This topic is closed to new replies.

Advertisement