aboutsummaryrefslogtreecommitdiff
path: root/redist/CNFGWinDriver.c
diff options
context:
space:
mode:
authorcnlohr <lohr85@gmail.com>2017-03-22 00:12:31 -0400
committercnlohr <lohr85@gmail.com>2017-03-22 00:12:31 -0400
commit3694605b23b1019488844bf448d461eacc69077f (patch)
tree56b65755c20e09074d6c1db0c31adb4ee8c7a413 /redist/CNFGWinDriver.c
parent8253e3c3adbb54ebc3d3c8e02c017e900a83edb0 (diff)
downloadlibsurvive-3694605b23b1019488844bf448d461eacc69077f.tar.gz
libsurvive-3694605b23b1019488844bf448d461eacc69077f.tar.bz2
Update RawDraw to version that can at least support OpenGL if we want it.
Diffstat (limited to 'redist/CNFGWinDriver.c')
-rw-r--r--redist/CNFGWinDriver.c71
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
+