[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[paragui-cvs] CVS: paragui/test gltest.cpp,1.1.2.3,1.1.2.4 paratest.cpp,
From: |
Teunis Peters <address@hidden> |
Subject: |
[paragui-cvs] CVS: paragui/test gltest.cpp,1.1.2.3,1.1.2.4 paratest.cpp,1.9.2.5,1.9.2.6 |
Date: |
Mon, 07 Oct 2002 18:23:29 -0400 |
Update of /cvsroot/paragui/paragui/test
In directory subversions:/tmp/cvs-serv21228/test
Modified Files:
Tag: devel-opengl
gltest.cpp paratest.cpp
Log Message:
Add driver support
expand debugging code (but mostly disabled)
Some more clarification.... hope I got everything - T
Index: gltest.cpp
===================================================================
RCS file: /cvsroot/paragui/paragui/test/Attic/gltest.cpp,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -C2 -r1.1.2.3 -r1.1.2.4
*** gltest.cpp 12 Sep 2002 06:38:50 -0000 1.1.2.3
--- gltest.cpp 7 Oct 2002 22:23:26 -0000 1.1.2.4
***************
*** 4,8 ****
*/
! #ifdef HAVE_OPENGL
#include "paragui.h"
--- 4,8 ----
*/
! /* #ifdef HAVE_OPENGL */
#include "paragui.h"
***************
*** 17,21 ****
--- 17,48 ----
#include "pglog.h"
+ #include "pgmenubar.h"
+ #include "pgtimerobject.h"
+
#include "pggldraw.h"
+ #include "pgdriver.h"
+
+ #define ID_APP_EXIT 1
+
+ bool exit_handler(PG_Button* button) {
+
+ // exit the application eventloop
+ PG_Application::GetInstance().Quit();
+
+ // return true to signal that we have processed this message
+ return true;
+ }
+
+ bool handle_menu_click(PG_MenuItem* item) {
+ PG_Application& app = PG_Application::GetInstance();
+
+ switch (item->getId()) {
+ case ID_APP_EXIT:
+ app.Quit();
+ break;
+ }
+
+ return true;
+ }
bool handleListBoxItem(PG_ListBoxItem* item) {
***************
*** 24,44 ****
}
int main( int argc, char **argv ) {
PG_Draw::PG_Draw* gldraw;
gldraw = new PG_Draw::PG_GLDraw();
PG_Draw::PG_Draw::SetDefaultDrawable(gldraw);
!
PG_Application& app = PG_Application::GetInstance();
!
app.LoadTheme("default");
! fprintf(stderr, "%s:%s:%i\n", __FILE__, __FUNCTION__, __LINE__);
! app.InitScreen(640, 480, 0);
app.SetEmergencyQuit(true);
!
! fprintf(stderr, "%s:%s:%i\n", __FILE__, __FUNCTION__, __LINE__);
! PG_ListBox listbox(NULL, PG_Rect(10,10,300,100));
listbox.sigSelectItem.connect(slot(handleListBoxItem));
- fprintf(stderr, "%s:%s:%i\n", __FILE__, __FUNCTION__, __LINE__);
new PG_ListBoxItem(&listbox, 25, "Item1");
--- 51,336 ----
}
+ class PlayField2 : public PG_ThemeWidget, public PG_TimerObject
+ {
+ public:
+ PlayField2(PG_Widget* parent, PG_Rect r);
+ ~PlayField2();
+
+ Uint32 eventTimer(PG_TimerID id, Uint32 interval);
+ protected:
+ void eventBlit(PG_Draw::PG_DrawableSurface* surface, const PG_Rect&
src, const PG_Rect& dst);
+ private:
+ SDL_Color my_color;
+ int tickstate;
+ };
+
+ PlayField2::PlayField2(PG_Widget* parent, PG_Rect r) : PG_ThemeWidget(parent,
r) {
+ my_color.r = 0;
+ my_color.g = 0;
+ my_color.b = 255;
+
+ tickstate = 0;
+ }
+
+ PlayField2::~PlayField2() {
+ }
+
+ void PlayField2::eventBlit(PG_Draw::PG_DrawableSurface* surface, const
PG_Rect& src, const PG_Rect& dst) {
+ float color[8][3]= {{ 1.0, 1.0, 0.0},
+ { 1.0, 0.0, 0.0},
+ { 0.0, 0.0, 0.0},
+ { 0.0, 1.0, 0.0},
+ { 0.0, 1.0, 1.0},
+ { 1.0, 1.0, 1.0},
+ { 1.0, 0.0, 1.0},
+ { 0.0, 0.0, 1.0}};
+ float cube[8][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}};
+ my_srfScreen->FillRect(dst, 0);
+ for (int i=0; i<3; i++)
+ {
+ #if 0
+ DrawLine(
+ i*40 + tickstate,
+ 0,
+ i*40 + tickstate,
+ my_height/2,
+ my_color,
+ 1
+ );
+ #endif
+ /* FIXME - this is state data - which should be saved somehow */
+ /* Do our drawing, too. */
+ /* glClearColor( 0.0, 0.0, 0.0, 1.0 ); */
+ /* glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); */
+
+ my_srfScreen->SetClipRect(dst);
+ // glViewport(0,0,my_srfScreen->getWidth(),my_srfScreen->getHeight());
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glLoadIdentity( );
+ glOrtho( -2.0, 2.0, -2.0, 2.0, -20.0, 20.0 );
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ glLoadIdentity( );
+ // glRotatef(5.0 * tickstate, 1.0, 1.0, 1.0);
+
+ glBegin( GL_QUADS );
+ {
+ #ifdef SHADED_CUBE
+ glColor3fv(color[0]);
+ glVertex3fv(cube[0]);
+ glColor3fv(color[1]);
+ glVertex3fv(cube[1]);
+ glColor3fv(color[2]);
+ glVertex3fv(cube[2]);
+ glColor3fv(color[3]);
+ glVertex3fv(cube[3]);
+
+ glColor3fv(color[3]);
+ glVertex3fv(cube[3]);
+ glColor3fv(color[4]);
+ glVertex3fv(cube[4]);
+ glColor3fv(color[7]);
+ glVertex3fv(cube[7]);
+ glColor3fv(color[2]);
+ glVertex3fv(cube[2]);
+
+ glColor3fv(color[0]);
+ glVertex3fv(cube[0]);
+ glColor3fv(color[5]);
+ glVertex3fv(cube[5]);
+ glColor3fv(color[6]);
+ glVertex3fv(cube[6]);
+ glColor3fv(color[1]);
+ glVertex3fv(cube[1]);
+
+ glColor3fv(color[5]);
+ glVertex3fv(cube[5]);
+ glColor3fv(color[4]);
+ glVertex3fv(cube[4]);
+ glColor3fv(color[7]);
+ glVertex3fv(cube[7]);
+ glColor3fv(color[6]);
+ glVertex3fv(cube[6]);
+
+ glColor3fv(color[5]);
+ glVertex3fv(cube[5]);
+ glColor3fv(color[0]);
+ glVertex3fv(cube[0]);
+ glColor3fv(color[3]);
+ glVertex3fv(cube[3]);
+ glColor3fv(color[4]);
+ glVertex3fv(cube[4]);
+
+ glColor3fv(color[6]);
+ glVertex3fv(cube[6]);
+ glColor3fv(color[1]);
+ glVertex3fv(cube[1]);
+ glColor3fv(color[2]);
+ glVertex3fv(cube[2]);
+ glColor3fv(color[7]);
+ glVertex3fv(cube[7]);
+ #else // flat cube
+ glColor3f(1.0, 0.0, 0.0);
+ glVertex3fv(cube[0]);
+ glVertex3fv(cube[1]);
+ glVertex3fv(cube[2]);
+ glVertex3fv(cube[3]);
+
+ glColor3f(0.0, 1.0, 0.0);
+ glVertex3fv(cube[3]);
+ glVertex3fv(cube[4]);
+ glVertex3fv(cube[7]);
+ glVertex3fv(cube[2]);
+
+ glColor3f(0.0, 0.0, 1.0);
+ glVertex3fv(cube[0]);
+ glVertex3fv(cube[5]);
+ glVertex3fv(cube[6]);
+ glVertex3fv(cube[1]);
+
+ glColor3f(0.0, 1.0, 1.0);
+ glVertex3fv(cube[5]);
+ glVertex3fv(cube[4]);
+ glVertex3fv(cube[7]);
+ glVertex3fv(cube[6]);
+
+ glColor3f(1.0, 1.0, 0.0);
+ glVertex3fv(cube[5]);
+ glVertex3fv(cube[0]);
+ glVertex3fv(cube[3]);
+ glVertex3fv(cube[4]);
+
+ glColor3f(1.0, 0.0, 1.0);
+ glVertex3fv(cube[6]);
+ glVertex3fv(cube[1]);
+ glVertex3fv(cube[2]);
+ glVertex3fv(cube[7]);
+ #endif /* SHADED_CUBE */
+ }
+ glEnd( );
+
+ // glMatrixMode(GL_MODELVIEW);
+ // glRotatef(5.0, 1.0, 1.0, 1.0);
+
+ #if 0
+ /* Draw 2D logo onto the 3D display */
+ if ( logo ) {
+ if ( USE_DEPRECATED_OPENGLBLIT ) {
+ DrawLogoBlit();
+ } else {
+ DrawLogoTexture();
+ }
+ }
+ #endif
+ glMatrixMode(GL_MODELVIEW);
+ glPopMatrix();
+ // glMatrixMode(GL_PROJECTION);
+ // glPopMatrix();
+ // glViewport(0,0,my_srfScreen->getWidth(),my_srfScreen->getHeight());
+ my_srfScreen->SetClipRect(PG_Rect());
+ }
+
+ SDL_Color temp_color;
+ PG_Rect temp_rect;
+ Uint32 temp_int;
+
+ temp_rect.x = dst.x;
+ temp_rect.y = dst.y+(dst.h/2);
+ temp_rect.w = dst.w;
+ temp_rect.h = dst.h-(dst.h/2);
+
+ temp_color.r = (my_color.r * tickstate)/40;
+ temp_color.g = (my_color.g * tickstate)/40;
+ temp_color.b = (my_color.b * tickstate)/40;
+
+ temp_int = SDL_MapRGB(my_srfScreen->getScreen()->format, temp_color.r,
temp_color.g, temp_color.b);
+ my_srfScreen->FillRect(temp_rect, temp_int);
+ }
+
+ Uint32 PlayField2::eventTimer(PG_TimerID id, Uint32 interval) {
+ tickstate++;
+ /* PG_LogDBG("eventTimer(%i, %i)", id, interval); */
+ if(tickstate >= 40) {
+ tickstate = 0;
+ }
+ Update();
+ PG_TimerObject::eventTimer(id, interval);
+ return 0;
+ }
+
int main( int argc, char **argv ) {
+ #if 0
PG_Draw::PG_Draw* gldraw;
gldraw = new PG_Draw::PG_GLDraw();
PG_Draw::PG_Draw::SetDefaultDrawable(gldraw);
! #endif
PG_Application& app = PG_Application::GetInstance();
!
! /* yay - tested working */
! #if 0
! #ifdef HAVE_DUMMYVIDEO
! /* app.AddArchive("../src/draw/dummy"); */
! PG_VideoDriver* gldriver = new PG_VideoDriver(app, PG_DUMMYVIDEO);
! #endif
! #endif
! #if 1
! #ifdef HAVE_OPENGL
! app.AddArchive("../src/draw/opengl");
! PG_VideoDriver* gldriver = new PG_VideoDriver(app, PG_GLVIDEO);
! #endif
! #endif
! #if 0
! #ifdef HAVE_DIRECTX
! app.AddArchive("../src/draw/windx");
! PG_VideoDriver* gldriver = new PG_VideoDriver(app, PG_DXVIDEO);
! #endif
! #endif
! if (gldriver->valid()) {
! gldriver->attach();
! } else {
! fprintf(stderr, "OpenGL failed to initialize! - Quitting...");
! return -1;
! };
!
app.LoadTheme("default");
! app.InitScreen(640, 480, 0, SDL_DOUBLEBUF);
!
! if (SDL_GetVideoSurface() != NULL) {
! printf("Screen BPP: %d\n", SDL_GetVideoSurface()->format->BitsPerPixel);
! printf("\n");
! printf( "Vendor : %s\n", glGetString( GL_VENDOR ) );
! printf( "Renderer : %s\n", glGetString( GL_RENDERER ) );
! printf( "Version : %s\n", glGetString( GL_VERSION ) );
! printf( "Extensions : %s\n", glGetString( GL_EXTENSIONS ) );
! printf("\n");
! };
!
app.SetEmergencyQuit(true);
! /* fprintf(stderr, "%s:%s:%i\n", __FILE__, __FUNCTION__, __LINE__); */
!
! PG_Rect rect(0, 0, 80, 30);
! PG_Button myButton(NULL,1,rect,"Quit");
! myButton.sigButtonClick.connect(slot(exit_handler));
! myButton.Show();
!
! PG_MenuBar menubar(NULL, PG_Rect(100, 0, 400, 30));
! PG_PopupMenu popmenu(NULL, 425, 140, "File");
! popmenu.addMenuItem("Nail", 99, slot(handle_menu_click)).
! addMenuItem("Quit", ID_APP_EXIT, slot(handle_menu_click));
! menubar.Add("File", &popmenu);
! menubar.Show();
!
! #if 0
! PG_ListBox listbox(NULL, PG_Rect(10,40,300,100));
listbox.sigSelectItem.connect(slot(handleListBoxItem));
new PG_ListBoxItem(&listbox, 25, "Item1");
***************
*** 53,72 ****
new PG_ListBoxItem(&listbox, 25, "Item10");
listbox.Show();
! fprintf(stderr, "%s:%s:%i\n", __FILE__, __FUNCTION__, __LINE__);
!
app.Run();
! fprintf(stderr, "%s:%s:%i\n", __FILE__, __FUNCTION__, __LINE__);
!
return 0;
}
! #else /* HAVE_OPENGL */
!
! int main(int argc, char *argv[])
! {
! printf("No OpenGL support on this system\n");
! return 1;
! }
!
! #endif /* HAVE_OPENGL */
--- 345,371 ----
new PG_ListBoxItem(&listbox, 25, "Item10");
listbox.Show();
! #endif
!
! PlayField2 anim_test2(NULL,
! PG_Rect(260, 300, 120, 100)
! );
! anim_test2.AddTimer(40);
! anim_test2.AddTimer(20);
! anim_test2.Show();
app.Run();
! delete gldriver;
return 0;
}
! /*
! * #else / * HAVE_OPENGL * /
! * #include <stdio.h>
! * int main(int argc, char *argv[])
! * {
! * printf("No OpenGL support on this system\n");
! * return 1;
! * }
! *
! * #endif / * HAVE_OPENGL * /
! */
Index: paratest.cpp
===================================================================
RCS file: /cvsroot/paragui/paragui/test/paratest.cpp,v
retrieving revision 1.9.2.5
retrieving revision 1.9.2.6
diff -C2 -r1.9.2.5 -r1.9.2.6
*** paratest.cpp 12 Sep 2002 06:38:50 -0000 1.9.2.5
--- paratest.cpp 7 Oct 2002 22:23:26 -0000 1.9.2.6
***************
*** 1,2 ****
--- 1,7 ----
+ /* define this to switch to OpenGL rendering - which currently crashes
+ * and causes trouble with X due to threading... */
+ /* #undef TRY_OPENGL */
+
+
#include "paragui.h"
***************
*** 277,280 ****
--- 282,289 ----
}
+ #ifdef TRY_OPENGL
+ #include "pggldraw.h"
+ #endif
+
int main(int argc, char* argv[]) {
char theme[20];
***************
*** 287,290 ****
--- 296,305 ----
int resx = RESX, resy = RESY;
+
+ #ifdef TRY_OPENGL
+ PG_Draw::PG_Draw* gldraw;
+ gldraw = new PG_Draw::PG_GLDraw();
+ PG_Draw::PG_Draw::SetDefaultDrawable(gldraw);
+ #endif
// construct the application object
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [paragui-cvs] CVS: paragui/test gltest.cpp,1.1.2.3,1.1.2.4 paratest.cpp,1.9.2.5,1.9.2.6,
Teunis Peters <address@hidden> <=
- Prev by Date:
[paragui-cvs] CVS: paragui/include pgdriver.h,NONE,1.1.2.1 pgdriverdta.h,NONE,1.1.2.1 pgdraw.h,1.4.2.3,1.4.2.4 pgfont.h,1.4.2.2,1.4.2.3 pggldraw.h,1.1.2.2,1.1.2.3
- Next by Date:
[paragui-cvs] CVS: paragui/src/widgets pgbutton.cpp,1.8.2.3,1.8.2.4 pgcolumnitem.cpp,1.3.2.2,1.3.2.3 pgimage.cpp,1.3.2.1,1.3.2.2 pglabel.cpp,1.4.2.1,1.4.2.2 pglayout.cpp,1.2.2.2,1.2.2.3 pglineedit.cpp,1.6.2.3,1.6.2.4 pgthemewidget.cpp,1.6.2.3,1.6.2.4 pgwidget.cpp,1.13.2.4,1.13.2.5 pgwidgetdnd.cpp,1.3.2.2,1.3.2.3 pgwindow.cpp,1.10.2.2,1.10.2.3
- Previous by thread:
[paragui-cvs] CVS: paragui/include pgdriver.h,NONE,1.1.2.1 pgdriverdta.h,NONE,1.1.2.1 pgdraw.h,1.4.2.3,1.4.2.4 pgfont.h,1.4.2.2,1.4.2.3 pggldraw.h,1.1.2.2,1.1.2.3
- Next by thread:
[paragui-cvs] CVS: paragui/src/widgets pgbutton.cpp,1.8.2.3,1.8.2.4 pgcolumnitem.cpp,1.3.2.2,1.3.2.3 pgimage.cpp,1.3.2.1,1.3.2.2 pglabel.cpp,1.4.2.1,1.4.2.2 pglayout.cpp,1.2.2.2,1.2.2.3 pglineedit.cpp,1.6.2.3,1.6.2.4 pgthemewidget.cpp,1.6.2.3,1.6.2.4 pgwidget.cpp,1.13.2.4,1.13.2.5 pgwidgetdnd.cpp,1.3.2.2,1.3.2.3 pgwindow.cpp,1.10.2.2,1.10.2.3
- Index(es):