diff options
author | mwturvey <michael.w.turvey@intel.com> | 2017-03-23 09:56:33 -0700 |
---|---|---|
committer | mwturvey <michael.w.turvey@intel.com> | 2017-03-23 09:56:33 -0700 |
commit | 78b7b6fb520c287caecbe895501898ef5c1440a5 (patch) | |
tree | a72988c97dfc7e724661d0dbed1699f76e9f6498 /redist/CNFGWinDriver.c | |
parent | 280a6599fea76a7d2c16cfe0fcc5c8f37fde66de (diff) | |
parent | 39ef5af74702c8825a82f65cf68e6af875a814ee (diff) | |
download | libsurvive-78b7b6fb520c287caecbe895501898ef5c1440a5.tar.gz libsurvive-78b7b6fb520c287caecbe895501898ef5c1440a5.tar.bz2 |
Merge branch 'master' into alternate_disambiguator
# Conflicts:
# src/survive_data.c
# src/survive_vive.c
Diffstat (limited to 'redist/CNFGWinDriver.c')
-rw-r--r-- | redist/CNFGWinDriver.c | 71 |
1 files changed, 66 insertions, 5 deletions
diff --git a/redist/CNFGWinDriver.c b/redist/CNFGWinDriver.c index a029419..c5da925 100644 --- a/redist/CNFGWinDriver.c +++ b/redist/CNFGWinDriver.c @@ -13,7 +13,6 @@ static HWND lsHWND; static HDC lsWindowHDC; static HDC lsHDC; - #ifdef RASTERIZER #include "CNFGRasterizer.h" @@ -32,14 +31,34 @@ static void InternalHandleResize(); #endif +#ifdef CNFGOGL +#include <GL/gl.h> +static HGLRC hRC=NULL; +static void InternalHandleResize() { } +void CNFGSwapBuffers() +{ + SwapBuffers(lsWindowHDC); +} +#endif + void CNFGGetDimensions( short * x, short * y ) { + static int lastx, lasty; + RECT window; + GetClientRect( lsHWND, &window ); + bufferx = ( window.right - window.left); + buffery = ( window.bottom - window.top); + if( bufferx != lastx || buffery != lasty ) + { + lastx = bufferx; + lasty = buffery; + InternalHandleResize(); + } *x = bufferx; *y = buffery; } - void CNFGUpdateScreenWithBitmap( unsigned long * data, int w, int h ) { RECT r; @@ -126,9 +145,49 @@ void CNFGSetup( const char * name_of_window, int width, int height ) hInstance, NULL); //no parameters to pass - lsWindowHDC = GetDC( lsHWND ); +#ifdef CNFGOGL + //From NeHe + static PIXELFORMATDESCRIPTOR pfd = + { + sizeof(PIXELFORMATDESCRIPTOR), + 1, + PFD_DRAW_TO_WINDOW | + PFD_SUPPORT_OPENGL | + PFD_DOUBLEBUFFER, + PFD_TYPE_RGBA, + 32, + 0, 0, 0, 0, 0, 0, + 0, + 0, + 0, + 0, 0, 0, 0, + 16, + 0, + 0, + PFD_MAIN_PLANE, + 0, + 0, 0, 0 + }; + GLuint PixelFormat = ChoosePixelFormat( lsWindowHDC, &pfd ); + if( !SetPixelFormat( lsWindowHDC, PixelFormat, &pfd ) ) + { + MessageBox( 0, "Could not create PFD for OpenGL Context\n", 0, 0 ); + exit( -1 ); + } + if (!(hRC=wglCreateContext(lsWindowHDC))) // Are We Able To Get A Rendering Context? + { + MessageBox( 0, "Could not create OpenGL Context\n", 0, 0 ); + exit( -1 ); + } + if(!wglMakeCurrent(lsWindowHDC,hRC)) // Try To Activate The Rendering Context + { + MessageBox( 0, "Could not current OpenGL Context\n", 0, 0 ); + exit( -1 ); + } +#endif + lsHDC = CreateCompatibleDC( lsWindowHDC ); lsBitmap = CreateCompatibleBitmap( lsWindowHDC, bufferx, buffery ); SelectObject( lsHDC, lsBitmap ); @@ -182,6 +241,7 @@ void CNFGHandleInput() } } +#ifndef CNFGOGL #ifndef RASTERIZER @@ -237,8 +297,7 @@ void CNFGClearFrame() DeleteObject( lsClearBrush ); lsClearBrush = CreateSolidBrush( CNFGBGColor ); SelectObject( lsHDC, lsClearBrush ); - - FillRect( lsHDC, &r, lsClearBrush ); + FillRect( lsHDC, &r, lsClearBrush); } void CNFGTackPoly( RDPoint * points, int verts ) @@ -287,3 +346,5 @@ void CNFGSwapBuffers() void CNFGInternalResize( short bufferx, short buffery ) { } #endif +#endif + |