Announcement

Collapse

Maintenance

The forum could be offline for 30-60 minutes in the very near future for maintenance (said 3pm Pacific). I was behind on getting this notice. I do apologize.
See more
See less

Use Only Portion of Dialog as OpenGL RC

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #21
    Originally posted by Gary Beene View Post
    Doug,
    We're clearly not communicating here.
    No, we're not, we can agree on that.

    No, this is simply not true. GDI has no bounds either. You can draw something out to infinity but only display the portion of the image that is contained with a viewport (the size of the DC). Likewise, with OpenGL, you can limit the portion of the drawing world that is shown, to be displayed on the rendering context. The two are similar in that regard, not different as you want to insist.

    The mechanisms are certainly different, but not the results.

    I appreciate your comments and they're part of a good general discussion on OpenGL but they don't really address the question I've asked. In the OP my question was whether the rendering could be limited to a rectangle within the rendering context.

    It's easy enough to imagine code that would emulate the concept - draw the entire rendering context with the object centered at the rectangle of interest and scaled to the rectangle size, then draw over (with the background color) anything outside the rectangle of interest. But who would want to do that? Not me!! That's why I asked the question of whether OpenGL had a way to do it without having to brute force the solution.

    Another approach to consider is to do the part about moving the object where I want it, then making the background of the rendering context transparent outside the desired rectangle. I've read threads on the web where folks can make the background transparent, but I've not seen where they can do that selectively.

    My point is that your comments only suggest that you're not aware of any OpenGL statements which make the task easy. They don't close the door on the possibility.
    Maybe I worded this poorly. When rendering to 2D GDI, you specify the bounding rectangle (in whatever coordinate system you want), and draw to that..of course you are right this can be just about anything, but you have defined finite world (the rectangle), and anything you draw outside of it, is clipped.

    In openGL it's not as cut a dry. You define the viewport size, and when setting OGL perspective it needs the aspect. However, you can see parts of the model, not necessarily within the viewport bounds. What is seen depends on many transformations such as perspective and camera position and clipping planes.

    Well, if you mean did you re-iterate what I suggested as the alternative in post #2, then yes.

    And, lastly, please remember that I was just asking a question. That's one of the fun things about programming, is to test the boundaries of what can be done. Just because there's perhaps an easier way to get something done doesn't mean I'm not interested in pursuing the alternatives. Sometimes, "better" changes over time as solutions are found for once-difficult concepts.

    I'd still like to figure out how to do what I asked for in the OP. I'll continue the search ...
    Here, we are not communicating because of the term "window". I think in terms of everything is a window..button controls, static controls, dialogs...

    I think you alluded to using a static control.

    So you would:
    Create a main window
    position toolbars, buttons etc
    position the static control, and use it's DC for the Rendering Context in OpenGL.

    And I agreed, this is one way to go. However, if you wish to process all mouse input from this static control, you'd have to subclass it. I don't think SS_NOTIFY is going to do the trick, but that would depend on what you need. You may also need to do other things like OWNERDRAWN, possibly handle WM_ERASEBKGND. Any way you'd do it, you just wouldn't want the control to do any painting/erasing.

    What I suggested, was create your own CHILD window, replacing the Static control above. The code I showed was a minimal child window. This window would have a callback (in the code I posted "GraphicProc", but it could be of course, anything) where you process you input. This is all a "control" is.

    In your recent posts, you are changing the size of the viewport OpenGL renders to, within the DC. The sizing was half the DC size, and I suspect, that if you gave your window a default background color other than black, when you change the viewport size in OGL, you would see OGL is not clearing the entire background (haven't tested), but only the rectangle of the viewport you gave it. So in this sense, yes you probably can just render to a portion of the window DC, but I think you will have other issues when (if) you try to handle mouse input, sizing etc.
    "Show me a young Conservative and I'll show you someone with no heart. Show me an old Liberal and I'll show you someone with no brains." ― Winston Churchill
    "Socialism is the philosophy of failure, the creed of ignorance and the gospel of envy." ― Winston Churchill

    Comment


    • #22
      Gary:

      You can use ogl to draw to a specific place on the window. Several years ago I set up a series titled "Exploring OpenGL" There was one example where I had two viewports showing two different objects rotating in different directions. I think there is 10 or so examples in the series.

      If I remember correctly the sequence was something like this:

      GLVIEWPORT(X, Y, X1, Y1)
      GLORTHO(X, X1, Y, Y1, Z1, Z2) <---- changed

      GLPUSHMATRIX

      [DRAW OBJECT]

      GLPUSHMATRIX
      GLVIEWPORT(X, Y, X1, Y1)

      GLPOPMATRIX
      [DRAW OBJECT]

      SWAPBUFFERS(DC)
      GLPOPMATRIX



      see http://www.powerbasic.com/support/pb...ight=exploring

      As far as being able to draw to a memory dc and bitbliting to the window, I've never been able to get that to work.
      Last edited by Walt Decker; 25 Oct 2015, 12:56 PM. Reason: link
      Walt Decker

      Comment


      • #23
        PS:

        There's another way to do it. Use a label control on your window and get the DC and RC for that label control.
        Walt Decker

        Comment


        • #24
          Hi Walt!
          Thanks for the comments ...

          You can use ogl to draw to a specific place on the window.
          Yes, the example I gave above shows that. But, the problem is that even though you draw to a selected location on the RC, the entire RC is draw with the background color.

          What I'd like to see is that the drawing to the ViewPort does NOT draw over the entire RC, but rather only acts on the ViewPort area - i.e., outside the viewport remains whatever colors it was before drawing with OpenGL.

          Several years ago I set up a series titled "Exploring OpenGL"
          I just went and tried the example, but it claims I need the GLAUX.DLL and fails to run. I don't see the DLL mentioned - juse the glaux.inc, which I have in my includes folder. Can you suggest why I'm getting that message?

          Use a label control on your window and get the DC and RC for that label...
          Yes, that's how I'm doing it now. I just wondered if there was a way to avoid the need for the label control. Not a particular issue for me, just something I wondered about.

          Comment


          • #25
            GLAUX was deprecated a LOT of years ago, being replaced with GLUT, that has not been updated since another LOT of years. There are open source versions of GLUT, that haven't been updated since 10 years ago.

            But in my headers, you have an include file called AfxGlut.inc, that implements these auxiliary procedures using PB code, e.g. AfxGlutSolidSphere.
            Forum: http://www.jose.it-berater.org/smfforum/index.php

            Comment


            • #26
              Gary:

              I'll go back into my archives and see what I can come up with. It might take a couple of days, I have a ton of OGL stuff in there, but one thing I'm fairly certain about is that you will have to reset the GLCOLOR(R!, G!, B!) value [where R!, G!, B! are reals in the range 0 to 1] for each viewport you use.

              PS: I think the example was done in PBWIN 9x and the ogl includes are for that version of PB. Why it's claiming that glaux.dll is required I have no idea, but i'll check it out an let you know.
              Last edited by Walt Decker; 25 Oct 2015, 04:05 PM.
              Walt Decker

              Comment


              • #27
                Originally posted by Gary Beene View Post

                Yes, that's how I'm doing it now. I just wondered if there was a way to avoid the need for the label control. Not a particular issue for me, just something I wondered about.
                Compilable example of what I was suggesting....but in DDT.

                Code:
                #COMPILE EXE
                #DIM ALL
                #INCLUDE ONCE "win32api.inc"
                
                %IDC_gbcontrol=20
                FUNCTION PBMAIN () AS LONG
                    LOCAL hDlg AS DWORD
                    IF ISFALSE(CreateOGLWindowClass()) THEN EXIT FUNCTION
                    DIALOG NEW PIXELS, %HWND_DESKTOP,"",,,400, 300, %WS_OVERLAPPEDWINDOW OR %WS_VISIBLE TO hDlg
                    'V--Create a minimal window, to use as the DC for OpenGL Rendering...
                    CONTROL ADD "GBControl", hDlg, %IDC_gbcontrol, "", 100, 0, 300, 400, %WS_CHILD OR %WS_VISIBLE
                
                    DIALOG SHOW MODAL hDlg, CALL MainProc()
                END FUNCTION
                
                FUNCTION CreateOGLWindowClass() AS LONG
                    LOCAL classname     AS ASCIIZ * 10
                    LOCAL Isinitialized AS LONG
                    LOCAL wc            AS WndClassEx
                    classname = "GBControl"
                    IsInitialized = GetClassInfoEx(EXE.INST, classname, wc)
                    IF IsInitialized = 0 THEN
                        wc.cbSize        = SIZEOF(wc)
                        wc.style         = %CS_DBLCLKS OR %CS_BYTEALIGNWINDOW
                        wc.lpfnWndProc   = CODEPTR(GBControlProc) 'callback, whatever you want to change it too..
                        wc.cbClsExtra    = 0
                        wc.cbWndExtra    = 0
                        wc.hInstance     = EXE.INST
                        wc.hIcon         = %null
                        wc.hCursor       = LoadCursor(%NULL, BYVAL %IDC_ARROW)
                        wc.hbrBackground = %color_activecaption+1 '%null '<--REC YOU SET TO NULL FOR NO ERASING..
                        wc.lpszMenuName  = %NULL
                        wc.lpszClassName = VARPTR(classname)
                        wc.hIconSm       = wc.hIcon
                        IF RegisterClassEx(wc) THEN FUNCTION = %TRUE
                    ELSE
                        FUNCTION=1
                    END IF
                END FUNCTION
                
                FUNCTION GBControlProc((BYVAL hwnd AS LONG, BYVAL Msg AS LONG, BYVAL wParam AS LONG, BYVAL lParam AS LONG) AS LONG
                    SELECT CASE Msg
                    CASE %WM_LBUTTONDBLCLK
                        ? "I have full control over input"
                    END SELECT
                FUNCTION = DefWindowProc(hwnd, Msg, wParam, lParam)
                END FUNCTION
                
                CALLBACK FUNCTION MainProc() AS LONG
                    LOCAL DLG AS SIZE
                    SELECT CASE AS LONG CB.MSG
                        CASE %WM_SIZE
                            DIALOG GET CLIENT CB.HNDL TO DLG.CX, DLG.CY
                            CONTROL SET SIZE CB.HNDL, %IDC_gbcontrol, DLG.CX-100, DLG.CY
                    END SELECT
                
                END FUNCTION
                "Show me a young Conservative and I'll show you someone with no heart. Show me an old Liberal and I'll show you someone with no brains." ― Winston Churchill
                "Socialism is the philosophy of failure, the creed of ignorance and the gospel of envy." ― Winston Churchill

                Comment


                • #28
                  Gary:

                  Going through all my archives I've found nothing that will do what you want.

                  Using the "3D VIEWPORT" example in the link I provided and changing the GLCLEARCOLOR(0, 0, 0, 0) parameter and the frustum for each view port produces the last background color used. This indicates that the background is used for the entire DC, not just the view port.

                  Going through the ogl super bible and several other sources produced nothing in the way of limiting the background color to just the view port.

                  The only options I see are:

                  1) use a seperate window (as you are currently doing) for rendering and set the GLCLEARCOLOR() background for that window.

                  2) set the GLCLEARCOLOR() to the background window color and then use ogl to plot a bitmap to the view port and render over the top of the bitmap (not tried but should work).

                  PS:
                  I just went and tried the example, but it claims I need the GLAUX.DLL and fails to run. I don't see the DLL mentioned - juse the glaux.inc, which I have in my includes folder. Can you suggest why I'm getting that message?
                  Were you using the view port example?
                  Last edited by Walt Decker; 26 Oct 2015, 10:48 AM. Reason: add comment
                  Walt Decker

                  Comment

                  Working...
                  X