| version 1.6 | | version 1.7 |
|---|
| | |
| #include "key.h" | | #include "key.h" |
| #include "joy.h" | | #include "joy.h" |
| #include "mouse.h" | | #include "mouse.h" |
| | | #include "digi.h" |
| | | #include "args.h" |
| /*#include "event.h"*/ | | /*#include "event.h"*/ |
| | | |
| | | |
| | |
| | | |
| if (!ogl_fullscreen){ | | if (!ogl_fullscreen){ |
| x+=get_win_x_bs();y+=get_win_y_bs(); | | x+=get_win_x_bs();y+=get_win_y_bs(); |
| | | }else{ |
| | | x=GetSystemMetrics(SM_CXSCREEN); |
| | | y=GetSystemMetrics(SM_CYSCREEN); |
| } | | } |
| g_hWnd = CreateWindowEx(0, | | g_hWnd = CreateWindowEx(0, |
| "WinD1X", | | "WinD1X", |
| | |
| flags, | | flags, |
| 0, 0, | | 0, 0, |
| x,y, | | x,y, |
| // GetSystemMetrics(SM_CXSCREEN), | | |
| // GetSystemMetrics(SM_CYSCREEN), | | |
| NULL, | | NULL, |
| NULL, | | NULL, |
| hInst, | | hInst, |
| | |
| key_init(); | | key_init(); |
| mouse_init(0); | | mouse_init(0); |
| joy_init(JOYSTICKID1); | | joy_init(JOYSTICKID1); |
| | | if (!FindArg( "-nosound" )) |
| | | digi_init(); |
| // printf("arch_init successfully completed\n"); | | // printf("arch_init successfully completed\n"); |
| | | |
| OpenGL_Initialize(); | | OpenGL_Initialize(); |
| | |
| key_close(); | | key_close(); |
| mouse_close(); | | mouse_close(); |
| joy_close(); | | joy_close(); |
| | | if (!FindArg( "-nosound" )) |
| | | digi_close(); |
| DestroyWindow(g_hWnd); | | DestroyWindow(g_hWnd); |
| } | | } |
| } | | } |
| | |
| GLPREF_width=x; | | GLPREF_width=x; |
| GLPREF_height=y; | | GLPREF_height=y; |
| if (gl_initialized){ | | if (gl_initialized){ |
| | | if (GLSTATE_width==GLPREF_width && GLSTATE_height==GLPREF_height && GLPREF_windowed!=ogl_fullscreen) |
| | | return 0;//we are already in the right mode, don't do anything. |
| if (!ogl_fullscreen && GLPREF_windowed){ | | if (!ogl_fullscreen && GLPREF_windowed){ |
| SetWindowPos(g_hWnd,0,0,0,x+get_win_x_bs(),y+get_win_y_bs(),SWP_NOMOVE);//the width/height seem to include borders/title/etc.. this isn't an exact value, but I didn't feel like testing enough to find the true values. -MPM | | SetWindowPos(g_hWnd,0,0,0,x+get_win_x_bs(),y+get_win_y_bs(),SWP_NOMOVE);//the width/height seem to include borders/title/etc.. this isn't an exact value, but I didn't feel like testing enough to find the true values. -MPM |
| // SetWindowPos(g_hWnd,0,0,0,x,y,0);//the width/height seem to include borders/title/etc.. this isn't an exact value, but I didn't feel like testing enough to find the true values. -MPM | | // SetWindowPos(g_hWnd,0,0,0,x,y,0);//the width/height seem to include borders/title/etc.. this isn't an exact value, but I didn't feel like testing enough to find the true values. -MPM |
| | |
| // Saved_gamma_values: Initial gamma values | | // Saved_gamma_values: Initial gamma values |
| bool OpenGL_Initialize(void) | | bool OpenGL_Initialize(void) |
| { | | { |
| | | char *errstr=""; |
| int width,height; | | int width,height; |
| int pf; | | int pf; |
| PIXELFORMATDESCRIPTOR pfd, pfd_copy; | | PIXELFORMATDESCRIPTOR pfd, pfd_copy; |
| | |
| retval=ChangeDisplaySettings(&devmode,0); | | retval=ChangeDisplaySettings(&devmode,0); |
| if (retval!=DISP_CHANGE_SUCCESSFUL) | | if (retval!=DISP_CHANGE_SUCCESSFUL) |
| { | | { |
| | | errstr="ChangeDisplaySettings"; |
| // we couldn't even switch to 640x480, we're out of here | | // we couldn't even switch to 640x480, we're out of here |
| // restore screen mode to default | | // restore screen mode to default |
| ChangeDisplaySettings(NULL,0); | | ChangeDisplaySettings(NULL,0); |
| | |
| pf = ChoosePixelFormat(GLPREF_windowdc,&pfd); | | pf = ChoosePixelFormat(GLPREF_windowdc,&pfd); |
| if(pf == 0) | | if(pf == 0) |
| { | | { |
| | | errstr="ChoosePixelFormat"; |
| // no pixel format closely matches | | // no pixel format closely matches |
| goto OpenGLError; | | goto OpenGLError; |
| } | | } |
| | |
| // Set the new PFD | | // Set the new PFD |
| if(SetPixelFormat(GLPREF_windowdc,pf,&pfd)==FALSE) | | if(SetPixelFormat(GLPREF_windowdc,pf,&pfd)==FALSE) |
| { | | { |
| | | errstr="SetPixelFormat"; |
| // unable to set the pixel format | | // unable to set the pixel format |
| goto OpenGLError; | | goto OpenGLError; |
| } | | } |
| | |
| // Now retrieve the PFD, we need to check some things | | // Now retrieve the PFD, we need to check some things |
| if(DescribePixelFormat(GLPREF_windowdc,pf,sizeof(PIXELFORMATDESCRIPTOR),&pfd_copy)==0) | | if(DescribePixelFormat(GLPREF_windowdc,pf,sizeof(PIXELFORMATDESCRIPTOR),&pfd_copy)==0) |
| { | | { |
| | | errstr="DescribePixelFormat"; |
| // unable to get the PFD | | // unable to get the PFD |
| goto OpenGLError; | | goto OpenGLError; |
| } | | } |
| | |
| GL_ResourceContext = wglCreateContext(GLPREF_windowdc); | | GL_ResourceContext = wglCreateContext(GLPREF_windowdc); |
| if(GL_ResourceContext==NULL) | | if(GL_ResourceContext==NULL) |
| { | | { |
| | | errstr="wglCreateContext"; |
| // we couldn't create a context! | | // we couldn't create a context! |
| goto OpenGLError; | | goto OpenGLError; |
| } | | } |
| | |
| OpenGLError: | | OpenGLError: |
| // Shutdown OpenGL | | // Shutdown OpenGL |
| OpenGL_Shutdown(); | | OpenGL_Shutdown(); |
| Error("opengl init error\n"); | | Error("opengl init error: %s\n",errstr); |
| return false; | | return false; |
| } | | } |
| | | |