Page Menu
Home
HEPForge
Search
Configure Global Search
Log In
Files
F9501636
frog.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Subscribers
None
frog.cpp
View Options
#include
"FROG/FROG_Displayer.h"
int
main
(
int
argc
,
char
*
argv
[])
{
#
ifdef
windows
SetDllDirectory
(
"Lib"
);
#endif
FROG_Displayer
*
frog_window
=
new
FROG_Displayer
(
0
,
0
,
800
,
600
,
"FROG Displayer"
);
frog_window
->
run
(
argc
,
argv
);
while
(
frog_window
->
shown
()){
Fl
::
check
();
}
return
0
;
}
/*
class WIN_GL : public Fl_Gl_Window {
public:
unsigned char* BUFFER;
WIN_GL(int x,int y,int w,int h,const char *l=0) : Fl_Gl_Window(x,y,w,h,l){
Fl::add_timeout(0.01, Timer_CB_stat, (void*)this);
}
void Perspective(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar) {
GLdouble xmin, xmax, ymin, ymax;
ymax = zNear * tan(fovy * 3.141516 / 360.0);
ymin = -ymax;
xmin = ymin * aspect;
xmax = ymax * aspect;
glFrustum(xmin, xmax, ymin, ymax, zNear, zFar);
}
static void Timer_CB_stat(void* args){ ((WIN_GL*)args)->Timer_CB(); }
void Timer_CB() {
this->redraw();
Fl::repeat_timeout(0.01, Timer_CB_stat, this);
}
void draw(){
//std::cout << "GL DRAW\n";
if ( !valid() ) {
valid(1);
// Viewport
glViewport(0, 0, w(), h());
// Projection
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
GLfloat ratio = w() / (float)h();
Perspective(30.0f, 1.0f*ratio, 1.0f, 30.0f);
glTranslatef(0.0, 0.0, -10.0);
// Model view
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glFrontFace(GL_CW);
glEnable(GL_CULL_FACE);
}
if(BUFFER){printf("free\n");free(BUFFER);}
BUFFER = (unsigned char*)malloc(500000000*sizeof(char));
printf("Buffer = %x\n",BUFFER);
glClearColor(.9,.9,.9, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Setup model matrix
glLoadIdentity();
static float spin = 0.0f;
spin+=0.5f;
glRotatef(spin, 0.5f, 1.0f, 0.0f); // show all sides of cube
// Draw cube with texture assigned to each face
glBegin(GL_QUADS);
// Front Face
glColor3f(1.0, 0.0, 0.0); // red
glVertex3f(-1.0, 1.0, 1.0); // Top Left Of The Texture and Quad
glVertex3f( 1.0, 1.0, 1.0); // Top Right Of The Texture and Quad
glVertex3f( 1.0, -1.0, 1.0); // Bottom Right Of The Texture and Quad
glVertex3f(-1.0, -1.0, 1.0); // Bottom Left Of The Texture and Quad
// Back Face
glColor3f(0.0, 1.0, 1.0); // cyn
glVertex3f( 1.0, 1.0, -1.0); // Top Left Of The Texture and Quad
glVertex3f(-1.0, 1.0, -1.0); // Top Right Of The Texture and Quad
glVertex3f(-1.0, -1.0, -1.0); // Bottom Right Of The Texture and Quad
glVertex3f( 1.0, -1.0, -1.0); // Bottom Left Of The Texture and Quad
// Top Face
glColor3f(0.0, 1.0, 0.0); // grn
glVertex3f(-1.0, 1.0, -1.0); // Top Left Of The Texture and Quad
glVertex3f( 1.0, 1.0, -1.0); // Top Right Of The Texture and Quad
glVertex3f( 1.0, 1.0, 1.0); // Bottom Right Of The Texture and Quad
glVertex3f(-1.0, 1.0, 1.0); // Bottom Left Of The Texture and Quad
// Bottom Face
glColor3f(1.0, 0.0, 1.0); // mag
glVertex3f( 1.0, -1.0, -1.0); // Top Left Of The Texture and Quad
glVertex3f(-1.0, -1.0, -1.0); // Top Right Of The Texture and Quad
glVertex3f(-1.0, -1.0, 1.0); // Bottom Right Of The Texture and Quad
glVertex3f( 1.0, -1.0, 1.0); // Bottom Left Of The Texture and Quad
// Right face
glColor3f(0.0, 0.0, 1.0); // blu
glVertex3f( 1.0, 1.0, 1.0); // Top Left Of The Texture and Quad
glVertex3f( 1.0, 1.0, -1.0); // Top Right Of The Texture and Quad
glVertex3f( 1.0, -1.0, -1.0); // Bottom Right Of The Texture and Quad
glVertex3f( 1.0, -1.0, 1.0); // Bottom Left Of The Texture and Quad
// Left Face
glColor3f(1.0, 1.0, 0.0); // yel
glVertex3f(-1.0, 1.0, -1.0); // Top Left Of The Texture and Quad
glVertex3f(-1.0, 1.0, 1.0); // Top Right Of The Texture and Quad
glVertex3f(-1.0, -1.0, 1.0); // Bottom Right Of The Texture and Quad
glVertex3f(-1.0, -1.0, -1.0); // Bottom Left Of The Texture and Quad
glEnd();
Fl_Gl_Window::draw();
}
int handle(int e){
return Fl_Gl_Window::handle(e);
}
};
class WIN_MAIN : public Fl_Double_Window {
public:
WIN_GL* GL1;
WIN_GL* GL2;
WIN_MAIN(int x,int y,int w,int h,const char *l=0) : Fl_Double_Window(x,y,w,h,l)
{
this->begin();
GL1 = new WIN_GL(10,10,w/2-20, h-20);
GL1->end();
GL1->show();
GL1->draw();
GL1->resizable(this);
this->begin();
GL2 = new WIN_GL(w-w/2+10,10,w/2-20, h-20);
GL2->end();
GL2->show();
GL2->draw();
GL2->resizable(this);
this->end();
}
};
int main (int argc, char *argv[])
{
WIN_MAIN* test = new WIN_MAIN(0,0,800,600,"Displayer");
test->resizable(test);
test->show();
while(test->shown()){
Fl::check();
//test->damage(FL_DAMAGE_ALL);
//test->GL1->redraw();
test->redraw();
new unsigned char[100000];
}
return 0;
}
*/
File Metadata
Details
Attached
Mime Type
text/x-c++
Expires
Sun, Feb 23, 2:51 PM (1 d, 7 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4486719
Default Alt Text
frog.cpp (5 KB)
Attached To
rFROGSVN frogsvn
Event Timeline
Log In to Comment