GIDForums  

Go Back   GIDForums > Computer Programming Forums > FLTK Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 28-Feb-2009, 11:20
l4m4_m4n l4m4_m4n is offline
New Member
 
Join Date: Feb 2009
Posts: 2
l4m4_m4n is on a distinguished road

OpenGL fails in FLTK!


Hello, world!
Do somebody know what is the problem here:
Untitled.jpg

I'm using FLTK 1.1.9 and the source code of the program is:
CPP / C++ / C Code:
#ifdef _WIN32
#include <windows.h>
#endif
#include <math.h>
#include <FL/Fl.h>
#include <FL/Fl_Window.h>
#include <FL/Fl_Gl_Window.h>
#include <FL/gl.h>
#include <FL/glut.h>
//
// Render a simple opengl shaded sphere with a single side light -- erco 11/28/08
//     NOTE: Glut needed *only* for glutSolidSphere()
//
class MyGlWindow : public Fl_Gl_Window {
public:
    // RESHAPE THE VIEWPORT
    void Reshape(GLfloat W, GLfloat H) {
        // (REFERENCE: SGI light.c DEMO)
        GLfloat ratio = W / H;
        glViewport(0, 0, (GLsizei)W, (GLsizei)H);
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glOrtho(-1.5*ratio, 1.5*ratio, -1.5, 1.5, -10.0, 10.0);
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();
    }
    void draw() {
        if (!valid()) {
            valid(1);
            Reshape(w(), h());
            // (REFERENCE: SGI 'light.c' EXAMPLE)
            GLfloat mat_ambient[]    = { 1.0, 1.0, 1.0, 1.0 };  // RGBA
            GLfloat mat_diffuse[]    = { 1.0, 1.0, 1.0, 1.0 };  // RGBA
            GLfloat mat_specular[]   = { 1.0, 1.0, 1.0, 1.0 };  // RGBA
            GLfloat light_position[] = { 5.0, 5.0, 0.0, 0.0 };  // XYZ
            glClearColor(0.0, 0.0, 0.4, 0.0);                   // bg color
            glShadeModel(GL_SMOOTH);
            //
            glMaterialfv(GL_FRONT, GL_AMBIENT,   mat_ambient);
            glMaterialfv(GL_FRONT, GL_DIFFUSE,   mat_diffuse);
            glMaterialfv(GL_FRONT, GL_SPECULAR,  mat_specular);
            glMaterialf(GL_FRONT,  GL_SHININESS, 20.0);
            glLightfv(GL_LIGHT0, GL_POSITION, light_position);
            //
            glEnable(GL_LIGHTING);
            glEnable(GL_LIGHT0);
            glEnable(GL_DEPTH_TEST);
        }
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        glPushMatrix();
            glColor3f(0.5, 0.5, 0.5);
            glutSolidSphere(0.5, 30, 30);
        glPopMatrix();
    }
    // CTOR
    MyGlWindow(int X,int Y,int W,int H,const char*L=0) : Fl_Gl_Window(X,Y,W,H,L) {
    }
};
int main() {
     Fl_Window win(640, 480, "sphere");
     MyGlWindow mygl(10, 10, win.w()-20, win.h()-20);
     win.resizable(&mygl);
     win.show();
     return(Fl::run());
}

I have Slackware Linux 12.2 and I do compile with "fltk-config --use-glut --use-gl --compile filename.cpp".
  #2  
Old 02-Mar-2009, 10:25
l4m4_m4n l4m4_m4n is offline
New Member
 
Join Date: Feb 2009
Posts: 2
l4m4_m4n is on a distinguished road

Re: OpenGL fails in FLTK!


OK, I have fixed that by installing Mesa libraries.
Now it works!!!
 
 

Recent GIDBlogProblems with the Navy (Officers) by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
OpenGL in Normal FLTK Windows automatedreason FLTK Forum 2 25-Apr-2008 05:44
A problem of using opengl in fltk formail FLTK Forum 2 11-Aug-2006 03:39
[Tutorial] GUI programming with FLTK dsmith FLTK Forum 10 03-Oct-2005 15:41
FLTK and OpenGL bgarisn FLTK Forum 2 27-Jun-2005 06:22
GIMcontacts - a gim fltk fluid venture cable_guy_67 FLTK Forum 0 14-Feb-2005 14:18

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 07:22.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.