Thread: [Plib-users] Grrr.... I only get a black screen
Brought to you by:
sjbaker
From: Peter P. <pet...@st...> - 2004-08-26 09:09:00
|
I have been playing around with wxWindow and ssg and I simply cannot get it working properly. My program can be found here: http://rafb.net/paste/results/TcxCwP78.html It shows to windows. One is drawn using ssg and _should_ show a white rectangle, but only shows a black screen. The other window is drawn using direct opengl calls, and shows (and should show) a spinning red rectangle. It can be compiled with this command: g++ wxssg.cc -o wxssg `wx-config --cxxflags --libs --gl-libs` -lplibssg -lplibul -lplibsg Can anybody explain to me why only the red rectangle works? PS. considering that it works with direct opengl calls, I don't think the problem is in wxWindow. -- A: Because it messes up the order in which people normally read text. Q: Why is it such a bad thing? A: Top-posting. Q: What is the most annoying thing on usenet and in e-mail? |
From: Paolo L. <p.l...@ci...> - 2004-08-26 12:00:16
|
Peter, try these: 1. disable lighting (state->disable(GL_LIGHTING)); 2. add the fourth vertex color (just three colors set for four vertices), or just add a single color, single normal (flat shading); 3. move the sgSetCoord/setCamera to the draw() section and use rotate_ as azimuth (4th param in sgSetCoord) in order to look around. Alternatively try loading a 3D model (get whatever 3DS model in internet) instead of creating the leaf internally. Let's hope and see... Paolo > -----Messaggio originale----- > Da: pli...@li...=20 > [mailto:pli...@li...] Per conto di=20 > Peter Poulsen > Inviato: gioved=EC 26 agosto 2004 10.09 > A: pli...@li... > Oggetto: [Plib-users] Grrr.... I only get a black screen >=20 >=20 > I have been playing around with wxWindow and ssg and I simply=20 > cannot get it=20 > working properly. >=20 > My program can be found here:=20 > http://rafb.net/paste/results/TcxCwP78.html=20 > It shows to=20 > windows. One is drawn using ssg and _should_ show a white=20 > rectangle, but only shows a black screen. The other window is=20 > drawn using=20 > direct opengl calls, and shows (and should show) a spinning=20 > red rectangle. >=20 > It can be compiled with this command: > g++ wxssg.cc -o wxssg `wx-config --cxxflags --libs --gl-libs`=20 > -lplibssg > -lplibul -lplibsg >=20 > Can anybody explain to me why only the red rectangle works? >=20 > PS. considering that it works with direct opengl calls, I=20 > don't think the=20 > problem is in wxWindow. >=20 > --=20 > A: Because it messes up the order in which people normally read text. > Q: Why is it such a bad thing? > A: Top-posting. > Q: What is the most annoying thing on usenet and in e-mail? >=20 >=20 > ------------------------------------------------------- > SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media > 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 > Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift. > http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285 > _______________________________________________ > plib-users mailing list > pli...@li... > https://lists.sourceforge.net/lists/listinfo/plib-users >=20 |
From: Peter P. <pet...@st...> - 2004-08-26 12:26:26
|
Paolo Leoncini wrote: > Peter, > > try these: > > 1. disable lighting (state->disable(GL_LIGHTING)); > 2. add the fourth vertex color (just three colors set for four > vertices), or just add a single color, single normal (flat shading); > 3. move the sgSetCoord/setCamera to the draw() section and use rotate_ > as azimuth (4th param in sgSetCoord) in order to look around. > > Alternatively try loading a 3D model (get whatever 3DS model in > internet) instead of creating the leaf internally. > > Let's hope and see... > > Paolo > > > >>-----Messaggio originale----- >>Da: pli...@li... >>[mailto:pli...@li...] Per conto di >>Peter Poulsen >>Inviato: giovedì 26 agosto 2004 10.09 >>A: pli...@li... >>Oggetto: [Plib-users] Grrr.... I only get a black screen >> >> >>I have been playing around with wxWindow and ssg and I simply >>cannot get it >>working properly. >> >>My program can be found here: >>http://rafb.net/paste/results/TcxCwP78.html >>It shows to >>windows. One is drawn using ssg and _should_ show a white >>rectangle, but only shows a black screen. The other window is >>drawn using >>direct opengl calls, and shows (and should show) a spinning >>red rectangle. >> >>It can be compiled with this command: >>g++ wxssg.cc -o wxssg `wx-config --cxxflags --libs --gl-libs` >>-lplibssg >>-lplibul -lplibsg >> >>Can anybody explain to me why only the red rectangle works? >> >>PS. considering that it works with direct opengl calls, I >>don't think the >>problem is in wxWindow. >> Thanks alot! I finally got it working. I'm posting it here just for the archive. #include <iostream> #include <string> #include <cassert> #include <cmath> #include <wx/wx.h> #include <wx/glcanvas.h> #include <wx/notebook.h> #include <plib/ssg.h> bool ssg_init = false; class GL_Window : public wxGLCanvas { public: GL_Window(float c, wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style=0, const wxString& name="GLCanvas", int* attribList = 0, const wxPalette& palette = wxNullPalette) : wxGLCanvas(parent, id, pos, size, style, name, attribList, palette), c_(c), rotate_(c) { } virtual ~GL_Window() {} void init(int color) { SetCurrent(); if(!ssg_init) { ssgInit(); ssg_init = true; } ssgGetCurrentContext()->setNearFar(0.1, 10000.0); ssgGetCurrentContext()->setCullface(false); sgVec3 sunposn ; sgSetVec3(sunposn, 0.0f, -10.0f, 0.0f) ; ssgGetLight(0)->setPosition(sunposn) ; root_ = new ssgRoot; ssgVertexArray* vertices = new ssgVertexArray; sgVec3 x = { -0.5, 0.0f, -0.5 }; sgVec3 y = { -0.5, 0.0f, 0.5 }; sgVec3 z = { 0.5, 0.0f, 0.5 }; sgVec3 w = { 0.5, 0.0f, -0.5 }; vertices->add(z); vertices->add(y); vertices->add(x); vertices->add(w); sgVec4 white = { 1.0f, color, color, 1.0f}; ssgColourArray* colours = new ssgColourArray; colours->add(white); ssgNormalArray* normals = new ssgNormalArray; sgVec3 normal = { 0, -1.0f, 0 }; normals->add(normal); ssgVtxTable* n = new ssgVtxTable(GL_QUADS, vertices, normals, NULL, colours); ssgSimpleState* state = new ssgSimpleState () ; state->disable(GL_TEXTURE_2D); state->disable(GL_COLOR_MATERIAL); state->disable(GL_LIGHTING); n->setState(state); n->setCullFace(false); root_->addKid(n); } void draw() { rotate_ += 0.01; glClearColor(0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT); SetCurrent(); glViewport(0, 0, (GLint)200, (GLint)200); if(root_) { sgCoord coord; sgSetCoord(&coord, 0.0f, -2.0f, 0.0f, 5*cos(rotate_), 0.0f, 0.0f); ssgGetCurrentContext()->setCamera(&coord); ssgCullAndDraw(root_); } SwapBuffers(); } void OnIdle(wxIdleEvent& event) { draw(); event.RequestMore(); } private: float c_; float rotate_; ssgRoot* root_; DECLARE_EVENT_TABLE(); }; class MyApp: public wxApp { virtual bool OnInit(); }; IMPLEMENT_APP(MyApp) bool MyApp::OnInit() { wxFrame* frame = new wxFrame((wxFrame *)NULL, -1, "Hello GL World", wxPoint(50,50), wxSize(450,340) ); frame->Show(TRUE); wxNotebook* book = new wxNotebook(frame, -1, wxPoint(-1,-1), wxSize(450,340)); GL_Window* MyGLCanvas = new GL_Window(1, book, -1, wxPoint(-1,-1), wxSize(200,200), wxSUNKEN_BORDER, "some text"); book->AddPage(MyGLCanvas, "One"); MyGLCanvas->init(1); MyGLCanvas = new GL_Window(0, book, -1, wxPoint(-1,-1), wxSize(200,200), wxSUNKEN_BORDER, "some text"); book->AddPage(MyGLCanvas, "Two"); MyGLCanvas->init(0); return TRUE; } BEGIN_EVENT_TABLE(GL_Window, wxGLCanvas) EVT_IDLE(GL_Window::OnIdle) END_EVENT_TABLE() -- A: Because it messes up the order in which people normally read text. Q: Why is it such a bad thing? A: Top-posting. Q: What is the most annoying thing on usenet and in e-mail? |
From: Paolo L. <p.l...@ci...> - 2004-08-26 13:37:35
|
Peter Poulsen wrote: > Thanks alot! I finally got it working. Nice to have you on board! Perhaps the problem was in the lighting. The quad normal is in the same direction as the light (y-), so enabling lighting produces a black color over black background. As counterproof try setting the clear color to non black, re-enable lighting and see if the quad appears black. Furthermore remember that SSG coordinate system is z-up (x-right, y-into-the-screen) whilst OpenGL is y-up, so keep it into account when setting light and camera positions in the world. Greetings - Paolo |
From: Peter P. <pet...@st...> - 2004-08-26 14:14:01
|
Paolo Leoncini wrote: > Peter Poulsen wrote: > > >>Thanks alot! I finally got it working. > > > Nice to have you on board! > > Perhaps the problem was in the lighting. The quad normal is in the same > direction as the light (y-), so enabling lighting produces a black color > over black background. As counterproof try setting the clear color to > non black, re-enable lighting and see if the quad appears black. > Furthermore remember that SSG coordinate system is z-up (x-right, > y-into-the-screen) whilst OpenGL is y-up, so keep it into account when > setting light and camera positions in the world. > > Greetings - > I tried re-enabling light and set the clear color to blue. It turn out that it wasn't that, but I tried playing a little with the glViewport command, it definitely has something to do with it. As it is placed in my previous mail, it works fine. -- A: Because it messes up the order in which people normally read text. Q: Why is it such a bad thing? A: Top-posting. Q: What is the most annoying thing on usenet and in e-mail? |
From: Steve B. <sjb...@ai...> - 2004-08-26 22:23:18
|
>>It shows to >>windows. One is drawn using ssg and _should_ show a white >>rectangle, but only shows a black screen. The other window is >>drawn using >>direct opengl calls, and shows (and should show) a spinning >>red rectangle. I'm betting that the OpenGL rendering context isn't being correctly set to the second window...but it's hard to know without playing with the code. ---------------------------- Steve Baker ------------------------- HomeEmail: <sjb...@ai...> WorkEmail: <sj...@li...> HomePage : http://www.sjbaker.org Projects : http://plib.sf.net http://tuxaqfh.sf.net http://tuxkart.sf.net http://prettypoly.sf.net -----BEGIN GEEK CODE BLOCK----- GCS d-- s:+ a+ C++++$ UL+++$ P--- L++++$ E--- W+++ N o+ K? w--- !O M- V-- PS++ PE- Y-- PGP-- t+ 5 X R+++ tv b++ DI++ D G+ e++ h--(-) r+++ y++++ -----END GEEK CODE BLOCK----- |