>
> Try again by fixing the source as I mentioned.
> I won't by able to try your code until several hours.
>
I modified my code as you told.
When I use "mode (FL_DOUBLE | FL_RGB)", the glGetString's return value showes
the GLWindow is still runnning in software mode.
When I use "mode (FL_SINGLE | FL_RGB)", GLWindow now is running in hardware
mode.
I noticed something strange. When I use "mode (FL_SINGLE | FL_RGB)" while the
other part of my code remains unchanged, with "glDrawBuffer(GL_BACK)" AND
"glDrawBuffer(GL_FRONT_AND_BACK)" specifing back buffer which should be
unavailable, my program could run at least "looks normally". I can
"swap_buffers()" in FL_SINGLE mode, and it works extremely well, rendering in
hardware mode.
In my real code, I use swap_buffer() since I found fltk don't always swap
buffer for me. I have a function which loops many times, in each loop, I draw a
scene and show it out. If I omit the swap_buffer() call, I don't get the last
redraw() result of the loop.
//
//My modifyed code.
//
#include <FL/Fl.h>
#include <FL/gl.h>
#include <FL/Fl_Gl_Window.H>
#include <FL/Fl_Menu_Item.H>
#include <FL/Fl_Menu_Bar.H>
#include <FL/Fl_Menu_Button.H>
#include <FL/Fl_Menu_Window.H>
#include <iostream>
class GlWindow : public Fl_Gl_Window {
public:
GlWindow(int X, int Y, int W, int H, const char *L = NULL)
: Fl_Gl_Window(X, Y, W, H, L) {
mode (FL_SINGLE | FL_RGB);//mode (FL_DOUBLE | FL_RGB);
persent = 0.0f;
}
int handle(int i)
{
if(i == FL_PUSH && Fl::event_button () == 1)
{
if(persent > 0.99999f)
persent = 0;
else
persent += 0.05f;
redraw();
return 1;
}
else
return Fl_Gl_Window::handle(i);
}
void draw()
{
if(! valid() )
{
gl_font(0, 12);
glViewport (0, 0, w(), h());
glMatrixMode (GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0f, w(), 0.0f, h(), -1.0f,
1.0f);
glMatrixMode (GL_MODELVIEW);
glLoadIdentity();
glClear(GL_COLOR_BUFFER_BIT);
valid(1);
}
glDrawBuffer (GL_BACK);
glClear(GL_COLOR_BUFFER_BIT);
//Draw Gray Proceeding Bar
glColor3b(33, 33, 33);
glBegin(GL_TRIANGLE_STRIP);
glVertex2f(0, h() * 0.3f);
glVertex2f(0, h() * 0.6f);
glVertex2f(w(), h() * 0.3f);
glVertex2f(w(), h() * 0.6f);
glEnd();
//Draw White Proceeding Bar
glColor3b(127, 127, 127);
glBegin(GL_TRIANGLE_STRIP);
glVertex2f(0, h() * 0.3f);
glVertex2f(0, h() * 0.6f);
glVertex2f(w() * persent, h() * 0.3f);
glVertex2f(w() * persent, h() * 0.6f);
glEnd();
//Draw Text "Persent : %4.4f s"
glColor3f (1.0f, 1.0f, 1.0f);
char temptext [30];
sprintf (temptext, "Persent : %4.4f s", persent);
gl_draw(temptext, 0.0f, h() * 0.7f);
}
float persent;
static void Test_cb(Fl_Widget * w, void*)
{
const char * gstring = (const char*) (glGetString(GL_RENDERER));
if(gstring != NULL)
{
printf ("%s\n", gstring);
}
gstring = (const char*) (glGetString(GL_VENDOR));
if(gstring != NULL)
{
printf ("%s\n", gstring);
}
gstring = (const char*) (glGetString(GL_EXTENSIONS));
if(gstring != NULL)
{
printf ("%s\n\n", gstring);
}
}
};
class ContainerWindow: public Fl_Menu_Window
{
public:
ContainerWindow(int X, int Y, int W, int H, const char *L = NULL)
: Fl_Menu_Window(X, Y, W, H, L) {
static Fl_Menu_Item menuitems[] = {
{ "&File", 0, 0, 0, FL_SUBMENU },
{ "&Open File", 0, (Fl_Callback *)0 },
{ "&Save File", 0, (Fl_Callback *)0 },
{ "&Exit", 0, (Fl_Callback *)0 },
{ 0 },
{ "&Operation", 0, 0, 0, FL_SUBMENU },
{"&Test", 0, (Fl_Callback *)&GlWindow::Test_cb},
{ 0 },
{0}
};
static Fl_Menu_Item popupMenuItems[] = {
{ "&Test", 0, (Fl_Callback
*)&GlWindow::Test_cb},
};
menuBar = new Fl_Menu_Bar(0, 0, w(), 30);
menuBar->copy(menuitems);
glWindow = new GlWindow(0, 30, w(), h() - 30);
popupMenu = new Fl_Menu_Button(0, 0, w(), h());
popupMenu->type(Fl_Menu_Button::POPUP3);
popupMenu->copy(popupMenuItems);
resizable(menuBar);
resizable(glWindow);
end();
}
public:
Fl_Menu_Bar* menuBar;
GlWindow* glWindow;
Fl_Menu_Button* popupMenu;
};
int main()
{
ContainerWindow mainWindow(0, 0, 700, 700, "Ray Casting");
mainWindow.show();
mainWindow.end();
Fl::run();
return 0;
}
_______________________________________________
fltk-bugs mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-bugs