您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ DescribePixelFormat函数代码示例

51自学网 2021-06-01 20:26:53
  C++
这篇教程C++ DescribePixelFormat函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中DescribePixelFormat函数的典型用法代码示例。如果您正苦于以下问题:C++ DescribePixelFormat函数的具体用法?C++ DescribePixelFormat怎么用?C++ DescribePixelFormat使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了DescribePixelFormat函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: GLW_MakeContext

/*** GLW_MakeContext*/static int GLW_MakeContext( PIXELFORMATDESCRIPTOR *pPFD ) {	int pixelformat;	//	// don't putz around with pixelformat if it's already set (e.g. this is a soft	// reset of the graphics system)	//	if ( !glw_state.pixelFormatSet ) {		//		// choose, set, and describe our desired pixel format.  If we're		// using a minidriver then we need to bypass the GDI functions,		// otherwise use the GDI functions.		//		if ( ( pixelformat = GLW_ChoosePFD( glw_state.hDC, pPFD ) ) == 0 ) {			ri.Printf( PRINT_ALL, "...GLW_ChoosePFD failed/n" );			return TRY_PFD_FAIL_SOFT;		}		ri.Printf( PRINT_ALL, "...PIXELFORMAT %d selected/n", pixelformat );		if ( glConfig.driverType > GLDRV_ICD ) {			qwglDescribePixelFormat( glw_state.hDC, pixelformat, sizeof( *pPFD ), pPFD );			if ( qwglSetPixelFormat( glw_state.hDC, pixelformat, pPFD ) == FALSE ) {				ri.Printf( PRINT_ALL, "...qwglSetPixelFormat failed/n" );				return TRY_PFD_FAIL_SOFT;			}		} else		{			DescribePixelFormat( glw_state.hDC, pixelformat, sizeof( *pPFD ), pPFD );			if ( SetPixelFormat( glw_state.hDC, pixelformat, pPFD ) == FALSE ) {				ri.Printf( PRINT_ALL, "...SetPixelFormat failed/n", glw_state.hDC );				return TRY_PFD_FAIL_SOFT;			}		}		glw_state.pixelFormatSet = qtrue;	}	//	// startup the OpenGL subsystem by creating a context and making it current	//	if ( !glw_state.hGLRC ) {		ri.Printf( PRINT_ALL, "...creating GL context: " );		if ( ( glw_state.hGLRC = qwglCreateContext( glw_state.hDC ) ) == 0 ) {			ri.Printf( PRINT_ALL, "failed/n" );			return TRY_PFD_FAIL_HARD;		}		ri.Printf( PRINT_ALL, "succeeded/n" );		ri.Printf( PRINT_ALL, "...making context current: " );		if ( !qwglMakeCurrent( glw_state.hDC, glw_state.hGLRC ) ) {			qwglDeleteContext( glw_state.hGLRC );			glw_state.hGLRC = NULL;			ri.Printf( PRINT_ALL, "failed/n" );			return TRY_PFD_FAIL_HARD;		}		ri.Printf( PRINT_ALL, "succeeded/n" );	}	return TRY_PFD_SUCCESS;}
开发者ID:Justasic,项目名称:RTCW-MP,代码行数:65,


示例2: choosePixelFormat

// Return a list of available and usable framebuffer configs//static GLboolean choosePixelFormat(_GLFWwindow* window,                                   const _GLFWfbconfig* desired,                                   int* result){    _GLFWfbconfig* usableConfigs;    const _GLFWfbconfig* closest;    int i, nativeCount, usableCount;    if (window->wgl.ARB_pixel_format)    {        nativeCount = getPixelFormatAttrib(window,                                         1,                                         WGL_NUMBER_PIXEL_FORMATS_ARB);    }    else    {        nativeCount = DescribePixelFormat(window->wgl.dc,                                          1,                                          sizeof(PIXELFORMATDESCRIPTOR),                                          NULL);    }    if (!nativeCount)    {        _glfwInputError(GLFW_API_UNAVAILABLE, "WGL: No pixel formats found");        return GL_FALSE;    }    usableConfigs = calloc(nativeCount, sizeof(_GLFWfbconfig));    usableCount = 0;    for (i = 0;  i < nativeCount;  i++)    {        const int n = i + 1;        _GLFWfbconfig* u = usableConfigs + usableCount;        if (window->wgl.ARB_pixel_format)        {            // Get pixel format attributes through WGL_ARB_pixel_format            if (!getPixelFormatAttrib(window, n, WGL_SUPPORT_OPENGL_ARB) ||                !getPixelFormatAttrib(window, n, WGL_DRAW_TO_WINDOW_ARB) ||                !getPixelFormatAttrib(window, n, WGL_DOUBLE_BUFFER_ARB))            {                continue;            }            if (getPixelFormatAttrib(window, n, WGL_PIXEL_TYPE_ARB) !=                WGL_TYPE_RGBA_ARB)            {                continue;            }            if (getPixelFormatAttrib(window, n, WGL_ACCELERATION_ARB) ==                 WGL_NO_ACCELERATION_ARB)            {                continue;            }            u->redBits = getPixelFormatAttrib(window, n, WGL_RED_BITS_ARB);            u->greenBits = getPixelFormatAttrib(window, n, WGL_GREEN_BITS_ARB);            u->blueBits = getPixelFormatAttrib(window, n, WGL_BLUE_BITS_ARB);            u->alphaBits = getPixelFormatAttrib(window, n, WGL_ALPHA_BITS_ARB);            u->depthBits = getPixelFormatAttrib(window, n, WGL_DEPTH_BITS_ARB);            u->stencilBits = getPixelFormatAttrib(window, n, WGL_STENCIL_BITS_ARB);            u->accumRedBits = getPixelFormatAttrib(window, n, WGL_ACCUM_RED_BITS_ARB);            u->accumGreenBits = getPixelFormatAttrib(window, n, WGL_ACCUM_GREEN_BITS_ARB);            u->accumBlueBits = getPixelFormatAttrib(window, n, WGL_ACCUM_BLUE_BITS_ARB);            u->accumAlphaBits = getPixelFormatAttrib(window, n, WGL_ACCUM_ALPHA_BITS_ARB);            u->auxBuffers = getPixelFormatAttrib(window, n, WGL_AUX_BUFFERS_ARB);            u->stereo = getPixelFormatAttrib(window, n, WGL_STEREO_ARB);            if (window->wgl.ARB_multisample)                u->samples = getPixelFormatAttrib(window, n, WGL_SAMPLES_ARB);            if (window->wgl.ARB_framebuffer_sRGB)                u->sRGB = getPixelFormatAttrib(window, n, WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB);        }        else        {            PIXELFORMATDESCRIPTOR pfd;            // Get pixel format attributes through old-fashioned PFDs            if (!DescribePixelFormat(window->wgl.dc,                                     n,                                     sizeof(PIXELFORMATDESCRIPTOR),                                     &pfd))            {                continue;            }            if (!(pfd.dwFlags & PFD_DRAW_TO_WINDOW) ||                !(pfd.dwFlags & PFD_SUPPORT_OPENGL) ||                !(pfd.dwFlags & PFD_DOUBLEBUFFER))            {//.........这里部分代码省略.........
开发者ID:ACefalu,项目名称:tzod,代码行数:101,


示例3: findPixelFormatFromBPP

/* * Find an appropriate pixel format */static int findPixelFormatFromBPP(JNIEnv *env, HDC hdc, jobject pixel_format, int bpp, bool double_buffer){	jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format);	int alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "alpha", "I"));	int depth = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "depth", "I"));	int stencil = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stencil", "I"));	int num_aux_buffers = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "num_aux_buffers", "I"));	int accum_bpp = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_bpp", "I"));	int accum_alpha = (int)(*env)->GetIntField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "accum_alpha", "I"));	jboolean stereo = (*env)->GetBooleanField(env, pixel_format, (*env)->GetFieldID(env, cls_pixel_format, "stereo", "Z"));	unsigned int flags = PFD_DRAW_TO_WINDOW |   // support window		PFD_SUPPORT_OPENGL |		(double_buffer ? PFD_DOUBLEBUFFER : 0) |		(stereo ? PFD_STEREO : 0);	PIXELFORMATDESCRIPTOR desc;	int iPixelFormat;	PIXELFORMATDESCRIPTOR pfd = {		sizeof(PIXELFORMATDESCRIPTOR),   // size of this pfd		1,                     // version number		flags,         // RGBA type		PFD_TYPE_RGBA,		(BYTE)bpp,		0, 0, 0, 0, 0, 0,      // color bits ignored		(BYTE)alpha,		0,                     // shift bit ignored		accum_bpp + accum_alpha,                     // no accumulation buffer		0, 0, 0, 0,            // accum bits ignored		(BYTE)depth,		(BYTE)stencil,		num_aux_buffers,		PFD_MAIN_PLANE,        // main layer		0,                     // reserved		0, 0, 0                // layer masks ignored	};	// get the best available match of pixel format for the device context	iPixelFormat = ChoosePixelFormat(hdc, &pfd);	if (iPixelFormat == 0) {		throwException(env, "Failed to choose pixel format");		return -1;	}	if (DescribePixelFormat(hdc, iPixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &desc) == 0) {		throwException(env, "Could not describe pixel format");		return -1;	}	if (desc.cColorBits < bpp) {		throwException(env, "Insufficient color precision");		return -1;	}	if (desc.cAlphaBits < alpha) {		throwException(env, "Insufficient alpha precision");		return -1;	}	if (desc.cStencilBits < stencil) {		throwException(env, "Insufficient stencil precision");		return -1;	}	if (desc.cDepthBits < depth) {		throwException(env, "Insufficient depth buffer precision");		return -1;	}	if ((desc.dwFlags & PFD_GENERIC_FORMAT) != 0) {		jboolean allowSoftwareOpenGL = getBooleanProperty(env, "org.lwjgl.opengl.Display.allowSoftwareOpenGL");		// secondary check for software override		if(!allowSoftwareOpenGL) {			throwException(env, "Pixel format not accelerated");			return -1;		}	}	if ((desc.dwFlags & flags) != flags) {		throwException(env, "Capabilities not supported");		return -1;	}	return iPixelFormat;}
开发者ID:Blackfatrat,项目名称:mycraft,代码行数:84,


示例4: OK2_AnimInit

/* Функция инициализации анимации. * АРГУМЕНТЫ: *   - дескриптор окна: *       HWND hWnd; * ВОЗВРАЩАЕМОЕ ЗНАЧЕНИЕ: Нет. */BOOL OK2_AnimInit( HWND hWnd ){  LARGE_INTEGER li;  INT i;  /* Init window parametrs */  OK2_Anim.hDC = GetDC(hWnd);  OK2_Anim.hWnd = hWnd;  OK2_Anim.W = 30;  OK2_Anim.H = 30;  OK2_Anim.NumOfUnits = 0;    /*** Инициализация OpenGL ***/  /* описываем формат точки */  pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);  pfd.dwFlags = PFD_SUPPORT_OPENGL | PFD_SUPPORT_GDI | PFD_DOUBLEBUFFER;  pfd.iPixelType = PFD_TYPE_RGBA;  pfd.cColorBits = 32;  i = ChoosePixelFormat(OK2_Anim.hDC, &pfd);  DescribePixelFormat(OK2_Anim.hDC, i, sizeof(pfd), &pfd);  SetPixelFormat(OK2_Anim.hDC, i, &pfd);  /* создаем контекст построения */  OK2_Anim.hRC = wglCreateContext(OK2_Anim.hDC);  /* делаем текущими контексты */  wglMakeCurrent(OK2_Anim.hDC, OK2_Anim.hRC);  /* инициализируем расширения */  if (glewInit() != GLEW_OK ||      !(GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader))  {    wglMakeCurrent(NULL, NULL);    wglDeleteContext(OK2_Anim.hRC);    ReleaseDC(OK2_Anim.hWnd, OK2_Anim.hDC);    memset(&OK2_Anim, 0, sizeof(ok2ANIM));    return FALSE;  }  /* параметры OpenGL по-умолчанию */  /* инициализируем таймер */  QueryPerformanceFrequency(&li);  TimeFreq = li.QuadPart;  QueryPerformanceCounter(&li);  TimeStart = TimeOld = TimeFPS = li.QuadPart;  TimePause = 0;  FrameCounter = 0;    /* инициализируем захват сообщений от мыши */  SetWindowsHookEx(WH_MOUSE_LL, OK2_MouseHook, GetModuleHandle(NULL), 0);  /* Параметры проецирования */  OK2_Anim.Wp = 4.0, OK2_Anim.Hp = 3.0,     /* размеры обрасти проецирования */  OK2_Anim.ProjDist = 1.0,              /* расстояние до плоскости проекции */  OK2_Anim.FarClip = 1000.0,  OK2_Anim.ProjSize = 1.0;  OK2_Anim.MatrWorld = /* матрица преобразования мировой СК */  OK2_Anim.MatrView =  /* матрица преобразования видовой СК */  OK2_Anim.MatrProjection = MatrIdenity(); /* матрица проекции */  glEnable(GL_DEPTH_TEST);  glEnable(GL_ALPHA_TEST);  //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);  return TRUE;} /* End of 'OK2_AnimInit' function */
开发者ID:unknownoperation,项目名称:SUM2014,代码行数:73,


示例5: WinMain

int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,                     LPSTR lpCmdLine, int nCmdShow) {  // Allocate program memory  g_program_memory.start = malloc(MAX_INTERNAL_MEMORY_SIZE);  g_program_memory.free_memory = g_program_memory.start;  // TODO: add checks for overflow when allocating  // Main program state  Program_State *state =      (Program_State *)g_program_memory.allocate(sizeof(Program_State));  state->init(&g_program_memory, &g_pixel_buffer,              (Raytrace_Work_Queue *)&g_raytrace_queue);  // Create window class  WNDCLASS WindowClass = {};  WindowClass.style = CS_OWNDC | CS_VREDRAW | CS_HREDRAW;  WindowClass.lpfnWndProc = Win32WindowProc;  WindowClass.hInstance = hInstance;  WindowClass.lpszClassName = "VMWindowClass";  // Set target sleep resolution  {    TIMECAPS tc;    UINT wTimerRes;    if (timeGetDevCaps(&tc, sizeof(TIMECAPS)) != TIMERR_NOERROR) {      OutputDebugStringA("Cannot set the sleep resolution/n");      exit(1);    }    wTimerRes = min(max(tc.wPeriodMin, 1), tc.wPeriodMax);  // 1 ms    timeBeginPeriod(wTimerRes);  }  QueryPerformanceFrequency(&gPerformanceFrequency);  if (!RegisterClass(&WindowClass)) {    // TODO: logging    printf("Couldn't register window class/n");    exit(1);  }  // Create window so that its client area is exactly kWindowWidth/Height  DWORD WindowStyle = WS_OVERLAPPEDWINDOW | WS_VISIBLE;  RECT WindowRect = {};  WindowRect.right = state->kWindowWidth;  WindowRect.bottom = state->kWindowHeight;  AdjustWindowRect(&WindowRect, WindowStyle, 0);  int WindowWidth = WindowRect.right - WindowRect.left;  int WindowHeight = WindowRect.bottom - WindowRect.top;  HWND Window = CreateWindow(WindowClass.lpszClassName, 0, WindowStyle,                             CW_USEDEFAULT, CW_USEDEFAULT, WindowWidth,                             WindowHeight, 0, 0, hInstance, 0);  if (!Window) {    printf("Couldn't create window/n");    exit(1);  }  // We're not going to release it as we use CS_OWNDC  HDC hdc = GetDC(Window);  g_running = true;  // Set proper buffer values based on actual client size  Win32ResizeClientWindow(Window);  // Init OpenGL  {    PIXELFORMATDESCRIPTOR DesiredPixelFormat = {};    DesiredPixelFormat.nSize = sizeof(DesiredPixelFormat);    DesiredPixelFormat.nVersion = 1;    DesiredPixelFormat.iPixelType = PFD_TYPE_RGBA;    DesiredPixelFormat.dwFlags =        PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW | PFD_DOUBLEBUFFER;    DesiredPixelFormat.cColorBits = 32;    DesiredPixelFormat.cAlphaBits = 8;    DesiredPixelFormat.iLayerType = PFD_MAIN_PLANE;    int SuggestedPixelFormatIndex = ChoosePixelFormat(hdc, &DesiredPixelFormat);    PIXELFORMATDESCRIPTOR SuggestedPixelFormat;    DescribePixelFormat(hdc, SuggestedPixelFormatIndex,                        sizeof(SuggestedPixelFormat), &SuggestedPixelFormat);    SetPixelFormat(hdc, SuggestedPixelFormatIndex, &SuggestedPixelFormat);    HGLRC OpenGLRC = wglCreateContext(hdc);    if (wglMakeCurrent(hdc, OpenGLRC)) {      // Success      glGenTextures(1, &gTextureHandle);      typedef BOOL WINAPI wgl_swap_interval_ext(int interval);      wgl_swap_interval_ext *wglSwapInterval =          (wgl_swap_interval_ext *)wglGetProcAddress("wglSwapIntervalEXT");      if (wglSwapInterval) {        wglSwapInterval(1);      } else {        // VSync not enabled or not supported        assert(false);//.........这里部分代码省略.........
开发者ID:obiwanus,项目名称:editor,代码行数:101,


示例6: throw

djvWglContext::djvWglContext(djvCoreContext * context) throw (djvError) :    djvOpenGlContext(context),    _p(new djvWglContextPrivate){#   if defined(DJV_WINDOWS)    //DJV_DEBUG("djvWglContext::djvWglContext");    // Create a dummy window and OpenGL context for glewInit.    // According to the docs, glewInit can be called just once per-process?    DJV_LOG(context->debugLog(), "djvWglContext", "Creating dummy window...");    HINSTANCE hinstance = GetModuleHandle(0);    if (! hinstance)    {        throw djvError(            "djvWglContext",            errorLabels()[ERROR_MODULE_HANDLE].arg(int(GetLastError())));    }    static const char name [] = "djv";    WNDCLASS wc;    if (! GetClassInfo(hinstance, name, &wc))    {        wc.style = CS_OWNDC;        //wc.lpfnWndProc = (WNDPROC)MainWndProc;        wc.lpfnWndProc = DefWindowProc;        wc.cbClsExtra = 0;        wc.cbWndExtra = 0;        wc.hInstance = hinstance;        wc.hIcon = LoadIcon(0, IDI_APPLICATION);        wc.hCursor = LoadCursor(0, IDC_ARROW);        wc.hbrBackground = 0;        wc.lpszMenuName = 0;        wc.lpszClassName = name;        if (! RegisterClass(&wc))        {            throw djvError(                "djvWglContext",                errorLabels()[ERROR_REGISTER_CLASS].arg(int(GetLastError())));        }    }    _p->id = CreateWindow(name, 0, 0, 0, 0, 0, 0, 0, 0, hinstance, 0);    if (! _p->id)    {        throw djvError(            "djvWglContext",            errorLabels()[ERROR_CREATE_WINDOW].arg(int(GetLastError())));    }    _p->device = GetDC(_p->id);    if (! _p->device)    {        throw djvError(            "djvWglContext",            errorLabels()[ERROR_GET_DC].arg(int(GetLastError())));    }    PIXELFORMATDESCRIPTOR pixelFormatInfo;    const int pixelFormatCount = DescribePixelFormat(_p->device, 0, 0, 0);    //DJV_DEBUG_PRINT("pixel format count = " << pixelFormatCount);    DJV_LOG(context->debugLog(), "djvWglContext",            QString("Pixel format count: %1").arg(pixelFormatCount));    for (int i = 1; i < pixelFormatCount; ++i)    {        DescribePixelFormat(            _p->device,            i,            sizeof(PIXELFORMATDESCRIPTOR),            &pixelFormatInfo);        //DJV_DEBUG_PRINT("  id " << i << ": " <<        //    ((PFD_SUPPORT_OPENGL & pixelFormatInfo.dwFlags) ? "gl " : "") <<        //    ((PFD_GENERIC_FORMAT & pixelFormatInfo.dwFlags) ? "" : "accel ") <<        //    ((PFD_TYPE_RGBA == pixelFormatInfo.iPixelType) ? "rgba " : "") <<        //    "depth = " << pixelFormatInfo.cColorBits << "/" <<        //    pixelFormatInfo.cRedBits << "/" <<        //    pixelFormatInfo.cGreenBits << "/" <<        //    pixelFormatInfo.cBlueBits << "/" <<        //    pixelFormatInfo.cAlphaBits << " ");        QStringList tmp;        if (PFD_SUPPORT_OPENGL & pixelFormatInfo.dwFlags)            tmp += "gl";        if (! (PFD_GENERIC_FORMAT & pixelFormatInfo.dwFlags))            tmp += "accel";        if (PFD_TYPE_RGBA == pixelFormatInfo.iPixelType)            tmp += "rgba";        DJV_LOG(context->debugLog(), "djvWglContext",//.........这里部分代码省略.........
开发者ID:sobotka,项目名称:djv-view,代码行数:101,


示例7: GetOpenGLPalette

HPALETTE GetOpenGLPalette(HDC hDC){	HPALETTE hRetPal = NULL;	// Handle to palette to be created	PIXELFORMATDESCRIPTOR pfd;	// Pixel Format Descriptor	LOGPALETTE *pPal;			// Pointer to memory for logical palette	int nPixelFormat;			// Pixel format index	int nColors;				// Number of entries in palette	int i;						// Counting variable	BYTE RedRange, GreenRange, BlueRange;	// Range for each color entry (7,7,and 3)	// Get the pixel format index and retrieve the pixel format description	nPixelFormat = GetPixelFormat(hDC);	DescribePixelFormat(hDC, nPixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &pfd);	// Does this pixel format require a palette?  If not, do not create a	// palette and just return NULL	if (!(pfd.dwFlags & PFD_NEED_PALETTE))		return NULL;	// Number of entries in palette.  8 bits yeilds 256 entries	nColors = 1 << pfd.cColorBits;	// Allocate space for a logical palette structure plus all the palette entries	pPal = (LOGPALETTE*)malloc(sizeof(LOGPALETTE) + nColors*sizeof(PALETTEENTRY));	// Fill in palette header 	pPal->palVersion = 0x300;		// Windows 3.0	pPal->palNumEntries = nColors; // table size								   // Build mask of all 1's.  This creates a number represented by having								   // the low order x bits set, where x = pfd.cRedBits, pfd.cGreenBits, and								   // pfd.cBlueBits.  	RedRange = (1 << pfd.cRedBits) - 1;	GreenRange = (1 << pfd.cGreenBits) - 1;	BlueRange = (1 << pfd.cBlueBits) - 1;	// Loop through all the palette entries	for (i = 0; i < nColors; i++)	{		// Fill in the 8-bit equivalents for each component		pPal->palPalEntry[i].peRed = (i >> pfd.cRedShift) & RedRange;		pPal->palPalEntry[i].peRed = (unsigned char)(			(double)pPal->palPalEntry[i].peRed * 255.0 / RedRange);		pPal->palPalEntry[i].peGreen = (i >> pfd.cGreenShift) & GreenRange;		pPal->palPalEntry[i].peGreen = (unsigned char)(			(double)pPal->palPalEntry[i].peGreen * 255.0 / GreenRange);		pPal->palPalEntry[i].peBlue = (i >> pfd.cBlueShift) & BlueRange;		pPal->palPalEntry[i].peBlue = (unsigned char)(			(double)pPal->palPalEntry[i].peBlue * 255.0 / BlueRange);		pPal->palPalEntry[i].peFlags = (unsigned char)NULL;	}	// Create the palette	hRetPal = CreatePalette(pPal);	// Go ahead and select and realize the palette for this device context	SelectPalette(hDC, hRetPal, FALSE);	RealizePalette(hDC);	// Free the memory used for the logical palette structure	free(pPal);	// Return the handle to the new palette	return hRetPal;}
开发者ID:marcinosypka,项目名称:Moonlander,代码行数:71,


示例8: DisplayError

BOOL GL11Window::Create(CONST WindowSettings& settings /*= {}*/){	m_settings = settings;	CONST auto hInstance{GetModuleHandle(NULL)};	if (!hInstance)	{		DisplayError(TEXT("Failed to retrieve the application handle."), GetLastError());		return FALSE;	}	WNDCLASSEX wndClassEx{};	ZeroMemory(&wndClassEx, sizeof(WNDCLASSEX));	wndClassEx.cbSize        = sizeof(WNDCLASSEX);	wndClassEx.style         = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;	wndClassEx.lpfnWndProc   = WndProc;	wndClassEx.cbClsExtra    = 0;	wndClassEx.cbWndExtra    = sizeof(VOID*) + sizeof(INT);	wndClassEx.hInstance     = hInstance;	wndClassEx.hIcon         = LoadIcon(NULL, IDI_APPLICATION);	wndClassEx.hCursor       = LoadCursor(NULL, IDC_ARROW);	wndClassEx.hbrBackground = NULL;	wndClassEx.lpszMenuName  = NULL;	wndClassEx.lpszClassName = TEXT("GL11WindowClass");	wndClassEx.hIconSm       = NULL;	if (FAILED(RegisterClassEx(&wndClassEx)))	{		DisplayError(TEXT("Failed to register the window class."), GetLastError());		return FALSE;	}	DWORD windowStyle{WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS};	DWORD windowStyleEx{WS_EX_ACCEPTFILES};	RECT windowRect{0, 0, m_settings.width, m_settings.height};	if (FAILED(AdjustWindowRectEx(&windowRect, windowStyle, FALSE, windowStyleEx)))	{		DisplayError(TEXT("Failed to adjust the window rect."), GetLastError());		return FALSE;	}	m_settings.x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (m_settings.width / 2);	m_settings.y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (m_settings.height / 2);	CONST auto FULL_TITLE{m_settings.title + m_settings.titleEx};	m_handle = CreateWindowEx(windowStyleEx,	                          wndClassEx.lpszClassName,	                          FULL_TITLE.c_str(),	                          windowStyle,	                          m_settings.x,	                          m_settings.y,	                          windowRect.right - windowRect.left,	                          windowRect.bottom - windowRect.top,	                          NULL,	                          NULL,	                          hInstance,	                          this);	if (!m_handle)	{		DisplayError(TEXT("Failed to create the window handle."), GetLastError());		return FALSE;	}	m_deviceContext = GetDC(m_handle);	// Query a pixel format:	PIXELFORMATDESCRIPTOR desiredPixelFormat{};	ZeroMemory(&desiredPixelFormat, sizeof(PIXELFORMATDESCRIPTOR));	desiredPixelFormat.nSize        = sizeof(PIXELFORMATDESCRIPTOR);	desiredPixelFormat.nVersion     = 1;	desiredPixelFormat.dwFlags      = PFD_DRAW_TO_WINDOW | PFD_DOUBLEBUFFER | PFD_SUPPORT_OPENGL;	desiredPixelFormat.iPixelType   = PFD_TYPE_RGBA;	desiredPixelFormat.cColorBits   = 32;	desiredPixelFormat.cDepthBits   = 24;	desiredPixelFormat.cStencilBits = 8;	desiredPixelFormat.iLayerType   = PFD_MAIN_PLANE;	auto chosenPixelFormat{ChoosePixelFormat(m_deviceContext, &desiredPixelFormat)};	if (!chosenPixelFormat)	{		DisplayError(TEXT("Failed to choose a dummy pixel format."), GetLastError());		return FALSE;	}	if (FAILED(DescribePixelFormat(m_deviceContext,	                               chosenPixelFormat,	                               sizeof(PIXELFORMATDESCRIPTOR),	                               &desiredPixelFormat)))	{		DisplayError(TEXT("Failed to fill the pixel format."), GetLastError());		return FALSE;	}	if (FAILED(SetPixelFormat(m_deviceContext, chosenPixelFormat, &desiredPixelFormat)))	{		DisplayError(TEXT("Failed to set the pixel format."), GetLastError());		return FALSE;	}//.........这里部分代码省略.........
开发者ID:Skurdt,项目名称:Win32-API-Code-Snippets,代码行数:101,


示例9: GLimp_InitGL

static int GLimp_InitGL( void ){	PIXELFORMATDESCRIPTOR pfd =	{		sizeof( PIXELFORMATDESCRIPTOR ), // size of this pfd		1,                      // version number		PFD_DRAW_TO_WINDOW |    // support window		PFD_SUPPORT_OPENGL |    // support OpenGL		PFD_DOUBLEBUFFER,       // double buffered		PFD_TYPE_RGBA,          // RGBA type		32,                     // 32-bit color depth		0, 0, 0, 0, 0, 0,       // color bits ignored		0,                      // no alpha buffer		0,                      // shift bit ignored		0,                      // no accumulation buffer		0, 0, 0, 0,             // accum bits ignored		24,                     // 32-bit z-buffer		0,                      // no stencil buffer		0,                      // no auxiliary buffer		PFD_MAIN_PLANE,         // main layer		0,                      // reserved		0, 0, 0                 // layer masks ignored	};	int pixelformat;	if( r_stencilbits->integer == 8 || r_stencilbits->integer == 16 )		pfd.cStencilBits = r_stencilbits->integer;	/*	** set PFD_STEREO if necessary	*/	if( glConfig.stereoEnabled )	{		ri.Com_DPrintf( "...attempting to use stereo/n" );		pfd.dwFlags |= PFD_STEREO;	}	/*	** Get a DC for the specified window	*/	if( glw_state.hDC != NULL )		ri.Com_Printf( "GLimp_Init() - non-NULL DC exists/n" );	if( ( glw_state.hDC = GetDC( glw_state.hWnd ) ) == NULL )	{		ri.Com_Printf( "GLimp_Init() - GetDC failed/n" );		return false;	}	if( ( pixelformat = ChoosePixelFormat( glw_state.hDC, &pfd ) ) == 0 )	{		ri.Com_Printf( "GLimp_Init() - ChoosePixelFormat failed/n" );		return false;	}	if( SetPixelFormat( glw_state.hDC, pixelformat, &pfd ) == FALSE )	{		ri.Com_Printf( "GLimp_Init() - SetPixelFormat failed/n" );		return false;	}	DescribePixelFormat( glw_state.hDC, pixelformat, sizeof( pfd ), &pfd );	glConfig.stencilBits = pfd.cStencilBits;	/*	** report if stereo is desired but unavailable	*/	if( !( pfd.dwFlags & PFD_STEREO ) && glConfig.stereoEnabled )	{		ri.Com_Printf( "...failed to select stereo pixel format/n" );		glConfig.stereoEnabled = false;	}	/*	** startup the OpenGL subsystem by creating a context and making	** it current	*/	if( ( glw_state.hGLRC = qwglCreateContext( glw_state.hDC ) ) == 0 )	{		ri.Com_Printf( "GLimp_Init() - qwglCreateContext failed/n" );		goto fail;	}	if( !qwglMakeCurrent( glw_state.hDC, glw_state.hGLRC ) )	{		ri.Com_Printf( "GLimp_Init() - qwglMakeCurrent failed/n" );		goto fail;	}	/*	** print out PFD specifics	*/	ri.Com_Printf( "GL PFD: color(%d-bits) Z(%d-bit) stencil(%d-bits)/n", ( int ) pfd.cColorBits, ( int ) pfd.cDepthBits, ( int )pfd.cStencilBits );	return true;fail:	if( glw_state.hGLRC )	{		qwglDeleteContext( glw_state.hGLRC );		glw_state.hGLRC = NULL;//.........这里部分代码省略.........
开发者ID:MaryJaneInChain,项目名称:qfusion,代码行数:101,


示例10: memset

//.........这里部分代码省略.........    hDC=GetDC(hWindow);    if (!hDC)    {        Close();        return "Unable to obtain a GL device context.";    }    // 6. PixelFormat abfragen und setzen    // **********************************    PIXELFORMATDESCRIPTOR PFD;    memset(&PFD, 0, 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  =BPP;    PFD.cDepthBits  =32;    PFD.cStencilBits=8;    PFD.iLayerType=PFD_MAIN_PLANE;    int PixelFormat=ChoosePixelFormat(hDC, &PFD);    if (!PixelFormat)    {        Close();        return "Unable to choose a pixel format.";    }    if (!DescribePixelFormat(hDC, PixelFormat, sizeof(PFD), &PFD))    {        Close();        return "Unable to verify pixel format.";    }    static char ErrorMsg[1024];    const char* s1="Selected pixel format mismatches:/n";    const char* s2="/n/nThis is probably a problem with your video card (or its driver)./n"                   "Please make sure you have the latest drivers installed./n"                   "If it still doesn't work, please let me know./n"                   "(Email to [email
C++ Deselect函数代码示例
C++ DeregisterEventSource函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。