Re: gtkglextmm help



I don't currently have gtkglextmm installed.  It would be helpful to me and everyone else on the list if you would post the error messages you get when compiling your latest source here, since I assume it is different than in the first mail you sent.  I ask becuase it might not necessarily be a gtkglextmm problem.

dave

On Thu, Aug 21, 2008 at 3:40 PM, Martin (OpenGeoMap) <martin opengeomap org> wrote:
I write this source code and work:

g++ main2.cc `pkg-config --cflags --libs gtkglextmm-x11-1.2`

It seems that the samples from here are bad¿?¿? #include <iostream>
#include <cstdlib>
#include <gtkmm.h>
#include <GL/glu.h>
#include <gtkglmm.h>

#include <math.h>

float boxv[][3] = {
  { -0.5, -0.5, -0.5 },
  {  0.5, -0.5, -0.5 },
  {  0.5,  0.5, -0.5 },
  { -0.5,  0.5, -0.5 },
  { -0.5, -0.5,  0.5 },
  {  0.5, -0.5,  0.5 },
  {  0.5,  0.5,  0.5 },
  { -0.5,  0.5,  0.5 }
};
#define ALPHA 0.5

static float ang = 30.;


class glsample : public Gtk::GL::DrawingArea{
  public:
      glsample();
      virtual ~glsample();

  protected:
      virtual void on_realize();
      virtual bool on_configure_event(GdkEventConfigure* event);
      virtual bool on_expose_event(GdkEventExpose* event);
 };


glsample::glsample(){

  Glib::RefPtr<Gdk::GL::Config> glconfig;

  glconfig = Gdk::GL::Config::create(Gdk::GL::MODE_RGB | Gdk::GL::MODE_DEPTH | Gdk::GL::MODE_DOUBLE);

  set_gl_capability(glconfig);

}

glsample::~glsample(){
}

void glsample::on_realize(){
  Gtk::GL::DrawingArea::on_realize();

  //get gl::window
  Glib::RefPtr<Gdk::GL::Window> glwindow = get_gl_window();

  glwindow->gl_begin(get_gl_context());
glwindow->gl_begin(get_gl_context());
  glClearColor(1.0, 0.0, 0.0, 1.0);
  glMatrixMode(GL_PROJECTION);
  glOrtho(-0.5, 0.5, -0.5, 0.5, -0.1, 0.1);
  glColor3f(1.0f, 0.0f, 0.0f);
  glDisable(GL_DEPTH_TEST);  

         
  glwindow->gl_end();
}

bool glsample::on_configure_event(GdkEventConfigure* event){

  //get gl::window
  Glib::RefPtr<Gdk::GL::Window> glwindow = get_gl_window();

  glwindow->gl_begin(get_gl_context());
glViewport(0, 0, GLsizei(get_width()), GLsizei(get_height()));

  glwindow->gl_end();

  return true;
}

bool glsample::on_expose_event(GdkEventExpose* event){

  //get gl::window
  Glib::RefPtr<Gdk::GL::Window> glwindow = get_gl_window();

  glwindow->gl_begin(get_gl_context());

  glClear(GL_COLOR_BUFFER_BIT);

  glwindow->swap_buffers();
 glBegin (GL_TRIANGLES);
                      glIndexi (0);
                      glColor3f (1.0f, 0.0f, 0.0f);
                      glVertex2i (0, 1);
                      glIndexi (0);
                      glColor3f (0.0f, 1.0f, 0.0f);
                      glVertex2i (-1, -1);
                      glIndexi (0);
                      glColor3f (0.0f, 0.0f, 1.0f);
                      glVertex2i (1, -1);
              glEnd ();
  // Error detection.
  GLenum error = glGetError();
  if(error != GL_NO_ERROR)
  {
      std::cerr << "\n OpenGL error: " << gluErrorString(error);
      std::cerr.flush();
  }
  //main loop
  glwindow->gl_end();
  glwindow->swap_buffers ();

  return true;
}

int main(int argc, char *argv[]){
  Gtk::Main init (argc, argv);
  Gtk::GL::init (argc, argv);

  Gtk::Window window;
  window.set_title ("Widget Demo");

  glsample drawing;
  window.add (drawing);

  window.show_all ();

  Gtk::Main::run (window);

  return EXIT_SUCCESS;

}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]