mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
fix wglGraphicsBuffer
This commit is contained in:
parent
99b64bdfc6
commit
f4d29cf30b
@ -17,7 +17,8 @@
|
||||
wglGraphicsBuffer.I wglGraphicsBuffer.h \
|
||||
wglGraphicsPipe.I wglGraphicsPipe.h \
|
||||
wglGraphicsStateGuardian.I wglGraphicsStateGuardian.h \
|
||||
wglGraphicsWindow.I wglGraphicsWindow.h
|
||||
wglGraphicsWindow.I wglGraphicsWindow.h \
|
||||
wglExtensions.h
|
||||
|
||||
#define INCLUDED_SOURCES \
|
||||
config_wgldisplay.cxx \
|
||||
|
139
panda/src/wgldisplay/wglExtensions.h
Normal file
139
panda/src/wgldisplay/wglExtensions.h
Normal file
@ -0,0 +1,139 @@
|
||||
// Filename: wglExtensions.h
|
||||
// Created by: drose (09Feb04)
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// PANDA 3D SOFTWARE
|
||||
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
|
||||
//
|
||||
// All use of this software is subject to the terms of the Panda 3d
|
||||
// Software license. You should have received a copy of this license
|
||||
// along with this source code; you will also find a current copy of
|
||||
// the license at http://www.panda3d.org/license.txt .
|
||||
//
|
||||
// To contact the maintainers of this program write to
|
||||
// panda3d@yahoogroups.com .
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef WGLEXTENSIONS_H
|
||||
#define WGLEXTENSIONS_H
|
||||
|
||||
#include "pandabase.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
// This file defines some headers that are necessary to make use of
|
||||
// the various wgl extensions we might test for in this module.
|
||||
|
||||
|
||||
// The following headers are from the WGL_ARB_pbuffer extension for
|
||||
// offscreen rendering into Pbuffers.
|
||||
|
||||
DECLARE_HANDLE(HPBUFFERARB);
|
||||
|
||||
typedef HPBUFFERARB (*wglCreatePbufferARB_proc)(HDC hDC,
|
||||
int iPixelFormat,
|
||||
int iWidth,
|
||||
int iHeight,
|
||||
const int *piAttribList);
|
||||
|
||||
typedef HDC (*wglGetPbufferDCARB_proc)(HPBUFFERARB hPbuffer);
|
||||
|
||||
typedef int (*wglReleasePbufferDCARB_proc)(HPBUFFERARB hPbuffer,
|
||||
HDC hDC);
|
||||
|
||||
typedef BOOL (*wglDestroyPbufferARB_proc)(HPBUFFERARB hPbuffer);
|
||||
|
||||
typedef BOOL (*wglQueryPbufferARB_proc)(HPBUFFERARB hPbuffer,
|
||||
int iAttribute,
|
||||
int *piValue);
|
||||
|
||||
#define WGL_DRAW_TO_PBUFFER_ARB 0x202D
|
||||
#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E
|
||||
#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F
|
||||
#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030
|
||||
#define WGL_PBUFFER_LARGEST_ARB 0x2033
|
||||
#define WGL_PBUFFER_WIDTH_ARB 0x2034
|
||||
#define WGL_PBUFFER_HEIGHT_ARB 0x2035
|
||||
#define WGL_PBUFFER_LOST_ARB 0x2036
|
||||
|
||||
|
||||
// The following headers are from the WGL_ARB_pixel_format extension
|
||||
// for getting extended pixel format information.
|
||||
|
||||
typedef BOOL (*wglGetPixelFormatAttribivARB_proc)(HDC hdc,
|
||||
int iPixelFormat,
|
||||
int iLayerPlane,
|
||||
UINT nAttributes,
|
||||
const int *piAttributes,
|
||||
int *piValues);
|
||||
|
||||
typedef BOOL (*wglGetPixelFormatAttribfvARB_proc)(HDC hdc,
|
||||
int iPixelFormat,
|
||||
int iLayerPlane,
|
||||
UINT nAttributes,
|
||||
const int *piAttributes,
|
||||
FLOAT *pfValues);
|
||||
|
||||
typedef BOOL (*wglChoosePixelFormatARB_proc)(HDC hdc,
|
||||
const int *piAttribIList,
|
||||
const FLOAT *pfAttribFList,
|
||||
UINT nMaxFormats,
|
||||
int *piFormats,
|
||||
UINT *nNumFormats);
|
||||
|
||||
#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000
|
||||
#define WGL_DRAW_TO_WINDOW_ARB 0x2001
|
||||
#define WGL_DRAW_TO_BITMAP_ARB 0x2002
|
||||
#define WGL_ACCELERATION_ARB 0x2003
|
||||
#define WGL_NEED_PALETTE_ARB 0x2004
|
||||
#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005
|
||||
#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006
|
||||
#define WGL_SWAP_METHOD_ARB 0x2007
|
||||
#define WGL_NUMBER_OVERLAYS_ARB 0x2008
|
||||
#define WGL_NUMBER_UNDERLAYS_ARB 0x2009
|
||||
#define WGL_TRANSPARENT_ARB 0x200A
|
||||
#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037
|
||||
#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038
|
||||
#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039
|
||||
#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A
|
||||
#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B
|
||||
#define WGL_SHARE_DEPTH_ARB 0x200C
|
||||
#define WGL_SHARE_STENCIL_ARB 0x200D
|
||||
#define WGL_SHARE_ACCUM_ARB 0x200E
|
||||
#define WGL_SUPPORT_GDI_ARB 0x200F
|
||||
#define WGL_SUPPORT_OPENGL_ARB 0x2010
|
||||
#define WGL_DOUBLE_BUFFER_ARB 0x2011
|
||||
#define WGL_STEREO_ARB 0x2012
|
||||
#define WGL_PIXEL_TYPE_ARB 0x2013
|
||||
#define WGL_COLOR_BITS_ARB 0x2014
|
||||
#define WGL_RED_BITS_ARB 0x2015
|
||||
#define WGL_RED_SHIFT_ARB 0x2016
|
||||
#define WGL_GREEN_BITS_ARB 0x2017
|
||||
#define WGL_GREEN_SHIFT_ARB 0x2018
|
||||
#define WGL_BLUE_BITS_ARB 0x2019
|
||||
#define WGL_BLUE_SHIFT_ARB 0x201A
|
||||
#define WGL_ALPHA_BITS_ARB 0x201B
|
||||
#define WGL_ALPHA_SHIFT_ARB 0x201C
|
||||
#define WGL_ACCUM_BITS_ARB 0x201D
|
||||
#define WGL_ACCUM_RED_BITS_ARB 0x201E
|
||||
#define WGL_ACCUM_GREEN_BITS_ARB 0x201F
|
||||
#define WGL_ACCUM_BLUE_BITS_ARB 0x2020
|
||||
#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021
|
||||
#define WGL_DEPTH_BITS_ARB 0x2022
|
||||
#define WGL_STENCIL_BITS_ARB 0x2023
|
||||
#define WGL_AUX_BUFFERS_ARB 0x2024
|
||||
|
||||
#define WGL_NO_ACCELERATION_ARB 0x2025
|
||||
#define WGL_GENERIC_ACCELERATION_ARB 0x2026
|
||||
#define WGL_FULL_ACCELERATION_ARB 0x2027
|
||||
|
||||
#define WGL_SWAP_EXCHANGE_ARB 0x2028
|
||||
#define WGL_SWAP_COPY_ARB 0x2029
|
||||
#define WGL_SWAP_UNDEFINED_ARB 0x202A
|
||||
|
||||
#define WGL_TYPE_RGBA_ARB 0x202B
|
||||
#define WGL_TYPE_COLORINDEX_ARB 0x202C
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
@ -50,19 +50,13 @@ protected:
|
||||
virtual bool open_buffer();
|
||||
|
||||
private:
|
||||
void setup_colormap(const PIXELFORMATDESCRIPTOR &pixelformat);
|
||||
|
||||
#ifdef _DEBUG
|
||||
static void print_pfd(PIXELFORMATDESCRIPTOR *pfd, char *msg);
|
||||
#endif
|
||||
bool make_window();
|
||||
|
||||
static void register_window_class();
|
||||
static LONG WINAPI static_window_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);
|
||||
static void show_error_message(DWORD message_id = 0);
|
||||
|
||||
HWND _hWnd;
|
||||
HDC _hdc;
|
||||
HPALETTE _colormap;
|
||||
HWND _window;
|
||||
HDC _window_dc;
|
||||
|
||||
static const char * const _window_class_name;
|
||||
static bool _window_class_registered;
|
||||
|
@ -26,6 +26,7 @@ typedef enum {Software, MCD, ICD} OGLDriverType;
|
||||
static const char * const OGLDrvStrings[] = { "Software", "MCD", "ICD" };
|
||||
|
||||
TypeHandle wglGraphicsPipe::_type_handle;
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: wglGraphicsPipe::Constructor
|
||||
|
@ -32,6 +32,19 @@ get_pfnum() const {
|
||||
return _pfnum;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: wglGraphicsStateGuardian::made_context
|
||||
// Access: Public
|
||||
// Description: Returns true if the GSG has had a context made for it
|
||||
// already, false otherwise. If this returns false, the
|
||||
// next call to get_context() will quietly make a new
|
||||
// context.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
INLINE bool wglGraphicsStateGuardian::
|
||||
made_context() const {
|
||||
return _made_context;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: wglGraphicsStateGuardian::get_context
|
||||
// Access: Public
|
||||
|
@ -17,7 +17,7 @@
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "wglGraphicsStateGuardian.h"
|
||||
|
||||
#include "string_utils.h"
|
||||
|
||||
TypeHandle wglGraphicsStateGuardian::_type_handle;
|
||||
|
||||
@ -34,6 +34,9 @@ wglGraphicsStateGuardian(const FrameBufferProperties &properties,
|
||||
{
|
||||
_made_context = false;
|
||||
_context = (HGLRC)NULL;
|
||||
|
||||
_supports_pbuffer = false;
|
||||
_supports_pixel_format = false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -49,6 +52,87 @@ wglGraphicsStateGuardian::
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: wglGraphicsStateGuardian::reset
|
||||
// Access: Public, Virtual
|
||||
// Description: Resets all internal state as if the gsg were newly
|
||||
// created.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void wglGraphicsStateGuardian::
|
||||
reset() {
|
||||
GLGraphicsStateGuardian::reset();
|
||||
|
||||
// Output the vendor and version strings.
|
||||
show_gl_string("GL_VENDOR", GL_VENDOR);
|
||||
show_gl_string("GL_RENDERER", GL_RENDERER);
|
||||
show_gl_string("GL_VERSION", GL_VERSION);
|
||||
|
||||
// Save the extensions tokens.
|
||||
save_extensions((const char *)glGetString(GL_EXTENSIONS));
|
||||
|
||||
// Also save the tokens listed by wglGetExtensionsString. This is a
|
||||
// little trickier, since the query function is itself an extension.
|
||||
typedef const GLubyte *(*wglGetExtensionsStringEXT_proc)(void);
|
||||
wglGetExtensionsStringEXT_proc wglGetExtensionsStringEXT =
|
||||
(wglGetExtensionsStringEXT_proc)wglGetProcAddress("wglGetExtensionsStringEXT");
|
||||
if (wglGetExtensionsStringEXT != NULL) {
|
||||
save_extensions((const char *)wglGetExtensionsStringEXT());
|
||||
}
|
||||
|
||||
if (wgldisplay_cat.is_debug()) {
|
||||
wgldisplay_cat.debug()
|
||||
<< "GL Extensions:\n";
|
||||
pset<string>::const_iterator ei;
|
||||
for (ei = _extensions.begin(); ei != _extensions.end(); ++ei) {
|
||||
wgldisplay_cat.debug() << (*ei) << "\n";
|
||||
}
|
||||
}
|
||||
|
||||
_supports_pbuffer = (_extensions.count("WGL_ARB_pbuffer") != 0);
|
||||
_supports_pixel_format = (_extensions.count("WGL_ARB_pixel_format") != 0);
|
||||
|
||||
_wglCreatePbufferARB =
|
||||
(wglCreatePbufferARB_proc)wglGetProcAddress("wglCreatePbufferARB");
|
||||
_wglGetPbufferDCARB =
|
||||
(wglGetPbufferDCARB_proc)wglGetProcAddress("wglGetPbufferDCARB");
|
||||
_wglReleasePbufferDCARB =
|
||||
(wglReleasePbufferDCARB_proc)wglGetProcAddress("wglReleasePbufferDCARB");
|
||||
_wglDestroyPbufferARB =
|
||||
(wglDestroyPbufferARB_proc)wglGetProcAddress("wglDestroyPbufferARB");
|
||||
_wglQueryPbufferARB =
|
||||
(wglQueryPbufferARB_proc)wglGetProcAddress("wglQueryPbufferARB");
|
||||
|
||||
if (_supports_pbuffer) {
|
||||
if (_wglCreatePbufferARB == NULL ||
|
||||
_wglGetPbufferDCARB == NULL ||
|
||||
_wglReleasePbufferDCARB == NULL ||
|
||||
_wglDestroyPbufferARB == NULL ||
|
||||
_wglQueryPbufferARB == NULL) {
|
||||
wgldisplay_cat.error()
|
||||
<< "Driver claims to support WGL_ARB_pbuffer extension, but does not define all functions.\n";
|
||||
_supports_pbuffer = false;
|
||||
}
|
||||
}
|
||||
|
||||
_wglGetPixelFormatAttribivARB =
|
||||
(wglGetPixelFormatAttribivARB_proc)wglGetProcAddress("wglGetPixelFormatAttribivARB");
|
||||
_wglGetPixelFormatAttribfvARB =
|
||||
(wglGetPixelFormatAttribfvARB_proc)wglGetProcAddress("wglGetPixelFormatAttribfvARB");
|
||||
_wglChoosePixelFormatARB =
|
||||
(wglChoosePixelFormatARB_proc)wglGetProcAddress("wglChoosePixelFormatARB");
|
||||
|
||||
if (_supports_pixel_format) {
|
||||
if (_wglGetPixelFormatAttribivARB == NULL ||
|
||||
_wglGetPixelFormatAttribfvARB == NULL ||
|
||||
_wglChoosePixelFormatARB == NULL) {
|
||||
wgldisplay_cat.error()
|
||||
<< "Driver claims to support WGL_ARB_pixel_format extension, but does not define all functions.\n";
|
||||
_supports_pixel_format = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: wglGraphicsStateGuardian::make_context
|
||||
// Access: Private
|
||||
@ -72,3 +156,42 @@ make_context(HDC hdc) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: wglGraphicsStateGuardian::show_gl_string
|
||||
// Access: Private
|
||||
// Description: Outputs the result of glGetString() on the indicated
|
||||
// tag.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void wglGraphicsStateGuardian::
|
||||
show_gl_string(const string &name, GLenum id) {
|
||||
if (wgldisplay_cat.is_debug()) {
|
||||
const GLubyte *text = glGetString(id);
|
||||
if (text == (const GLubyte *)NULL) {
|
||||
wgldisplay_cat.debug()
|
||||
<< "Unable to query " << name << "\n";
|
||||
} else {
|
||||
wgldisplay_cat.debug()
|
||||
<< name << " = " << (const char *)text << "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Function: wglGraphicsStateGuardian::save_extensions
|
||||
// Access: Private
|
||||
// Description: Separates the string returned by GL_EXTENSIONS or
|
||||
// wglGetExtensionsStringEXT into its individual tokens
|
||||
// and saves them in the _extensions member.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
void wglGraphicsStateGuardian::
|
||||
save_extensions(const char *extensions) {
|
||||
vector_string tokens;
|
||||
extract_words(extensions, tokens);
|
||||
|
||||
vector_string::iterator ti;
|
||||
for (ti = tokens.begin(); ti != tokens.end(); ++ti) {
|
||||
_extensions.insert(*ti);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
#include "pandabase.h"
|
||||
|
||||
#include "wglExtensions.h"
|
||||
#include "glGraphicsStateGuardian.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
@ -34,10 +35,15 @@ public:
|
||||
virtual ~wglGraphicsStateGuardian();
|
||||
|
||||
INLINE int get_pfnum() const;
|
||||
INLINE bool made_context() const;
|
||||
INLINE HGLRC get_context(HDC hdc);
|
||||
|
||||
virtual void reset();
|
||||
|
||||
private:
|
||||
void make_context(HDC hdc);
|
||||
void show_gl_string(const string &name, GLenum id);
|
||||
void save_extensions(const char *extensions);
|
||||
|
||||
// All windows that share a particular GL context must also share
|
||||
// the same pixel format; therefore, we store the pixel format
|
||||
@ -47,6 +53,23 @@ private:
|
||||
bool _made_context;
|
||||
HGLRC _context;
|
||||
|
||||
pset<string> _extensions;
|
||||
|
||||
public:
|
||||
bool _supports_pbuffer;
|
||||
|
||||
wglCreatePbufferARB_proc _wglCreatePbufferARB;
|
||||
wglGetPbufferDCARB_proc _wglGetPbufferDCARB;
|
||||
wglReleasePbufferDCARB_proc _wglReleasePbufferDCARB;
|
||||
wglDestroyPbufferARB_proc _wglDestroyPbufferARB;
|
||||
wglQueryPbufferARB_proc _wglQueryPbufferARB;
|
||||
|
||||
bool _supports_pixel_format;
|
||||
|
||||
wglGetPixelFormatAttribivARB_proc _wglGetPixelFormatAttribivARB;
|
||||
wglGetPixelFormatAttribfvARB_proc _wglGetPixelFormatAttribfvARB;
|
||||
wglChoosePixelFormatARB_proc _wglChoosePixelFormatARB;
|
||||
|
||||
public:
|
||||
static TypeHandle get_class_type() {
|
||||
return _type_handle;
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user