Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Graphics
  4. Copy screen & render with OpenGL

Copy screen & render with OpenGL

Scheduled Pinned Locked Moved Graphics
cssgraphicsgame-devsalesquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • X Offline
    X Offline
    XTAL256
    wrote on last edited by
    #1

    Hi, i am writing an app that copies the screen, warps/distorts the image, then draws it back. I already got the code working in a visualization i am making for Windows Media Player but for some reason it won't work now.

    glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    enableBlend();
    glColor4f(1.0f, 1.0f, 1.0f, 0.9f);
    renderBackground(wf); // Render warped background

    enableTexture(image);
    glBegin(GL_QUADS); // Draw image over background
    glTexCoord2f(0, 1); glVertex2f(0, 0);
    glTexCoord2f(0, 0); glVertex2f(0, 512);
    glTexCoord2f(1, 0); glVertex2f(512, 512);
    glTexCoord2f(1, 1); glVertex2f(512, 0);
    glEnd();

    glBindTexture(GL_TEXTURE_2D, backTexture);// Copy image to texture
    glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 512, 512, 0);

    disableTexture();
    disableBlend();

    That's basically it, renderBackground() draws the texture over a grid of warp points which is stored in a WarpFile object. The enable/disable methods are just wrappers for the OpenGL commands. Is there anything i am doing wrong? I tried pbuffers do copy/render to but it was too hard. If you need me to post more code (like the renderBackground method) just ask thanks

    -------------------------------- Customer in computer shop: "Can you copy the Internet onto this disk for me?"

    X 1 Reply Last reply
    0
    • X XTAL256

      Hi, i am writing an app that copies the screen, warps/distorts the image, then draws it back. I already got the code working in a visualization i am making for Windows Media Player but for some reason it won't work now.

      glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

      enableBlend();
      glColor4f(1.0f, 1.0f, 1.0f, 0.9f);
      renderBackground(wf); // Render warped background

      enableTexture(image);
      glBegin(GL_QUADS); // Draw image over background
      glTexCoord2f(0, 1); glVertex2f(0, 0);
      glTexCoord2f(0, 0); glVertex2f(0, 512);
      glTexCoord2f(1, 0); glVertex2f(512, 512);
      glTexCoord2f(1, 1); glVertex2f(512, 0);
      glEnd();

      glBindTexture(GL_TEXTURE_2D, backTexture);// Copy image to texture
      glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 512, 512, 0);

      disableTexture();
      disableBlend();

      That's basically it, renderBackground() draws the texture over a grid of warp points which is stored in a WarpFile object. The enable/disable methods are just wrappers for the OpenGL commands. Is there anything i am doing wrong? I tried pbuffers do copy/render to but it was too hard. If you need me to post more code (like the renderBackground method) just ask thanks

      -------------------------------- Customer in computer shop: "Can you copy the Internet onto this disk for me?"

      X Offline
      X Offline
      XTAL256
      wrote on last edited by
      #2

      I FIXED IT! These are the 3 lines directly before the code above:

      if (bgType = BG_BLUR)
      renderBlur(wf, 20, 0.2f);
      else if (bgType = BG_WARP) {
      // All of the above code is here
      }

      See something wrong? I didn't until just then. = instead of == !!! I can't believe i made such a simple mistake. I know everyone makes silly mistakes but i seem to be getting == confused with = a lot lately. Sorry if i'm rambling on, i just had to say this. That one bug has really been pissing me off :mad::confused::wtf::(:((

      -------------------------------- Customer in computer shop: "Can you copy the Internet onto this disk for me?"

      L C 2 Replies Last reply
      0
      • X XTAL256

        I FIXED IT! These are the 3 lines directly before the code above:

        if (bgType = BG_BLUR)
        renderBlur(wf, 20, 0.2f);
        else if (bgType = BG_WARP) {
        // All of the above code is here
        }

        See something wrong? I didn't until just then. = instead of == !!! I can't believe i made such a simple mistake. I know everyone makes silly mistakes but i seem to be getting == confused with = a lot lately. Sorry if i'm rambling on, i just had to say this. That one bug has really been pissing me off :mad::confused::wtf::(:((

        -------------------------------- Customer in computer shop: "Can you copy the Internet onto this disk for me?"

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        VizCoder wrote:

        That one bug has really been p...

        You should consider switching to a modern programming language ... :)

        Luc Pattyn


        try { [Search CP Articles] [Search CP Forums] [Forum Guidelines] [My Articles] } catch { [Google] }


        1 Reply Last reply
        0
        • X XTAL256

          I FIXED IT! These are the 3 lines directly before the code above:

          if (bgType = BG_BLUR)
          renderBlur(wf, 20, 0.2f);
          else if (bgType = BG_WARP) {
          // All of the above code is here
          }

          See something wrong? I didn't until just then. = instead of == !!! I can't believe i made such a simple mistake. I know everyone makes silly mistakes but i seem to be getting == confused with = a lot lately. Sorry if i'm rambling on, i just had to say this. That one bug has really been pissing me off :mad::confused::wtf::(:((

          -------------------------------- Customer in computer shop: "Can you copy the Internet onto this disk for me?"

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          Get in the habit of doing this: if (BG_WARP == bgType) That won't compile with the single =

          Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups