[osg-users] Graphics context size Screen capture question

2013-09-03 Thread Christoffer Pettersson
Hello.
I'm currently implementing a screen capture functionality and I have a few 
questions regarding the GraphicsContext size and the Image::readPixels 
function. 

In the first scenario I want to create a graphics context of size 3840x1080. My 
Monitor is only 2560x1600 and the graphics context seem to clip around the 
monitor border, giving me a graphics context of roughly 2560x1080. Is there a 
way to force OSG to create a context wider than my screen resolution?

Second scenario: I have a 1920x1080 graphics context. This context will be 
shared between two cameras. What I want to do now is the following:
1. Render world as seen from camera 1 to viewport(0, 0, 1920, 1080).
2. store pixels with Image::ReadPixels in postDrawCallback
3. Render world as seen from camera 2 to viewport(0, 0, 1920, 1080).
4. store pixels with Image::ReadPixels in postDrawCallback
Unfortunately this doesn't work very well. The image I get from 
Image::ReadPixels is the same for both cameras. 

Thank you
Christoffer

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=56085#56085





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Graphics context size Screen capture question

2013-09-03 Thread Christoffer Pettersson
Hi Nick,

I'll look into the osgPoster. Thanks so much.

Update: I was able to fix the problem with 2 cameras rendering to the same 
position. In the real application I have a lot more than 2 cameras and I had 
attached the callback to the wrong camera. :)

//Christoffer

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=56088#56088





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] osgViewer takes over my standard input

2012-09-26 Thread Christoffer Pettersson
I tried switching to getline stringstream combo and also using the ignore 
statement to ignore previous content in the buffer. It still gave me the same 
non blocking result though.

I received your code, I will have a look at it, thanks :)

Kind Regards
Christoffer

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=50306#50306





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] osgViewer takes over my standard input

2012-09-25 Thread Christoffer Pettersson
Hello, I'm trying to write a program where the renderer is running on a 
separate thread. On the main thread I want to control the command line inputs 
but as soon as I add scenedata to the osgViewer which is stored in the renderer 
then the renderer takes over the standard input. std::cin in the main thread is 
ignored. If I put std::cin in the renderer thread however the program pauses 
and expects an input from the command line.

Does anyone know how I can prevent osgViewer from taking over the command line? 
I have attached sample code to this post where I demonstrate the problem.


Code:

#include 
#include 
#include 

class MiniRenderer: public OpenThreads::Thread 
{ 
public: 
void addModel(osg::Node* node) 
{ 
_nodes.push_back(node); 
} 

void run() 
{ 
_viewer.setUpViewInWindow(0, 0, 640, 480); 
_viewer.realize(); 
_sceneRoot = new osg::Group; 
_run = true; 
while(_run) 
{ 
if(_nodes.size()0) 
{ 
for(unsigned int i = 0; i  _nodes.size(); ++i) 
_sceneRoot-addChild(_nodes[i]); 
_nodes.clear(); 
_viewer.setSceneData(_sceneRoot.get()); 
} 
int test = -2; 
std::cout  In Thread:   std::endl; 
std::cin  test; 
std::cout  In Thread :   test  std::endl; 
_viewer.frame(); 
} 
} 
bool _run; 
osg::ref_ptr _sceneRoot; 
osgViewer::Viewer _viewer; 
std::vector  _nodes; 
}; 


int main( int argc, char **argv ) 
{ 
std::cout  Starting thread  std::endl; 
MiniRenderer *minirenderer = new MiniRenderer(); 
mr-startThread(); 

osg::ref_ptr root = osgDB::readNodeFile(cessna.osg); 
minirenderer-addModel(root); 
int test = -1; 

std::cout  Main cin  std::endl; 
std::cin  test; 
std::cout  Main cin:   test  std::endl; 

while(true) 
{ 

} 
return 0; 
} 




Edit: Parts of my code seem to have gone missing after I posted this, so here's 
a pastebin link with the code: 

pastebin . com / GxFAbZvf

I found one way to be able to get input from the console by using 
std::cin.clear() and std::ignore(std::numeric_limitstd::streamsize::max, 
'\n'). But this code would work in some places but not in others, so I can't 
use this since it's very unreliable..

Kind Regards
Hoffe

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=49913#49913





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] osgViewer takes over my standard input

2012-09-25 Thread Christoffer Pettersson
Hello,

This problem occurs when I run the code on an old machine with intel core 2 
duo,Nvidia quadro FX 580, 4gb ram, OS=Slackware. If I run this code on another 
machine with Intel i7-3770, AMD Radeon 7800 series (2gb), 12gb ram, OS=Red Hat 
then the code runs just fine.

Do you have any ideas as to why this older hardware does not handle this code 
properly?


 
 Using standard input is a bit unusual for a rendering application, 
 might I suggest you just read the keyboard input from the actual 
 rendering window itself?


Unfortunately this is not an option. I'm writing a test framework which depends 
on input from the console.

Kind Regards
Christoffer

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=50279#50279





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] osgViewer takes over my standard input

2012-09-25 Thread Christoffer Pettersson
hmm ok. I tried the code on another computer with specifications between the 
two computers mentioned before. This one running Slackware as well. And the 
code ran fine on this one. Theyre using the same terminal and as far as I know 
they also use the same compiler.

As I mentioned before, Writing a proper gui is not an option. The framework 
needs to be controlled from the terminal.

Kind Regards
Christoffer

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=50285#50285





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] osgViewer takes over my standard input

2012-09-25 Thread Christoffer Pettersson
Hi Robert,

That is pretty much what I'm doing, just the other way around. The main thread 
is responsible for handling standard inputs, while the second thread is 
responsible for handling the renderer. 

Hi Jorge,
That is exactly what I try to mimic using the current design :) I cant add 
network support at the moment so I need to use the sort of design I have 
presented.

Kind Regards
Christoffer

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=50290#50290





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] osgViewer takes over my standard input

2012-09-25 Thread Christoffer Pettersson
The cin in the thread is only there for demonstration purposes. It was used to 
test the blocking of the cin function. If i write cin in the render thread then 
the program is halted. If i write it in the main thread it is not halted. The 
model code is also just for demonstration. That part of the code works. It's 
essentially just there to recreate the cin problem

Kind regards
Christoffer

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=50292#50292





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] osgViewer takes over my standard input

2012-09-25 Thread Christoffer Pettersson
The cin in the render thread is not supposed to be there. They were just put 
there to see if they would block or not, which they did.  The problem i have is 
that if i write cin in any other thread than the render thread, then the thread 
containing the cin command does not block. It jumps over the cin command giving 
me an empty buffer. This happens on 1 out of the 3 computers i have tested the 
code on. On the other 2, the cin command succesfully blocks.

Kind regards 
Christoffer

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=50294#50294





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


[osg-users] osgViewer takes over my standard input

2012-09-17 Thread Christoffer Pettersson
Hello, I'm trying to write a program where the renderer is running on a 
separate thread. On the main thread I want to control the command line inputs 
but as soon as I add scenedata to the osgViewer which is stored in the renderer 
then the renderer takes over the standard input. std::cin in the main thread is 
ignored. If I put std::cin in the renderer thread however the program pauses 
and expects an input from the command line.

Does anyone know how I can prevent osgViewer from taking over the command line? 
I have attached sample code to this post where I demonstrate the problem.


Code:

#include 
#include 
#include 

class MiniRenderer: public OpenThreads::Thread 
{ 
public: 
void addModel(osg::Node* node) 
{ 
_nodes.push_back(node); 
} 

void run() 
{ 
_viewer.setUpViewInWindow(0, 0, 640, 480); 
_viewer.realize(); 
_sceneRoot = new osg::Group; 
_run = true; 
while(_run) 
{ 
if(_nodes.size()0) 
{ 
for(unsigned int i = 0; i  _nodes.size(); ++i) 
_sceneRoot-addChild(_nodes[i]); 
_nodes.clear(); 
_viewer.setSceneData(_sceneRoot.get()); 
} 
int test = -2; 
std::cout  In Thread:   std::endl; 
std::cin  test; 
std::cout  In Thread :   test  std::endl; 
_viewer.frame(); 
} 
} 
bool _run; 
osg::ref_ptr _sceneRoot; 
osgViewer::Viewer _viewer; 
std::vector  _nodes; 
}; 


int main( int argc, char **argv ) 
{ 
std::cout  Starting thread  std::endl; 
MiniRenderer *minirenderer = new MiniRenderer(); 
mr-startThread(); 

osg::ref_ptr root = osgDB::readNodeFile(cessna.osg); 
minirenderer-addModel(root); 
int test = -1; 

std::cout  Main cin  std::endl; 
std::cin  test; 
std::cout  Main cin:   test  std::endl; 

while(true) 
{ 

} 
return 0; 
} 




Kind Regards
Hoffe

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=49913#49913





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org