Hi Trajce, very kind!
It's managed C++ (even if I would finally use OSG in a C++Builder application, 
but I fear I will need to build OSG in Visual Studio and make a a 
wrapper.......).

I tried many examples. I haven't tried osgviewerMFC because I haven't got the 
Visual Studio project files (CMake didn't create them for this project) and I'm 
new to MFC.
Anyway I usually get these errors:

1) Eccezione non gestita di tipo 'System.Runtime.InteropServices.SEHException' 
in TestOsgVS.exe. Informazioni aggiuntive: eccezione lanciata da un componente 
esterno.
when executing 
Code:
osg::ref_ptr<osg::Node> model1 = 
osgDB::readNodeFile("C:\\Path\\to\\OpenSceneGraph-3.0.1-VS10.0.30319-x86-release-12741\\data\\cessna.osg");



2) Eccezione non gestita di tipo 'System.AccessViolationException' in 
TestOsgVS.exe
when executing 
Code:
traits->inheritedWindowData = windata;



One of my test is this:


Code:
#pragma once

#include <osgDB/ReadFile>
//#include <osgUtil/Optimizer>
#include <osgViewer/Viewer>
//#include <osgViewer/api/Win32/GraphicsWindowWin32>
//#include <osgViewer/CompositeViewer>
#include <osgGA/TrackballManipulator>
#include <osgViewer/ViewerEventHandlers>

#include <iostream>
#include <Windows.h>
#include <string>

namespace TestOsgVS {

    using namespace System;
    using namespace System::ComponentModel;
    using namespace System::Collections;
    using namespace System::Windows::Forms;
    using namespace System::Data;
    using namespace System::Drawing;
    using namespace std;

    /// <summary>
    /// Riepilogo per Form1
    /// </summary>
    public ref class Form1 : public System::Windows::Forms::Form
    {
    public:
        Form1(void)
        {
            InitializeComponent();
            //
            //TODO: aggiungere qui il codice del costruttore.
            //
        }

    protected:
        /// <summary>
        /// Liberare le risorse in uso.
        /// </summary>
        ~Form1()
        {
            if (components)
            {
                delete components;
            }
        }
    private: System::Windows::Forms::Panel^  pOSG;
    private: System::Windows::Forms::Button^  button1;
    protected: 

    private:
        /// <summary>
        /// Variabile di progettazione necessaria.
        /// </summary>
        System::ComponentModel::Container ^components;

        osgViewer::Viewer* viewer;
        osg::Camera* camera;

#pragma region Windows Form Designer generated code
        /// <summary>
        /// Metodo necessario per il supporto della finestra di progettazione. 
Non modificare
        /// il contenuto del metodo con l'editor di codice.
        /// </summary>
        void InitializeComponent(void)
        {
            this->pOSG = (gcnew System::Windows::Forms::Panel());
            this->button1 = (gcnew System::Windows::Forms::Button());
            this->SuspendLayout();
            // 
            // pOSG
            // 
            this->pOSG->BackColor = 
System::Drawing::Color::FromArgb(static_cast<System::Int32>(static_cast<System::Byte>(255)),
 static_cast<System::Int32>(static_cast<System::Byte>(128)), 
                static_cast<System::Int32>(static_cast<System::Byte>(128)));
            this->pOSG->Location = System::Drawing::Point(43, 29);
            this->pOSG->Name = L"pOSG";
            this->pOSG->Size = System::Drawing::Size(379, 265);
            this->pOSG->TabIndex = 0;
            // 
            // button1
            // 
            this->button1->Location = System::Drawing::Point(482, 29);
            this->button1->Name = L"button1";
            this->button1->Size = System::Drawing::Size(177, 94);
            this->button1->TabIndex = 1;
            this->button1->Text = L"button1";
            this->button1->UseVisualStyleBackColor = true;
            this->button1->Click += gcnew System::EventHandler(this, 
&Form1::button1_Click);
            // 
            // Form1
            // 
            this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
            this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
            this->ClientSize = System::Drawing::Size(716, 503);
            this->Controls->Add(this->button1);
            this->Controls->Add(this->pOSG);
            this->Name = L"Form1";
            this->Text = L"Form1";
            this->ResumeLayout(false);

        }
#pragma endregion


    private: System::Void button1_Click(System::Object^  sender, 
System::EventArgs^  e) {
        
        // load model from file
        osg::ref_ptr<osg::Node> loadedModel = 
            
osgDB::readNodeFile("C:\\Path\\to\\OpenSceneGraph-3.0.1-VS10.0.30319-x86-release-12741\\data\\cow.osgt");

        //from osgviewerSDL example
        osgViewer::Viewer viewer;
        osg::ref_ptr<osgViewer::GraphicsWindowEmbedded> gw = 
viewer.setUpViewerAsEmbeddedInWindow(50,50,200,200);
        viewer.setSceneData(loadedModel.get());
        viewer.setCameraManipulator(new osgGA::TrackballManipulator);
        viewer.addEventHandler(new osgViewer::StatsHandler);
        viewer.realize();

        // draw the new frame
        viewer.frame();
    }
};
}



Many thanks for your help.[/list][/list]

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





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

Reply via email to