OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

OSG Viewer without windowDecoration


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General [forum]
View previous topic :: View next topic  
Author Message
mkliko
Newbie


Joined: 19 May 2014
Posts: 16

PostPosted: Mon May 19, 2014 9:30 am    Post subject:
OSG Viewer without windowDecoration
Reply with quote

Hello everyone,

I'm new here to this forum, but I'm working a couple of months with OSG for now. I'm getting the hang of it, but now I am bumping into a bug or something. Let me explain:

I want a viewer without the usual windows buttons on the top right corner. (The minimize, restore and close buttons)

I found out that in OSG a function is available with osg::GraphicsContext::Traits. But, when I execute the program, all I get is a black screen. (With correct windowsize and location on screen, so that works fine).

Here is my full code:
Code:

#include <osg/Geometry>
#include <osg/DisplaySettings>
#include <osg/MatrixTransform>
#include <osg/LineWidth>
#include <osgDB/ReadFile>
#include <osgViewer/Viewer>
#include <osgGA/TrackballManipulator>

int main()
{
        osgViewer::Viewer* viewer = new osgViewer::Viewer;
        //osgViewer::CompositeViewer* viewer = new osgViewer::CompositeViewer;
        osg::ref_ptr<osg::GraphicsContext::Traits> traits = new osg::GraphicsContext::Traits;
        traits->x = 100; // In screen space, so it's the top-left corner
        traits->y = 100;
        traits->width = 640;
        traits->height = 480;
        traits->windowDecoration = false; // Removes the window's border

        osg::GraphicsContext* gc =
        osg::GraphicsContext::createGraphicsContext(traits.get());

        viewer->setSceneData(osgDB::readNodeFile("d:/openscenegraph-data/hopper.osg"));
        viewer->getCamera()->setGraphicsContext(gc);

        viewer->run();
}


NOTE: When I don't add the graphicsContext to the camera of the viewer, everything works fine. (The line before viewer->run(); ) So I think the rest of my code is not the problem.

I hope the members of this forum can help me!
Thanks in advance!

Thank you!

Cheers,
Marco


Last edited by mkliko on Mon May 19, 2014 11:08 am; edited 1 time in total
Back to top
View user's profile Send private message
mkliko
Newbie


Joined: 19 May 2014
Posts: 16

PostPosted: Mon May 19, 2014 11:07 am    Post subject:
Re: OSG Viewer without windowDecoration
Reply with quote

-- New info! --

In my console I get twice the same error:
"Error: cannot draw stage due to undefined viewport"

I think the problem is that I add graphicsContext to a camera that is not defined for the viewer. Can that be the issue?

If so, then rises the next question. How do I create a camera with the the right matrix to see my object in the right way?

Again, thanks in advance!
Back to top
View user's profile Send private message
mkliko
Newbie


Joined: 19 May 2014
Posts: 16

PostPosted: Mon May 19, 2014 11:42 am    Post subject:
Reply with quote

-- EDIT --

dived more into the viewport stuff...
Added this line after setGraphicsContext:

viewer->getCamera()->setViewport(new osg::Viewport(0, 0, 640, 480));

Now I have a default view of the cessna plane! Cool Laughing Very Happy

No keyboard or mouse input yet...

Cheers,
Marco
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General [forum] All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts Viewer slaves and RTTs Steal General 19 Fri Feb 17, 2017 7:46 pm View latest post
No new posts About Viewer->updateTraversal() Rambabu General 2 Tue Dec 27, 2016 12:05 pm View latest post
No new posts Mouse Picking with Oculus Viewer matt_kennett General 0 Tue Nov 01, 2016 5:31 am View latest post
No new posts Latest OSG cannot realize viewer unde... kornerr General 4 Wed Oct 19, 2016 2:29 pm View latest post
No new posts Explicitly synchronize all viewer cam... mille25 General 4 Mon Jul 04, 2016 2:25 pm View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP