2 Copyright (C) 2003 Rice1964
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 #include "osal_opengl.h"
21 #include "OGLRender.h"
23 extern Matrix g_MtxReal;
24 extern uObjMtxReal gObjMtxReal;
26 //========================================================================
28 void OGLRender::DrawText(const char* str, RECT *rect)
33 void OGLRender::DrawSpriteR_Render() // With Rotation
35 glViewportWrapper(0, windowSetting.statusBarHeightToUse, windowSetting.uDisplayWidth, windowSetting.uDisplayHeight);
37 GLboolean cullface = glIsEnabled(GL_CULL_FACE);
38 glDisable(GL_CULL_FACE);
44 gRDP.fvPrimitiveColor[0], gRDP.fvPrimitiveColor[1], gRDP.fvPrimitiveColor[2], gRDP.fvPrimitiveColor[3],
45 gRDP.fvPrimitiveColor[0], gRDP.fvPrimitiveColor[1], gRDP.fvPrimitiveColor[2], gRDP.fvPrimitiveColor[3],
46 gRDP.fvPrimitiveColor[0], gRDP.fvPrimitiveColor[1], gRDP.fvPrimitiveColor[2], gRDP.fvPrimitiveColor[3],
48 gRDP.fvPrimitiveColor[0], gRDP.fvPrimitiveColor[1], gRDP.fvPrimitiveColor[2], gRDP.fvPrimitiveColor[3],
49 gRDP.fvPrimitiveColor[0], gRDP.fvPrimitiveColor[1], gRDP.fvPrimitiveColor[2], gRDP.fvPrimitiveColor[3],
50 gRDP.fvPrimitiveColor[0], gRDP.fvPrimitiveColor[1], gRDP.fvPrimitiveColor[2], gRDP.fvPrimitiveColor[3],
54 g_texRectTVtx[0].tcord[0].u,g_texRectTVtx[0].tcord[0].v,
55 g_texRectTVtx[1].tcord[0].u,g_texRectTVtx[1].tcord[0].v,
56 g_texRectTVtx[2].tcord[0].u,g_texRectTVtx[2].tcord[0].v,
58 g_texRectTVtx[0].tcord[0].u,g_texRectTVtx[0].tcord[0].v,
59 g_texRectTVtx[2].tcord[0].u,g_texRectTVtx[2].tcord[0].v,
60 g_texRectTVtx[3].tcord[0].u,g_texRectTVtx[3].tcord[0].v,
63 GLfloat vertices[] = {
64 g_texRectTVtx[0].x, g_texRectTVtx[0].y, -g_texRectTVtx[0].z, 1,
65 g_texRectTVtx[1].x, g_texRectTVtx[1].y, -g_texRectTVtx[1].z, 1,
66 g_texRectTVtx[2].x, g_texRectTVtx[2].y, -g_texRectTVtx[2].z, 1,
68 g_texRectTVtx[0].x, g_texRectTVtx[0].y, -g_texRectTVtx[0].z, 1,
69 g_texRectTVtx[2].x, g_texRectTVtx[2].y, -g_texRectTVtx[2].z, 1,
70 g_texRectTVtx[3].x, g_texRectTVtx[3].y, -g_texRectTVtx[3].z, 1
73 glColorPointer(4, GL_FLOAT, 0, &colour );
74 glVertexPointer(4,GL_FLOAT, 0,&vertices);
77 glClientActiveTexture( GL_TEXTURE1 );
78 // if (m_texUnitEnabled[1])
79 // glEnableClientState( GL_TEXTURE_COORD_ARRAY );
80 // glTexCoordPointer(2, GL_FLOAT, 0, &tex);
82 glDisableClientState( GL_TEXTURE_COORD_ARRAY );
83 glClientActiveTexture( GL_TEXTURE0 );
85 // if (m_texUnitEnabled[0])
86 // glEnableClientState( GL_TEXTURE_COORD_ARRAY );
87 glTexCoordPointer(2, GL_FLOAT, 0, &tex);
89 // glDisableClientState( GL_TEXTURE_COORD_ARRAY );
90 glDrawArrays(GL_TRIANGLES,0,6);
91 //Restore old pointers
92 glColorPointer( 4, GL_UNSIGNED_BYTE, sizeof(uint8)*4, &(g_oglVtxColors[0][0]) );
93 // if (m_texUnitEnabled[1])
94 glTexCoordPointer( 2, GL_FLOAT, sizeof( TLITVERTEX ), &(g_vtxBuffer[0].tcord[0].u) );
96 // glEnableClientState( GL_TEXTURE_COORD_ARRAY );
97 glVertexPointer( 4, GL_FLOAT, sizeof(float)*5, &(g_vtxProjected5[0][0]) );
100 glClientActiveTexture( GL_TEXTURE1 );
101 // if (m_texUnitEnabled[1])
102 // glTexCoordPointer( 2, GL_FLOAT, sizeof( TLITVERTEX ), &(g_vtxBuffer[0].tcord[1].u) );
104 glEnableClientState( GL_TEXTURE_COORD_ARRAY );
107 glBegin(GL_TRIANGLES);
108 glColor4fv(gRDP.fvPrimitiveColor);
110 OGLRender::TexCoord(g_texRectTVtx[0]);
111 glVertex3f(g_texRectTVtx[0].x, g_texRectTVtx[0].y, -g_texRectTVtx[0].z);
113 OGLRender::TexCoord(g_texRectTVtx[1]);
114 glVertex3f(g_texRectTVtx[1].x, g_texRectTVtx[1].y, -g_texRectTVtx[1].z);
116 OGLRender::TexCoord(g_texRectTVtx[2]);
117 glVertex3f(g_texRectTVtx[2].x, g_texRectTVtx[2].y, -g_texRectTVtx[2].z);
119 OGLRender::TexCoord(g_texRectTVtx[0]);
120 glVertex3f(g_texRectTVtx[0].x, g_texRectTVtx[0].y, -g_texRectTVtx[0].z);
122 OGLRender::TexCoord(g_texRectTVtx[2]);
123 glVertex3f(g_texRectTVtx[2].x, g_texRectTVtx[2].y, -g_texRectTVtx[2].z);
125 OGLRender::TexCoord(g_texRectTVtx[3]);
126 glVertex3f(g_texRectTVtx[3].x, g_texRectTVtx[3].y, -g_texRectTVtx[3].z);
130 #elif SDL_VIDEO_OPENGL_ES2
133 gRDP.fvPrimitiveColor[0], gRDP.fvPrimitiveColor[1], gRDP.fvPrimitiveColor[2], gRDP.fvPrimitiveColor[3],
134 gRDP.fvPrimitiveColor[0], gRDP.fvPrimitiveColor[1], gRDP.fvPrimitiveColor[2], gRDP.fvPrimitiveColor[3],
135 gRDP.fvPrimitiveColor[0], gRDP.fvPrimitiveColor[1], gRDP.fvPrimitiveColor[2], gRDP.fvPrimitiveColor[3],
137 gRDP.fvPrimitiveColor[0], gRDP.fvPrimitiveColor[1], gRDP.fvPrimitiveColor[2], gRDP.fvPrimitiveColor[3],
138 gRDP.fvPrimitiveColor[0], gRDP.fvPrimitiveColor[1], gRDP.fvPrimitiveColor[2], gRDP.fvPrimitiveColor[3],
139 gRDP.fvPrimitiveColor[0], gRDP.fvPrimitiveColor[1], gRDP.fvPrimitiveColor[2], gRDP.fvPrimitiveColor[3],
143 g_texRectTVtx[0].tcord[0].u,g_texRectTVtx[0].tcord[0].v,
144 g_texRectTVtx[1].tcord[0].u,g_texRectTVtx[1].tcord[0].v,
145 g_texRectTVtx[2].tcord[0].u,g_texRectTVtx[2].tcord[0].v,
147 g_texRectTVtx[0].tcord[0].u,g_texRectTVtx[0].tcord[0].v,
148 g_texRectTVtx[2].tcord[0].u,g_texRectTVtx[2].tcord[0].v,
149 g_texRectTVtx[3].tcord[0].u,g_texRectTVtx[3].tcord[0].v,
152 float w = windowSetting.uDisplayWidth / 2.0f, h = windowSetting.uDisplayHeight / 2.0f, inv = 1.0f;
154 GLfloat vertices[] = {
155 -inv + g_texRectTVtx[0].x/ w, inv - g_texRectTVtx[0].y/ h, -g_texRectTVtx[0].z,1,
156 -inv + g_texRectTVtx[1].x/ w, inv - g_texRectTVtx[1].y/ h, -g_texRectTVtx[1].z,1,
157 -inv + g_texRectTVtx[2].x/ w, inv - g_texRectTVtx[2].y/ h, -g_texRectTVtx[2].z,1,
159 -inv + g_texRectTVtx[0].x/ w, inv - g_texRectTVtx[0].y/ h, -g_texRectTVtx[0].z,1,
160 -inv + g_texRectTVtx[2].x/ w, inv - g_texRectTVtx[2].y/ h, -g_texRectTVtx[2].z,1,
161 -inv + g_texRectTVtx[3].x/ w, inv - g_texRectTVtx[3].y/ h, -g_texRectTVtx[3].z,1
165 glVertexAttribPointer(VS_COLOR, 4, GL_FLOAT,GL_FALSE, 0, &colour );
166 glVertexAttribPointer(VS_POSITION,4,GL_FLOAT,GL_FALSE,0,&vertices);
167 glVertexAttribPointer(VS_TEXCOORD0,2,GL_FLOAT,GL_FALSE, 0, &tex);
168 //OPENGL_CHECK_ERRORS;
169 glDrawArrays(GL_TRIANGLES,0,6);
170 //OPENGL_CHECK_ERRORS;
172 //Restore old pointers
173 glVertexAttribPointer(VS_COLOR, 4, GL_UNSIGNED_BYTE,GL_TRUE, sizeof(uint8)*4, &(g_oglVtxColors[0][0]) );
174 glVertexAttribPointer(VS_POSITION,4,GL_FLOAT,GL_FALSE,sizeof(float)*5,&(g_vtxProjected5[0][0]));
175 glVertexAttribPointer(VS_TEXCOORD0,2,GL_FLOAT,GL_FALSE, sizeof( TLITVERTEX ), &(g_vtxBuffer[0].tcord[0].u));
179 if( cullface ) glEnable(GL_CULL_FACE);
183 void OGLRender::DrawObjBGCopy(uObjBg &info)
185 if( IsUsedAsDI(g_CI.dwAddr) )
187 DebugMessage(M64MSG_WARNING, "Unimplemented: write into Z buffer. Was mostly commented out in Rice Video 6.1.0");
192 CRender::LoadObjBGCopy(info);
193 CRender::DrawObjBGCopy(info);