![]() |
【转帖】opengl and background transpapency
opengl and background transpapency...
opengl and background transparency... does anybody know how to draw with opengl and not paint the background first. i have tried a few of the suggestions that i searched for in the forum (like the "clearscreen" and "doublebuffering" properties), to no avail. were are drawing multiple charts and chart formats on top of each other. attached is my attempt to get this working in our environment. perhaps you could show me the error in my ways. thank you in advance, nuzzi attached files quote: originally posted by nuzzi does anybody know how to draw with opengl and not paint the background first. i have tried a few of the suggestions that i searched for in the forum (like the "clearscreen" and "doublebuffering" properties), to no avail. were are drawing multiple charts and chart formats on top of each other. attached is my attempt to get this working in our environment. perhaps you could show me the error in my ways. thank you in advance, nuzzi besides that opengl-questions might be better placed in some other news groups ... opengl doesn't know a concept called background. if you wan't to clear the screenbuffer in opengl there is the glclear -function which takes the buffers to be emptied (like gl_color_buffer_bit or gl_depth_buffer_bit) if you want to draw things on top of each other in 2d (like windows or charts) you need to turn off depth buffering and draw them in the correct order (topmost window last). if i didn't understand your question feel free to give me some more hints. hth psy thanks for the reply... sorry...re-reading my question, i realize it was pretty unclear. i am using opengl as the .gs for the opendesign libraries. nuzzi quote: originally posted by nuzzi does anybody know how to draw with opengl and not paint the background first. i have tried a few of the suggestions that i searched for in the forum (like the "clearscreen" and "doublebuffering" properties), to no avail. were are drawing multiple charts and chart formats on top of each other. attached is my attempt to get this working in our environment. perhaps you could show me the error in my ways. thank you in advance, nuzzi as a strange aside. if i change the .gs to wingdi it works beautifully, but we are using opengl. what we would really like to do is have the gl drawing calls be made on a thread we create in our drawing engine, without the device needed. nuzzi has anybody used opengl and opendesign libraries to draw multiple charts on top of each other with transparency? thank you, nuzzi ok, another approach... since i haven't found a way to make the opengl gs device draw transparently, i figure i will draw to an offscreen bitmap and do the transparency myself. the following code throws and assert for setpixelformat in the exgsopenglvectorizedevice. void __stdcall c_od_dwg::mapdraw( idc2* dc ) { rect r; dc->getscrrect( &r ); pt2d_t mc; dc->getmapcenter( &mc ); if (( srect.left != r.left ) || ( srect.right != r.right ) || ( srect.top != r.top ) || ( srect.bottom != r.bottom )) reset_device( dc ); if ( p_db.isnull() || ( srect.left == srect.right ) || ( srect.top == srect.bottom )) return; odgsinitialize(); odgsview* pview = p_dev->viewat(0); // return a pointer to the dictionary entity containing the device properties odrxdictionaryptr p_props = p_dev->properties(); // set the dc handle for this gsdevice //hbitmap hmsk = createcompatiblebitmap( dc->gethandle(), srect.right, srect.top ); hdc hdcbuf = createcompatibledc( dc->gethandle()); hbitmap hbmp;// = createcompatiblebitmap( dc->gethandle(), srect.right, srect.top ); bitmapinfo bmi; bmi.bmiheader.bisize = sizeof(bitmapinfoheader); bmi.bmiheader.biwidth = srect.right; bmi.bmiheader.biheight = -srect.bottom; // negative indicates a top-down image bmi.bmiheader.biplanes = 1; bmi.bmiheader.bibitcount = 32; bmi.bmiheader.bicompression = bi_rgb; bmi.bmiheader.bisizeimage = (((( 32 * srect.right ) + 31 ) & ~31 ) >> 3 ) * srect.bottom; bmi.bmiheader.bixpelspermeter = 0; bmi.bmiheader.biypelspermeter = 0; bmi.bmiheader.biclrused = 0; bmi.bmiheader.biclrimportant = 0; hbmp = createdibsection(null, &bmi, dib_rgb_colors, 0, 0, 0l); selectobject(hdcbuf, hbmp); if( p_props->has( "windowhdc" )) p_props->putat( "windowhdc", odrxvariantvalue(( long )hdcbuf )); odgepoint3d targ = pview->target(); odgepoint3d dir = pview->position(); odgevector3d dir_targ = dir - targ; odgevector3d up = odgevector3d( sin( dc->getrotation()), cos( dc->getrotation()), 0.0 ); //pview->upvector(); targ.x = mc.x; targ.y = mc.y; pview->setview(targ + dir_targ, targ, up, dc->getscale() * abs( srect.right - srect.left ), dc->getscale() * abs( srect.bottom - srect.top )); p_dev->update(); odgsuninitialize(); bitblt( dc->gethandle(), 0, 0, srect.right, srect.bottom, hdcbuf, 0, 0, srccopy ); deletedc(hdcbuf); deleteobject(hbmp); } any ideas what might be wrong here? thanks again... |
所有的时间均为北京时间。 现在的时间是 05:43 AM. |