I already have found some sample codes where someone projected a terminal emulation on every side of a 3d cube. The problem is that the fonts are
mostly rendered (for example bitmaps) and are therefore not selectable.
The other point is that I would need to use some pipe to connect the 3d rendered quad with the shell (which might be accessable through popen or similar.)
If I somehow manage to create a full shell on a 3d quad, I would still have big problems selecting text.
My current approach would be to just render the input/output on the quad in 3d space.
If I would need to select text, I would have to create some alpha blending sdl-console and copy the data to the buffer of the newly created window.
This approach would reduce the problems of mouse cursor projection for selection, which already drives me nuts if i try to select an object in 3d.
(Currently, selecting works, the selection point is not on the object if I change my camera position/perspective)
Code:
void Cameraclass::sdl_mousedw(int x, int y, int but)
{
printf("\nMouse button %d pressed at %d %d\n", but, x, y);
if (but == SDL_BUTTON_LEFT)
gl_select(x,screenheight-y); //Important: gl (0,0) ist bottom left but window coords (0,0) are top left so we have to change this!
}
void Cameraclass::gl_select(int x, int y)
{
GLuint buff[64] = {0};
GLint hits, view[4];
// This choose the buffer where we store the values for the selection data
glSelectBuffer(64, buff);
// This retrieves info about the viewport
glGetIntegerv(GL_VIEWPORT, view);
// Switching in selecton mode
glRenderMode(GL_SELECT);
// Clearing the names’ stack
// This stack contains all the info about the objects
glInitNames();
// Now fill the stack with one element (or glLoadName will generate an error)
glPushName(0);
// Now modify the viewing volume, restricting selection area around the cursor
//glMatrixMode(GL_MODELVIEW); // working
glMatrixMode(GL_PROJECTION); // working
glLoadIdentity();
glPushMatrix();
// restrict the draw to an area around the cursor
gluPickMatrix(x, y, 4.0, 4.0, view);
gluPerspective(60, (float)view[2]/(float)view[3], 0.0001, 1000.0); // orig
// Draw the objects onto the screen
// draw only the names in the stack, and fill the array
DrawTargets();
glMatrixMode(GL_PROJECTION); // mod
// Do you remeber? We do pushMatrix in PROJECTION mode
glPopMatrix();
// get number of objects drawed in that area
// and return to render mode
hits = glRenderMode(GL_RENDER);
// Print a list of the objects
list_hits(hits, buff);
// uncomment this to show the whole buffer
// gl_selall(hits, buff);
glMatrixMode(GL_MODELVIEW);
}