Rice GLES2 (from mupen64plus-ae) plugin. Compile but doesn't works well on the OpenPa...
[mupen64plus-pandora.git] / source / gles2rice / src / GraphicsContext.cpp
1 /*
2
3   Copyright (C) 2003 Rice1964
4
5   This program is free software; you can redistribute it and/or
6   modify it under the terms of the GNU General Public License
7   as published by the Free Software Foundation; either version 2
8   of the License, or (at your option) any later version.
9
10   This program is distributed in the hope that it will be useful,
11   but WITHOUT ANY WARRANTY; without even the implied warranty of
12   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13   GNU General Public License for more details.
14
15   You should have received a copy of the GNU General Public License
16   along with this program; if not, write to the Free Software
17   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18
19 */
20
21 #define M64P_PLUGIN_PROTOTYPES 1
22 #include "m64p_plugin.h"
23 #include "m64p_vidext.h"
24
25 #include "FrameBuffer.h"
26 #include "OGLGraphicsContext.h"
27 #include "Video.h"
28
29 CGraphicsContext* CGraphicsContext::g_pGraphicsContext = NULL;
30 bool CGraphicsContext::m_deviceCapsIsInitialized = false;
31 bool CGraphicsContext::needCleanScene = false;
32 int CGraphicsContext::m_maxFSAA = 16;
33 int CGraphicsContext::m_maxAnisotropy = 16;
34
35 CGraphicsContext * CGraphicsContext::Get(void)
36 {   
37     return CGraphicsContext::g_pGraphicsContext;
38 }
39     
40 CGraphicsContext::CGraphicsContext() :
41     m_supportTextureMirror(false),
42     m_bReady(false), 
43         m_bActive(false),
44         m_bWindowed(true)
45 {
46 }
47 CGraphicsContext::~CGraphicsContext()
48 {
49     g_pFrameBufferManager->CloseUp();
50 }
51
52 uint32 CGraphicsContext::m_dwWindowStyle=0;         // Saved window style for mode switches
53 uint32 CGraphicsContext::m_dwWindowExStyle=0;       // Saved window style for mode switches
54 uint32 CGraphicsContext::m_dwStatusWindowStyle=0;   // Saved window style for mode switches
55
56 void CGraphicsContext::InitWindowInfo()
57 {
58 }
59
60 bool CGraphicsContext::Initialize(uint32 dwWidth, uint32 dwHeight, BOOL bWindowed)
61 {
62     m_bWindowed = (bWindowed != 0);
63
64     g_pFrameBufferManager->Initialize();
65     return true;
66 }
67
68 bool CGraphicsContext::ResizeInitialize(uint32 dwWidth, uint32 dwHeight, BOOL bWindowed )
69 {
70     return true;
71 }
72
73 void CGraphicsContext::CleanUp()
74 {
75     m_bActive = false;
76     m_bReady  = false;
77 }
78
79
80 int __cdecl SortFrequenciesCallback( const void* arg1, const void* arg2 )
81 {
82     unsigned int* p1 = (unsigned int*)arg1;
83     unsigned int* p2 = (unsigned int*)arg2;
84
85     if( *p1 < *p2 )   
86         return -1;
87     else if( *p1 > *p2 )   
88         return 1;
89     else 
90         return 0;
91 }
92 int __cdecl SortResolutionsCallback( const void* arg1, const void* arg2 )
93 {
94     unsigned int* p1 = (unsigned int*)arg1;
95     unsigned int* p2 = (unsigned int*)arg2;
96
97     if( *p1 < *p2 )   
98         return -1;
99     else if( *p1 > *p2 )   
100         return 1;
101     else 
102     {
103         if( p1[1] < p2[1] )   
104             return -1;
105         else if( p1[1] > p2[1] )   
106             return 1;
107         else
108             return 0;
109     }
110 }
111
112 // This is a static function, will be called when the plugin DLL is initialized
113 void CGraphicsContext::InitDeviceParameters(void)
114 {
115     // To initialze device parameters for OpenGL
116     COGLGraphicsContext::InitDeviceParameters();
117 }
118