|
|
531f67 |
#include <iostream></iostream>
|
|
|
531f67 |
|
|
|
531f67 |
#include <gdkmm.h></gdkmm.h>
|
|
|
531f67 |
#include <gtkmm.h></gtkmm.h>
|
|
|
531f67 |
|
|
|
fdabb2 |
#include "view.h"
|
|
|
531f67 |
#include "surface.h"
|
|
|
531f67 |
#include "generator.h"
|
|
|
531f67 |
|
|
|
531f67 |
|
|
|
531f67 |
int main(int argc, char **argv) {
|
|
|
531f67 |
std::cout << "Lab: prototype of perspective transformation" << std::endl;
|
|
|
531f67 |
Glib::RefPtr<gtk::application> application = Gtk::Application::create(</gtk::application>
|
|
|
531f67 |
argc, argv, "org.morevnaproject.lab.perspective");
|
|
|
531f67 |
|
|
|
531f67 |
std::cout << "generate" << std::endl;
|
|
|
531f67 |
Generator generator;
|
|
|
531f67 |
DataSurface surface(256, 256);
|
|
|
531f67 |
generator.generate(surface, Vector2(0, 0), Vector2(16, 16));
|
|
|
531f67 |
|
|
|
531f67 |
std::cout << "convert" << std::endl;
|
|
|
531f67 |
Glib::RefPtr<gdk::pixbuf> pixbuf = Gdk::Pixbuf::create(</gdk::pixbuf>
|
|
|
531f67 |
Gdk::COLORSPACE_RGB, true, 8, surface.width(), surface.height() );
|
|
|
531f67 |
guint8 *pixel = pixbuf->get_pixels();
|
|
|
531f67 |
for(int r = 0; r < surface.height(); ++r) {
|
|
|
531f67 |
Color *row = surface[r];
|
|
|
531f67 |
for(int c = 0; c < surface.width(); ++c) {
|
|
|
531f67 |
const Color &color = row[c];
|
|
|
531f67 |
*(pixel++) = (guint8)(color.r*255.9);
|
|
|
531f67 |
*(pixel++) = (guint8)(color.g*255.9);
|
|
|
531f67 |
*(pixel++) = (guint8)(color.b*255.9);
|
|
|
531f67 |
*(pixel++) = (guint8)(color.a*255.9);
|
|
|
531f67 |
}
|
|
|
531f67 |
}
|
|
|
531f67 |
|
|
|
531f67 |
std::cout << "create window" << std::endl;
|
|
|
531f67 |
Gtk::Window window;
|
|
|
531f67 |
window.set_default_size(200, 200);
|
|
|
fdabb2 |
Gtk::HBox hbox;
|
|
|
fdabb2 |
hbox.set_homogeneous(true);
|
|
|
fdabb2 |
|
|
|
fdabb2 |
View a;
|
|
|
fdabb2 |
a.own_points.push_back( View::PointPtr( new View::Point() ) );
|
|
|
fdabb2 |
a.own_points.push_back( View::PointPtr( new View::Point() ) );
|
|
|
fdabb2 |
a.own_points.push_back( View::PointPtr( new View::Point() ) );
|
|
|
fdabb2 |
hbox.add(a);
|
|
|
fdabb2 |
|
|
|
fdabb2 |
View b;
|
|
|
fdabb2 |
b.own_points.push_back( View::PointPtr( new View::Point() ) );
|
|
|
fdabb2 |
b.own_points.push_back( View::PointPtr( new View::Point() ) );
|
|
|
fdabb2 |
b.own_points.push_back( View::PointPtr( new View::Point() ) );
|
|
|
fdabb2 |
hbox.add(b);
|
|
|
fdabb2 |
|
|
|
531f67 |
Gtk::Image image(pixbuf);
|
|
|
fdabb2 |
hbox.add(image);
|
|
|
fdabb2 |
|
|
|
fdabb2 |
window.add(hbox);
|
|
|
531f67 |
window.show_all();
|
|
|
531f67 |
|
|
|
531f67 |
std::cout << "run" << std::endl;
|
|
|
531f67 |
int result = application->run(window);
|
|
|
531f67 |
|
|
|
531f67 |
std::cout << "finished with code " << result << std::endl;
|
|
|
531f67 |
}
|