Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <GL/gl.h>
- #include <GL/glu.h>
- #include <stdio.h>
- #include <time.h>
- #define GET_X_LPARAM(a) ((short)LOWORD(a))
- #define GET_Y_LPARAM(a) ((short)HIWORD(a))
- unsigned short PlaneB[0x1000/2];
- POINT camera = {0,0};
- POINT mouse;
- double zoom = 1;
- bool showgray = false;
- int state = 0;
- int drawtype = 0;
- struct Ground
- {
- int width;
- int height;
- double *data;
- Ground(int _width, int _height)
- {
- width = _width;
- height = _height;
- data = (double *)malloc(width*height*sizeof(double));
- for (int x=0; x<width; ++x)
- for (int y=0; y<height; ++y)
- (*this)[x][y] = 0;
- }
- double *operator [](int x)
- {
- return data+x*height;
- }
- ~Ground()
- {
- if (data)
- free(data);
- }
- };
- struct DuneGround
- {
- int width;
- int height;
- BYTE *data;
- DuneGround(int _width, int _height)
- {
- width = _width;
- height = _height;
- data = (BYTE *)malloc(width*height*sizeof(BYTE));
- for (int x=0; x<width; ++x)
- for (int y=0; y<height; ++y)
- (*this)[x][y] = 0xB0;
- }
- BYTE *operator [](int x)
- {
- return data+x*height;
- }
- ~DuneGround()
- {
- if (data)
- free(data);
- }
- DuneGround(const DuneGround & g)
- {
- width = g.width;
- height = g.height;
- data = (BYTE *)malloc(width*height*sizeof(BYTE));
- memcpy(data,g.data,width*height*sizeof(BYTE));
- }
- const DuneGround & operator = (const DuneGround &g)
- {
- free(data);
- width = g.width;
- height = g.height;
- data = (BYTE *)malloc(width*height*sizeof(BYTE));
- memcpy(data,g.data,width*height*sizeof(BYTE));
- return (*this);
- }
- };
- /*struct Point
- {
- double x,y;
- }*/
- DuneGround duneGround(64,64);
- DuneGround duneGroundNew(64,64);
- Ground g(2*64+1,2*64+1);
- GLuint GroundTiles;
- GLuint GroundGrey;
- // Declarations //////////////////////////////////////////////////////
- GLuint LoadTextureRAW( const char * filename, int wrap );
- GLuint LoadVRAM( const char * vram, const char * pal);
- GLuint GenerateGround();
- void ChangeState(int _state);
- void RangeGround(double z);
- void LocalPick(int x, int y, int type);
- void LoadMap( const char * filename );
- void SaveMap( const char * filename );
- void FreeTexture( GLuint texture );
- LRESULT CALLBACK WndProc( HWND hWnd, UINT message,
- WPARAM wParam, LPARAM lParam );
- VOID EnableOpenGL( HWND hWnd, HDC * hDC, HGLRC * hRC );
- VOID DisableOpenGL( HWND hWnd, HDC hDC, HGLRC hRC );
- void UpdateViewport(HWND hWnd);
- void Render(HWND hWnd, HDC hDC);
- // WinMain ///////////////////////////////////////////////////////////
- int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
- LPSTR lpCmdLine, int iCmdShow )
- {
- WNDCLASS wc;
- HWND hWnd;
- HDC hDC;
- HGLRC hRC;
- MSG msg;
- BOOL bQuit = FALSE;
- // register window class
- wc.style = CS_OWNDC;
- wc.lpfnWndProc = WndProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hInstance = hInstance;
- wc.hIcon = LoadIcon( NULL, IDI_APPLICATION );
- wc.hCursor = LoadCursor( NULL, IDC_ARROW );
- wc.hbrBackground = (HBRUSH)GetStockObject( BLACK_BRUSH );
- wc.lpszMenuName = NULL;
- wc.lpszClassName = "GLSample";
- RegisterClass( &wc );
- // create main window
- hWnd = CreateWindow(
- "GLSample", "OpenGL Texture Sample",
- WS_CAPTION | WS_POPUPWINDOW | WS_VISIBLE | WS_MAXIMIZEBOX | WS_THICKFRAME,
- 0, 0, 800, 600,
- NULL, NULL, hInstance, NULL );
- // enable OpenGL for the window
- EnableOpenGL( hWnd, &hDC, &hRC );
- UpdateViewport( hWnd);
- // load our texture
- GroundTiles = LoadTextureRAW( "tex1.bmp", TRUE );
- //LoadMap("map_18.bin");
- srand(time(0));
- GroundGrey = GenerateGround();
- //texture = LoadVRAM( "vram.bin", "pal.bin" );
- int startTime = GetTickCount();
- int prevTime = startTime;
- // program main loop
- while ( !bQuit ) {
- // check for messages
- if ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) {
- // handle or dispatch messages
- if ( msg.message == WM_QUIT ) {
- bQuit = TRUE;
- } else {
- TranslateMessage( &msg );
- DispatchMessage( &msg );
- }
- } else {
- int n = GetTickCount();
- if (n - prevTime > 1000/40)
- {
- Render(hWnd, hDC);
- prevTime = n;
- }
- else
- Sleep(1);
- }
- }
- // free the texture
- FreeTexture( GroundTiles );
- FreeTexture( GroundGrey );
- // shutdown OpenGL
- DisableOpenGL( hWnd, hDC, hRC );
- // destroy the window explicitly
- DestroyWindow( hWnd );
- return msg.wParam;
- }
- void Render(HWND hWnd, HDC hDC)
- {
- // OpenGL animation code goes here
- RECT rc;
- GetClientRect(hWnd,&rc);
- double cx = int((camera.x+mouse.x-(rc.right/2))/32.0/zoom);
- double cy = int((camera.y+mouse.y-(rc.bottom/2))/32.0/zoom);
- if (state == 1
- && (int)(cx*2) <64*2+1 && (int)(cx*2)>=0
- && (int)(cy*2) <64*2+1 && (int)(cy*2)>=0)
- LocalPick(cx*2,cy*2,drawtype);//RangeGround(g[(int)(cx*2)][(int)(cy*2)]);*/
- glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
- glClear( GL_COLOR_BUFFER_BIT );
- // setup texture mapping
- glEnable( GL_TEXTURE_2D );
- glBindTexture( GL_TEXTURE_2D, GroundTiles );
- glPushMatrix();
- glBegin( GL_QUADS );
- // tiles
- /*double tw = 1.0/64;
- for (int i=0; i<32; ++i)
- {
- for (int j=0; j<64; ++j)
- {
- int id = PlaneB[i*64+j]&0x7FF;
- int idx = id&63;
- int idy = id>>6;
- glTexCoord2d(tw*(idx+0),tw*(idy+0)); glVertex2d(-1.0+tw*j,+1.0-tw*i);
- glTexCoord2d(tw*(idx+1),tw*(idy+0)); glVertex2d(-1.0+tw*(j+1),+1.0-tw*i);
- glTexCoord2d(tw*(idx+1),tw*(idy+1)); glVertex2d(-1.0+tw*(j+1),+1.0-tw*(i+1));
- glTexCoord2d(tw*(idx+0),tw*(idy+1)); glVertex2d(-1.0+tw*j,+1.0-tw*(i+1));
- }
- }
- glTexCoord2d(0.0,0.0); glVertex2d(-8.0,+8.0);
- glTexCoord2d(1.0,0.0); glVertex2d(+8.0,+8.0);
- glTexCoord2d(1.0,1.0); glVertex2d(+8.0,-8.0);
- glTexCoord2d(0.0,1.0); glVertex2d(-8.0,-8.0);*/
- GetClientRect(hWnd, &rc);
- double tw = 1.0/16;
- for (int i=0; i<64; ++i)
- {
- for (int j=0; j<64; ++j)
- {
- int id;
- if (state == 1)
- id = duneGroundNew[j][i];
- else
- id = duneGround[j][i];
- int idx = id&15;
- int idy = (id>>4);
- glTexCoord2d(tw*(idx+0),1-tw*(idy+0)); glVertex2d(j,-i);
- glTexCoord2d(tw*(idx+1),1-tw*(idy+0)); glVertex2d(j+1,-i);
- glTexCoord2d(tw*(idx+1),1-tw*(idy+1)); glVertex2d(j+1,-(i+1));
- glTexCoord2d(tw*(idx+0),1-tw*(idy+1)); glVertex2d(j,-(i+1));
- }
- }
- glEnd();
- if (showgray)
- {
- glBindTexture( GL_TEXTURE_2D, GroundGrey );
- glBegin( GL_QUADS );
- glTexCoord2d(0,0); glVertex2d(0,-0);
- glTexCoord2d(1,0); glVertex2d(64,-0);
- glTexCoord2d(1,1); glVertex2d(64,-64);
- glTexCoord2d(0,1); glVertex2d(0,-64);
- glEnd();
- }
- /*glBindTexture( GL_TEXTURE_2D, texture );
- glBegin( GL_QUADS );
- glTexCoord2d(tw*(3+0),1-tw*(0+0)); glVertex2d(cx,-cy);
- glTexCoord2d(tw*(3+1),1-tw*(0+0)); glVertex2d(cx+1,-cy);
- glTexCoord2d(tw*(3+1),1-tw*(0+1)); glVertex2d(cx+1,-cy-1);
- glTexCoord2d(tw*(3+0),1-tw*(0+1)); glVertex2d(cx,-cy-1);
- glEnd();*/
- glPopMatrix();
- SwapBuffers( hDC );
- }
- // Texture ///////////////////////////////////////////////////////////
- // load a 256x256 RGB .RAW file as a texture
- GLuint LoadTextureRAW( const char * filename, int wrap )
- {
- GLuint texture;
- int width, height;
- BYTE * data;
- FILE * file;
- FILE *f;
- BYTE tmp;
- int i;
- // open texture data
- file = fopen( filename, "rb" );
- if ( file == NULL ) return 0;
- // allocate buffer
- width = 512;
- height = 512;
- data = (BYTE*)malloc( width * height * 3 );
- // read texture data
- fseek( file, 0x36, SEEK_SET);
- fread( data, width * height * 3, 1, file );
- fclose( file );
- for (i=0; i<width*height; ++i)
- {
- tmp = data[i*3];
- data[i*3] = data[i*3+2];
- data[i*3+2] = tmp;
- }
- // allocate a texture name
- glGenTextures( 1, &texture );
- // select our current texture
- glBindTexture( GL_TEXTURE_2D, texture );
- // select modulate to mix texture with color for shading
- glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
- // when texture area is small, bilinear filter the closest MIP map
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
- // when texture area is large, bilinear filter the first MIP map
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
- // if wrap is true, the texture wraps over at the edges (repeat)
- // ... false, the texture ends at the edges (clamp)
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
- wrap ? GL_REPEAT : GL_CLAMP );
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
- wrap ? GL_REPEAT : GL_CLAMP );
- // build our texture MIP maps
- //gluBuild2DMipmaps( GL_TEXTURE_2D, 3, width,
- // height, GL_RGB, GL_UNSIGNED_BYTE, data );
- glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, width,
- height, 0, GL_RGB, GL_UNSIGNED_BYTE, data );
- // free buffer
- free( data );
- return texture;
- }
- double randf()
- {
- return rand()/double(RAND_MAX);
- }
- void GenerateGroundRecursive(Ground &g, int x, int y, int width, int height)
- {
- if (width <= 1 || height <= 1)
- return;
- double a,b,c,d;
- a = g[x ][y ];
- b = g[x+width][y ];
- c = g[x ][y+height];
- d = g[x+width][y+height];
- g[(x + (x + width))/2][ y ] = (a + b)/2;
- g[ x ][(y + (y + height))/2] = (a + c)/2;
- g[(x + (x + width))/2][ y + height ] = (c + d)/2;
- g[ x + width ][(y + (y + height))/2] = (b + d)/2;
- double z = (a+b+c+d)/4+((-1+randf()*2)*width/64/2);
- if (z > 1)
- z = 1;
- if (z < 0)
- z = 0;
- g[(x + (x + width))/2][(y + (y + height))/2] = z;
- GenerateGroundRecursive(g, x , y , width/2, height/2);
- GenerateGroundRecursive(g, x + width/2, y , width/2, height/2);
- GenerateGroundRecursive(g, x , y + height/2, width/2, height/2);
- GenerateGroundRecursive(g, x + width/2, y + height/2, width/2, height/2);
- }
- void LocalPick(int x, int y, int type)
- {
- static bool was[2*64+1][2*64+1];
- for (int i=0; i<2*64+1; ++i)
- for (int j=0; j<2*64+1; ++j)
- was[i][j] = false;
- static int X[(2*64+1)*(2*64+1)];
- static int Y[(2*64+1)*(2*64+1)];
- double z = g[x][y];
- int s = 0,e = 0;
- X[e] = x;
- Y[e] = y;
- was[x][y] = true;
- ++e;
- while (s < e)
- {
- for (int i=-1; i<2; ++i)
- for (int j=-1; j<2; ++j)
- if (X[s]+i>=0 && X[s]+i<2*64+1
- && Y[s]+j>=0 && Y[s]+j<2*64+1
- && !was[X[s]+i][Y[s]+j]
- && g[X[s]+i][Y[s]+j]>=z)
- {
- X[e] = X[s]+i;
- Y[e] = Y[s]+j;
- was[X[e]][Y[e]] = true;
- ++e;
- }
- ++s;
- }
- for (int x=0; x<64; ++x)
- {
- for (int y=0; y<64; ++y)
- {
- int mask = 0;
- for (int i=0; i<3; ++i)
- for (int j=0; j<3; ++j)
- if (was[i+x*2][j+y*2])
- mask |= 1<<(i+j*3);
- int k = 0;
- //1 2 4
- //8 16 32
- //64 128 256
- if ( (mask&(1+2+4)) == (1+2+4))
- k++;
- if ( (mask&(4+32+256)) == (4+32+256))
- k |= 2;
- if ( (mask&(64+128+256)) == (64+128+256))
- k |= 4;
- if ( (mask&(1+8+64)) == (1+8+64))
- k |= 8;
- int id = duneGround[x][y];
- if ( type == 0 )
- {
- id = 0x80+k;
- if ( k == 0)
- id = duneGround[x][y];
- if ( k == 0 && (mask & 16)) // point
- id = 0x80;
- if ( k == 3 && !(mask & 16))
- id = 0x3C;
- if ( k == 6 && !(mask & 16))
- id = 0x3D;
- if ( k == 12 && !(mask & 16))
- id = 0x3F;
- if ( k == 9 && !(mask & 16))
- id = 0x3E;
- }
- if ( type == 1 )
- {
- id = 0xB0+k;
- if ( k == 0)
- id = duneGround[x][y];
- if ( k == 3 && !(mask & 16))
- id = 0x40;
- if ( k == 6 && !(mask & 16))
- id = 0x41;
- if ( k == 12 && !(mask & 16))
- id = 0x43;
- if ( k == 9 && !(mask & 16))
- id = 0x42;
- }
- if ( type == 2 )
- {
- id = 0xC0+k;
- if ( k == 0)
- id = duneGround[x][y];
- if ( k == 3 && !(mask & 16))
- id = 0x44;
- if ( k == 6 && !(mask & 16))
- id = 0x45;
- if ( k == 12 && !(mask & 16))
- id = 0x47;
- if ( k == 9 && !(mask & 16))
- id = 0x46;
- }
- duneGroundNew[x][y] = id;
- }
- }
- }
- void RangeGround(double z)
- {
- for (int x=0; x<64; ++x)
- {
- for (int y=0; y<64; ++y)
- {
- int mask = 0;
- for (int i=0; i<3; ++i)
- for (int j=0; j<3; ++j)
- if (g[i+x*2][j+y*2]>z)
- mask |= 1<<(i+j*3);
- int k = 0;
- //1 2 4
- //8 16 32
- //64 128 256
- if ( (mask&(1+2+4)) == (1+2+4))
- k++;
- if ( (mask&(4+32+256)) == (4+32+256))
- k |= 2;
- if ( (mask&(64+128+256)) == (64+128+256))
- k |= 4;
- if ( (mask&(1+8+64)) == (1+8+64))
- k |= 8;
- int id = 0x80+k;
- if ( k == 0)
- id = 0xB0;
- if ( k == 0 && (mask & 16))
- id = 0x80;
- if ( k == 3 && !(mask & 16))
- id = 0x3C;
- if ( k == 6 && !(mask & 16))
- id = 0x3D;
- if ( k == 12 && !(mask & 16))
- id = 0x3F;
- if ( k == 9 && !(mask & 16))
- id = 0x3E;
- duneGround[x][y] = id;
- }
- }
- }
- GLuint GenerateGround()
- {
- g[ 0][ 0] = randf();
- g[g.width-1][ 0] = randf();
- g[ 0][g.height-1] = randf();
- g[g.width-1][g.height-1] = randf();
- GenerateGroundRecursive(g, 0, 0, g.width-1, g.height-1);
- BYTE *data = (BYTE*)malloc( (g.width-1) * (g.height-1) * 3 );
- for (int x=0; x<g.width-1; ++x)
- {
- for (int y=0; y<g.height-1; ++y)
- {
- for (int i=0; i<3; ++i)
- data[(x + y*(g.width-1))*3 + i] = g[x][y]*255;
- }
- }
- GLuint texture;
- glGenTextures( 1, &texture );
- glBindTexture( GL_TEXTURE_2D, texture );
- glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
- // when texture area is small, bilinear filter the closest MIP map
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
- // when texture area is large, bilinear filter the first MIP map
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
- // if wrap is true, the texture wraps over at the edges (repeat)
- // ... false, the texture ends at the edges (clamp)
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP );
- glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP );
- glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, g.width-1, g.height-1, 0, GL_RGB, GL_UNSIGNED_BYTE, data );
- free(data);
- return texture;
- }
- void LoadMap( const char * filename )
- {
- FILE *f = fopen(filename, "rb");
- if (!f)
- return;
- BYTE tmp;
- for (int y=0; y<64; ++y)
- for (int x=0; x<64; ++x)
- {
- fread(&tmp,1,1,f);
- duneGround[x][y]=tmp;
- }
- fclose(f);
- }
- void SaveMap( const char * filename )
- {
- FILE *f = fopen(filename,"wb");
- if (!f)
- return;
- for (int y=0; y<64; ++y)
- for (int x=0; x<64; ++x)
- fwrite(&duneGround[x][y],1,1,f);
- fclose(f);
- }
- void FreeTexture( GLuint texture )
- {
- glDeleteTextures( 1, &texture );
- }
- bool mousedown = false;
- void UpdateViewport(HWND hWnd)
- {
- RECT rc;
- GetClientRect(hWnd, &rc);
- glViewport( 0, 0, rc.right, rc.bottom);
- glMatrixMode( GL_PROJECTION );
- glLoadIdentity();
- //gluOrtho2D( 0,0,500,500);//camera.x, camera.y, camera.x+rc.right, camera.y+rc.bottom);
- double scale = 1/32.0/zoom;
- glScalef(64.0/rc.right*zoom,64.0/rc.bottom*zoom,1);
- glTranslatef( -camera.x*scale, camera.y*scale, 0);
- glMatrixMode( GL_MODELVIEW );
- }
- void ChangeState(int _state)
- {
- state = _state;
- if (state == 1)
- duneGroundNew = duneGround;
- }
- // Window Proc ///////////////////////////////////////////////////////
- LRESULT CALLBACK WndProc( HWND hWnd, UINT message,
- WPARAM wParam, LPARAM lParam )
- {
- switch ( message ) {
- case WM_CREATE:
- return 0;
- case WM_CLOSE:
- PostQuitMessage( 0 );
- return 0;
- case WM_SIZE:
- UpdateViewport(hWnd);
- break;
- case WM_DESTROY:
- return 0;
- case WM_KEYDOWN:
- switch ( wParam ) {
- case VK_ESCAPE:
- PostQuitMessage( 0 );
- return 0;
- case 'S':
- SaveMap("map.bin");
- return 0;
- case 'R':
- FreeTexture(GroundGrey);
- GroundGrey = GenerateGround();
- return 0;
- case 'E':
- ChangeState(state^1);
- return 0;
- case '0':
- drawtype = 0;
- return 0;
- case '1':
- drawtype = 1;
- return 0;
- case '2':
- drawtype = 2;
- return 0;
- case '3':
- drawtype = 3;
- return 0;
- case 'C':
- for (int x=0; x<duneGround.width; ++x)
- for (int y=0; y<duneGround.height; ++y)
- duneGround[x][y] = 0xB0;
- return 0;
- case VK_SPACE:
- showgray = !showgray;
- return 0;
- }
- return 0;
- case WM_MOUSEWHEEL:
- {
- RECT rc;
- GetClientRect(hWnd,&rc);
- mouse.x = GET_X_LPARAM(lParam);
- mouse.y = GET_Y_LPARAM(lParam);
- short zDelta = HIWORD(wParam);
- if (zDelta > 0)
- {
- zoom *= 1.2;
- camera.x *= 1.2;//(camera.x + mouse.x) * (zoom/(zoom-0.1)) - mouse.x;
- camera.y *= 1.2;//(camera.y + mouse.y) * (zoom/(zoom-0.1)) - mouse.y;
- }
- else
- {
- zoom /= 1.2;
- camera.x /= 1.2;
- camera.y /= 1.2;
- }
- UpdateViewport(hWnd);
- }
- break;
- case WM_LBUTTONDOWN:
- {
- SetCapture(hWnd);
- mouse.x = GET_X_LPARAM(lParam);
- mouse.y = GET_Y_LPARAM(lParam);
- RECT rc;
- GetClientRect(hWnd,&rc);
- int cx = int((camera.x+mouse.x-(rc.right/2))/32.0/zoom);
- int cy = int((camera.y+mouse.y-(rc.bottom/2))/32.0/zoom);
- if (state == 1)
- duneGround = duneGroundNew;
- mousedown = true;
- }
- break;
- case WM_MOUSEMOVE:
- if (mousedown)
- {
- int xPos = mouse.x; mouse.x = GET_X_LPARAM(lParam);
- int yPos = mouse.y; mouse.y = GET_Y_LPARAM(lParam);
- camera.x -= mouse.x-xPos;
- camera.y -= mouse.y-yPos;
- UpdateViewport(hWnd);
- }
- mouse.x = GET_X_LPARAM(lParam);
- mouse.y = GET_Y_LPARAM(lParam);
- break;
- case WM_LBUTTONUP:
- ReleaseCapture();
- mousedown = false;
- break;
- }
- return DefWindowProc( hWnd, message, wParam, lParam );
- }
- // OpenGL ////////////////////////////////////////////////////////////
- // Enable OpenGL
- VOID EnableOpenGL( HWND hWnd, HDC * hDC, HGLRC * hRC )
- {
- PIXELFORMATDESCRIPTOR pfd;
- int iFormat;
- // get the device context (DC)
- *hDC = GetDC( hWnd );
- // 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;
- iFormat = ChoosePixelFormat( *hDC, &pfd );
- SetPixelFormat( *hDC, iFormat, &pfd );
- // create and enable the render context (RC)
- *hRC = wglCreateContext( *hDC );
- wglMakeCurrent( *hDC, *hRC );
- }
- // Disable OpenGL
- VOID DisableOpenGL( HWND hWnd, HDC hDC, HGLRC hRC )
- {
- wglMakeCurrent( NULL, NULL );
- wglDeleteContext( hRC );
- ReleaseDC( hWnd, hDC );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement