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. OpenGL directly on the desktop

OpenGL directly on the desktop

Scheduled Pinned Locked Moved Graphics
graphicsgame-devquestion
2 Posts 2 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.
  • A Offline
    A Offline
    Ajko
    wrote on last edited by
    #1

    I'm trying to add visual effects to the desktop. I want to be able to use the desktop as normal at the same time. This is what I have been coding so far. But the triangle is never painted to the screen. #include #include int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow) { HDC hDC; HGLRC hRC; float theta = 0.0f; PIXELFORMATDESCRIPTOR pfd; int format; // get the device context for the whole screen instead of a window hDC = GetWindowDC(NULL); // set the pixel format for the DC ZeroMemory( &pfd, sizeof( pfd ) ); pfd.nSize = sizeof( pfd ); pfd.nVersion = 1; pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; pfd.iPixelType = PFD_TYPE_RGBA; pfd.cColorBits = 24; pfd.cDepthBits = 16; pfd.iLayerType = PFD_MAIN_PLANE; format = ChoosePixelFormat( hDC, &pfd ); SetPixelFormat( hDC, format, &pfd ); // create and enable the render context (RC) hRC = wglCreateContext( hDC ); wglMakeCurrent( hDC, hRC ); while ( true ) { glClearColor( 0.0f, 0.0f, 0.0f, 0.0f ); glClear( GL_COLOR_BUFFER_BIT ); glPushMatrix(); glRotatef( theta, 0.0f, 0.0f, 1.0f ); glBegin( GL_TRIANGLES ); glColor3f( 1.0f, 0.0f, 0.0f ); glVertex2f( 0.0f, 1.0f ); glColor3f( 0.0f, 1.0f, 0.0f ); glVertex2f( 0.87f, -0.5f ); glColor3f( 0.0f, 0.0f, 1.0f ); glVertex2f( -0.87f, -0.5f ); glEnd(); glPopMatrix(); SwapBuffers( hDC ); theta += 1.0f; } return 0; } Have anyone done something like this before?

    X 1 Reply Last reply
    0
    • A Ajko

      I'm trying to add visual effects to the desktop. I want to be able to use the desktop as normal at the same time. This is what I have been coding so far. But the triangle is never painted to the screen. #include #include int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow) { HDC hDC; HGLRC hRC; float theta = 0.0f; PIXELFORMATDESCRIPTOR pfd; int format; // get the device context for the whole screen instead of a window hDC = GetWindowDC(NULL); // set the pixel format for the DC ZeroMemory( &pfd, sizeof( pfd ) ); pfd.nSize = sizeof( pfd ); pfd.nVersion = 1; pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; pfd.iPixelType = PFD_TYPE_RGBA; pfd.cColorBits = 24; pfd.cDepthBits = 16; pfd.iLayerType = PFD_MAIN_PLANE; format = ChoosePixelFormat( hDC, &pfd ); SetPixelFormat( hDC, format, &pfd ); // create and enable the render context (RC) hRC = wglCreateContext( hDC ); wglMakeCurrent( hDC, hRC ); while ( true ) { glClearColor( 0.0f, 0.0f, 0.0f, 0.0f ); glClear( GL_COLOR_BUFFER_BIT ); glPushMatrix(); glRotatef( theta, 0.0f, 0.0f, 1.0f ); glBegin( GL_TRIANGLES ); glColor3f( 1.0f, 0.0f, 0.0f ); glVertex2f( 0.0f, 1.0f ); glColor3f( 0.0f, 1.0f, 0.0f ); glVertex2f( 0.87f, -0.5f ); glColor3f( 0.0f, 0.0f, 1.0f ); glVertex2f( -0.87f, -0.5f ); glEnd(); glPopMatrix(); SwapBuffers( hDC ); theta += 1.0f; } return 0; } Have anyone done something like this before?

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

      Firstly, what do the #includes actually include. I assume they are unimportant and have either been left out or forgotten. But more to the point, you should have a look at PFD_DRAW_TO_WINDOW in the variable pfd.dwFlags. I too am using OpenGL for a small project I am making. I don't know that much about it but i think you might have to set it to draw to the DESKTOP. I think the desktop is just a special kind of window. What you are trying to do sounds interesting. Let me know when you have it working

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

      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