size of overlay window.

  • Follow


Hi all,

  I have created overlay windows in my program. And I want to, just
know whether the size of the overlay window is fixed to the previous
main window or it can be changed.
    All I read, was that the window size of the overlay window is as
same as that of the main window. Is that always true ?
      Can anyone please tell me regarding that...
     Thanks in advance.

0
Reply naiktejaswini (5) 7/5/2007 5:03:06 AM

On Jul 5, 7:03 am, tejaswini <naiktejasw...@yahoo.co.in> wrote:
> Hi all,
>
>   I have created overlay windows in my program. And I want to, just
> know whether the size of the overlay window is fixed to the previous
> main window or it can be changed.
>     All I read, was that the window size of the overlay window is as
> same as that of the main window. Is that always true ?

They can be anywhere inside the main window.


--
<\___/>
/ O O \
\_____/  FTB.     Remove my socks for email address.

0
Reply fungus 7/5/2007 9:14:19 AM


On Jul 5, 2:14 pm, fungus <openglMYSO...@artlum.com> wrote:
> On Jul 5, 7:03 am, tejaswini <naiktejasw...@yahoo.co.in> wrote:
>
> > Hi all,
>
> >   I have createdoverlaywindows in my program. And I want to, just
> > know whether thesizeof theoverlaywindowis fixed to the previous
> > mainwindowor it can be changed.
> >     All I read, was that thewindowsizeof theoverlaywindowis as
> > same as that of the mainwindow. Is that always true ?
>
> They can be anywhere inside the mainwindow.
>
> --
> <\___/>
> / O O \
> \_____/  FTB.     Remove my socks for email address.

Thanks for the reply.
            I think you mean to say, is size of the overlay window can
be different than the main window but it should not exceed the size of
the main window.

0
Reply tejaswini 7/6/2007 3:38:31 AM

On Jul 6, 8:38 am, tejaswini <naiktejasw...@yahoo.co.in> wrote:
> On Jul 5, 2:14 pm, fungus <openglMYSO...@artlum.com> wrote:
>
>
>
>
>
> > On Jul 5, 7:03 am, tejaswini <naiktejasw...@yahoo.co.in> wrote:
>
> > > Hi all,
>
> > >   I have createdoverlaywindows in my program. And I want to, just
> > > know whether thesizeof theoverlaywindowis fixed to the previous
> > > mainwindowor it can be changed.
> > >     All I read, was that thewindowsizeof theoverlaywindowis as
> > > same as that of the mainwindow. Is that always true ?
>
> > They can be anywhere inside the mainwindow.
>
> > --
> > <\___/>
> > / O O \
> > \_____/  FTB.     Remove my socks for email address.
>
> Thanks for the reply.
>             I think you mean to say, is size of theoverlaywindow can
> be different than the main window but it should not exceed the size of
> the main window.- Hide quoted text -
>
> - Show quoted text -

If it is possible to draw the overlay window with different size than
the main window, then is it also  possible that the overlay window is
transparent, so that the image present the previous main window is
seen. I just want to know whether it is possible or not, so that it
will be helpful to me to proceed.

 Here is the code...

#include <windows.h>
#include <stdio.h>
#include "gl.h"
#include "glut.h"
#include "glu.h"


// pragmas
#pragma warning(disable : 4244)  // disable conversion warnings on
intel


// globals
HDC   hDC;                              // device context
HGLRC hRC;                              // opengl context
HGLRC hOverlayRC;                       // opengl overlay context
int   nEntries = 2;                     // number of entries in
palette
COLORREF crEntries[2] = {               // entries in custom palette
    0x00000000,                         // black (transparent)
    0x00ff0000,                         // white



};


// functions

/* WindowProc()
 *  Minimum Window Procedure
 */
LONG WINAPI WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
lParam)
{
    LONG        lRet = 1;
    PAINTSTRUCT ps;


    switch(uMsg) {
    case WM_CREATE:
        break;


    case WM_DESTROY:
        break;


    case WM_PAINT:
        BeginPaint(hWnd, &ps);
        EndPaint(hWnd, &ps);
        break;


    case WM_LBUTTONDOWN:
        printf("WM_LBUTTONDOWN: %d %d %s %s %s %s %s\n",
               LOWORD(lParam), HIWORD(lParam),
               wParam & MK_CONTROL ? "MK_CONTROL" : "",
               wParam & MK_LBUTTON ? "MK_LBUTTON" : "",
               wParam & MK_RBUTTON ? "MK_RBUTTON" : "",
               wParam & MK_MBUTTON ? "MK_MBUTTON" : "",
               wParam & MK_SHIFT   ? "MK_SHIFT"   : "");
        break;


    case WM_MOUSEMOVE:
        printf("WM_MOUSEMOVE: %d %d\n", LOWORD(lParam),
HIWORD(lParam));
        break;


    case WM_CHAR:
        printf("WM_CHAR: %c\n", wParam);
        if(wParam == 27) // ESC
            PostQuitMessage(0);
        break;


    case WM_SIZE:
        printf("WM_SIZE: %d %d\n", LOWORD(lParam), HIWORD(lParam));
        wglMakeCurrent(hDC, hRC);
        glViewport(0, 0, LOWORD(lParam), HIWORD(lParam));
        wglMakeCurrent(hDC, hOverlayRC);
        glViewport(0, 0, LOWORD(lParam), HIWORD(lParam));
        break;


    case WM_CLOSE:
        printf("WM_CLOSE\n");
        PostQuitMessage(0);
        break;


    default:
        lRet = DefWindowProc(hWnd, uMsg, wParam, lParam);
        break;
    }


    return lRet;



}


/* main()
 *  Entry point
 */
int main(int argc, char** argv)
{
    int       pf, maxpf;
    HWND      hWnd;                     // window
    WNDCLASS  wc;                       // window class
    HINSTANCE hInstance;                // instance of program
    PIXELFORMATDESCRIPTOR pfd;          // pixel format desctiptor
    LAYERPLANEDESCRIPTOR  lpd;          // layer plane desctiptor
    char*     WindowClass = "OpenGL";   // window class
    MSG       msg;                      // message

    // get this modules instance
    hInstance = GetModuleHandle(NULL);


    // fill in the window class structure
    wc.style         = 0;                            // no special
styles
    wc.lpfnWndProc   = (WNDPROC)WindowProc;          // event handler
    wc.cbClsExtra    = 0;                            // no extra class
data
    wc.cbWndExtra    = 0;                            // no extra
window data
    wc.hInstance     = hInstance;                    // instance
    wc.hIcon         = LoadIcon(NULL, IDI_WINLOGO);  // load a default
icon
    wc.hCursor       = LoadCursor(NULL, IDC_ARROW);  // load a default
cursor
    wc.hbrBackground = NULL;                         // redraw our own
bg
    wc.lpszMenuName  = NULL;                         // no menu
    wc.lpszClassName = WindowClass;                  // use a special
class


    // register the window class
    if(!RegisterClass(&wc)) {
        MessageBox(NULL,
                   "RegisterClass() failed:  Cannot register window
class,",
                   "Error", MB_OK);
        return FALSE;
    }


    // create a window
    hWnd = CreateWindow(WindowClass,     // class
                        WindowClass,     // name
                        WS_OVERLAPPEDWINDOW |
                        WS_CLIPSIBLINGS | WS_CLIPCHILDREN, // style
                        0, 0, 200, 200,  // x, y, width, height
                        NULL,            // no parent
                        NULL,            // no menu
                        hInstance,       // instance
                        NULL);           // don't pass anything to
WM_CREATE


    // make sure we got a window
    if(hWnd == NULL) {
        MessageBox(NULL,
                   "CreateWindow() failed:  Cannot create a window.",
                   "Error", MB_OK);
        return FALSE;
    }


    // show the window (map it)
    ShowWindow(hWnd, SW_SHOW);


    // send an initial WM_PAINT message (expose)
    UpdateWindow(hWnd);


    // get the device context
    hDC = GetDC(hWnd);


    // get the maximum number of pixel formats
    maxpf = DescribePixelFormat(hDC, 0, 0, NULL);


    // find an overlay layer descriptor
    for(pf = 0; pf < maxpf; pf++)
        if(wglDescribeLayerPlane(hDC, pf, 1,
                                 sizeof(LAYERPLANEDESCRIPTOR), &lpd))
        {
            if(!(lpd.dwFlags & LPD_DOUBLEBUFFER)) // want double
buffered
                continue;
            else
                break;                  // found one!
        }


    // now get the pixel format descriptor for that layer
    DescribePixelFormat(hDC, pf, sizeof(PIXELFORMATDESCRIPTOR),
&pfd);


    // set the pixel format
    if(SetPixelFormat(hDC, pf, &pfd) == FALSE) {
        MessageBox(NULL,
                   "SetPixelFormat() failed:  Cannot set overlay
specified.",
                   "Error", MB_OK);
        return FALSE;
    }


    // set up the layer palette
    printf("Num overlays %d\n", pfd.bReserved);
    printf("Bits per overlay %d\n", lpd.cColorBits);
    wglSetLayerPaletteEntries(hDC, 1, 0, nEntries, crEntries);


    // realize the palette
    wglRealizeLayerPalette(hDC, 1, TRUE);


    // create an OpenGL context
    hOverlayRC = wglCreateLayerContext(hDC, 1);


    // create an OpenGL context
    hRC = wglCreateContext(hDC);
    wglMakeCurrent(hDC, hRC);


    // now we can start changing state & rendering
    while(1) {                  // rotate a triangle around


        // first, check for (and process) messages in the queue
        while(PeekMessage(&msg, hWnd, 0, 0, PM_NOREMOVE)) {
            if(GetMessage(&msg, hWnd, 0, 0)) {
                TranslateMessage(&msg); // translate virtual-key
messages
                DispatchMessage(&msg);  // call the window proc
            } else {
				printf(".....don't do anything....");
                //goto quit;
            }
        }


        wglMakeCurrent(hDC, hRC);
        glClear(GL_COLOR_BUFFER_BIT);
        glRotatef(1.0, 0.0, 0.0, 1.0);
        glBegin(GL_TRIANGLES);
        glColor3f(1.0, 0.0, 0.0);
        glVertex2i( 0,  1);
        glColor3f(0.0, 1.0, 0.0);
        glVertex2i(-1, -1);
        glColor3f(0.0, 0.0, 1.0);
        glVertex2i( 1, -1);
        glEnd();
        glFlush();
        wglSwapLayerBuffers(hDC, WGL_SWAP_MAIN_PLANE);


        wglMakeCurrent(hDC, hOverlayRC);
        glClear(GL_COLOR_BUFFER_BIT);
        glRotatef(-1.0, 0.0, 0.0, 1.0);
        glBegin(GL_TRIANGLES);
        glIndexi(1);
        glVertex2i( 0,  1);
        glVertex2i(-1, -1);
        glVertex2i( 1, -1);
        glEnd();
        glFlush();
        wglSwapLayerBuffers(hDC, WGL_SWAP_OVERLAY1);


    }


}

   In this code, the the create window specifies the window for both
main as well as overlay window. So the size is same for both. But I
like to change the size of the overlay window, if it is possible
meanwhile maintaining the transparency.

   Please reply..

0
Reply tejaswini 7/6/2007 12:54:32 PM

On Jul 6, 2:54 pm, tejaswini <naiktejasw...@yahoo.co.in> wrote:
>
> If it is possible to draw the overlay window with different size than
> the main window, then is it also  possible that the overlay window is
> transparent, so that the image present the previous main window is
> seen. I just want to know whether it is possible or not, so that it
> will be helpful to me to proceed.
>

I don't know.... It's not OpenGL.

Maybe you could ask in a Windows programming
newsgroup.


--
<\___/>
/ O O \
\_____/  FTB.     Remove my socks for email address.

0
Reply fungus 7/6/2007 7:34:14 PM

"fungus" <openglMYSOCKS@artlum.com> wrote in message 
news:1183750454.650869.246720@q75g2000hsh.googlegroups.com...
> On Jul 6, 2:54 pm, tejaswini <naiktejasw...@yahoo.co.in> wrote:
>>
>> If it is possible to draw the overlay window with different size than
>> the main window, then is it also  possible that the overlay window is
>> transparent, so that the image present the previous main window is
>> seen. I just want to know whether it is possible or not, so that it
>> will be helpful to me to proceed.
>>
>
> I don't know.... It's not OpenGL.
>
> Maybe you could ask in a Windows programming
> newsgroup.
>
>
> --
> <\___/>
> / O O \
> \_____/  FTB.     Remove my socks for email address.
>

Ohh, it's not an OPENGL overlay window -- that's a horse of a different 
color.
OPENGL overlays windows are bound to the main OpenGL bit planes to be the 
same size, and are by definition transparent.

jbw


0
Reply jbwest 7/9/2007 3:48:56 AM

On Jul 9, 8:48 am, "jbwest" <jbw...@comcast.net> wrote:
> "fungus" <openglMYSO...@artlum.com> wrote in message
>
> news:1183750454.650869.246720@q75g2000hsh.googlegroups.com...
>
>
>
>
>
> > On Jul 6, 2:54 pm, tejaswini <naiktejasw...@yahoo.co.in> wrote:
>
> >> If it is possible to draw the overlay window with different size than
> >> the main window, then is it also  possible that the overlay window is
> >> transparent, so that the image present the previous main window is
> >> seen. I just want to know whether it is possible or not, so that it
> >> will be helpful to me to proceed.
>
> > I don't know.... It's not OpenGL.
>
> > Maybe you could ask in a Windows programming
> > newsgroup.
>
> > --
> > <\___/>
> > / O O \
> > \_____/  FTB.     Remove my socks for email address.
>
> Ohh, it's not an OPENGL overlay window -- that's a horse of a different
> color.
> OPENGL overlays windows are bound to the main OpenGL bit planes to be the
> same size, and are by definition transparent.
>
> jbw- Hide quoted text -
>
> - Show quoted text -

Thanks for all who replied to me. It has helped me a lot.

                                                       -----
Tejaswini.

0
Reply tejaswini 7/9/2007 12:15:52 PM

6 Replies
84 Views

(page loaded in 0.219 seconds)

Similiar Articles:













7/21/2012 3:43:37 AM


Reply: