⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 display_window_opengl.h

📁 这是一款2d游戏引擎
💻 H
字号:
/*  $Id: display_window_opengl.h,v 1.18 2003/12/16 16:47:03 mbn Exp $
**
**  ClanLib Game SDK
**  Copyright (C) 2003  The ClanLib Team
**  For a total list of contributers see the file CREDITS.
**
**  This library is free software; you can redistribute it and/or
**  modify it under the terms of the GNU Lesser General Public
**  License as published by the Free Software Foundation; either
**  version 2.1 of the License, or (at your option) any later version.
**
**  This library is distributed in the hope that it will be useful,
**  but WITHOUT ANY WARRANTY; without even the implied warranty of
**  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
**  Lesser General Public License for more details.
**
**  You should have received a copy of the GNU Lesser General Public
**  License along with this library; if not, write to the Free Software
**  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
*/

#ifndef header_display_window_opengl
#define header_display_window_opengl

#if _MSC_VER > 1000
#pragma once
#endif

#ifdef WIN32
#include <windows.h>
#endif

#include "Display/Win32/display_window_win32.h"
#include "API/Display/graphic_context.h"
#include "API/Display/pixel_buffer.h"

#include <GL/glu.h>
#include <stack>

class CL_DisplayWindow_OpenGL : public CL_DisplayWindow_Win32
{
//! Construction:
public:
	CL_DisplayWindow_OpenGL();

	virtual ~CL_DisplayWindow_OpenGL();

//! Attributes:
public:
	//: Returns the gc of this window.
	virtual CL_GraphicContext *get_gc();

	//: Returns pixel buffer of frame buffer.
	virtual CL_PixelBuffer &get_buffer(int i);

	virtual const CL_PixelBuffer &get_buffer(int i) const;

	//: Returns the number of frame buffers.
	virtual int get_buffer_count() const;

	//: OpenGL rendering context for this window.
	HGLRC get_context() { return context; }

	//: Device context for this window.
	HDC get_dc();

	static std::list<HGLRC> opengl_contexts;

//! Operations:
public:
	//: Called when a window is to be created.
	virtual void create_window(const CL_DisplayWindowDescription &desc);

	//: Called when a window is destroyed.
	virtual void destroy_window();

	//: Called when window receives a windows event.
	virtual bool received_event(UINT uMsg, WPARAM wParam, LPARAM lParam);

	//: Flip opengl buffers.
	virtual void flip();

	//: Copy a region of the backbuffer to the frontbuffer.
	virtual void update(const CL_Rect &rect);

//! Implementation:
private:
	//: Repaint layered window.
	void repaint_layered();

	//: OpenGL compatible gc.
	CL_GraphicContext gc;

	//: OpenGL frame buffer access.
	CL_PixelBuffer buffer_front, buffer_back;

	//: OpenGL rendering context for this window.
	HGLRC context;

	//: Device context for this window.
	HDC hdc;

	//: Device context to layered bitmap.
	HDC layered_dc;

	//: Layered bitmap.
	HBITMAP layered_bitmap;

	//: Original bitmap selected into the layered DC.
	HBITMAP layered_orig_bitmap;

	//: Layered window, user32.dll dll handle.
	HMODULE user32_dll;

	//: Layered window, function pointer for UpdateLayeredWindow.
	typedef BOOL (WINAPI *PtrUpdateLayeredWindow)(
	  HWND, HDC, POINT *, SIZE *, HDC, POINT *, COLORREF, BLENDFUNCTION *, DWORD);

	PtrUpdateLayeredWindow ptr_UpdateLayeredWindow;
};

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -