Jelajahi Sumber

Fix building of GLES renderer

Daniele Bartolini 13 tahun lalu
induk
melakukan
5363c55924

+ 38 - 38
src/renderers/gles/GLESRenderer.cpp

@@ -25,24 +25,21 @@ OTHER DEALINGS IN THE SOFTWARE.
 
 #include "GLESIndexBuffer.h"
 #include "GLESRenderer.h"
-#include "GLESSupport.h"
 #include "GLESTexture.h"
 #include "GLESTextureManager.h"
 #include "GLESUtils.h"
 #include "GLESVertexBuffer.h"
-#include "Light.h"
 #include "Log.h"
 #include "Material.h"
 #include "Types.h"
 #include "Rect.h"
+#include "Allocator.h"
 #include <GLES/gl.h>
 
 namespace crown
 {
 
 GLESRenderer::GLESRenderer() :
-	mGLESSupport(NULL),
-
 	mMaxLights(0),
 	mMaxTextureSize(0),
 	mMaxTextureUnits(0),
@@ -51,10 +48,13 @@ GLESRenderer::GLESRenderer() :
 
 	mMaxAnisotropy(0.0f),
 
+	mVertexBufferList(get_default_allocator()),
+	mIndexBufferList(get_default_allocator()),
+
 	mActiveTextureUnit(0)
 {
-	mMinMaxPoint32_tSize[0] = 0.0f;
-	mMinMaxPoint32_tSize[1] = 0.0f;
+	mMinMaxPointSize[0] = 0.0f;
+	mMinMaxPointSize[1] = 0.0f;
 
 	for (uint32_t i = 0; i < MAX_TEXTURE_UNITS; i++)
 	{
@@ -65,27 +65,27 @@ GLESRenderer::GLESRenderer() :
 	// This code snippet initializes the matrices
 	for (uint32_t i = 0; i < MT_COUNT; i++)
 	{
-		mMatrix[i].LoadIdentity();
+		mMatrix[i].load_identity();
 	}
 
-	mGLESSupport = GetGLESSupport();
-
-	mGLESSupport->BuildExtensionList();
-
 	glGetIntegerv(GL_MAX_LIGHTS, &mMaxLights);
 	glGetIntegerv(GL_MAX_TEXTURE_SIZE, &mMaxTextureSize);
 	glGetIntegerv(GL_MAX_TEXTURE_UNITS, &mMaxTextureUnits);
 	//glGetIntegerv(GL_MAX_ELEMENTS_INDICES, &mMaxVertexIndices);
 	//glGetIntegerv(GL_MAX_ELEMENTS_VERTICES, &mMaxVertexVertices);
 
-	glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, &mMinMaxPoint32_tSize[0]);
+	glGetFloatv(GL_ALIASED_POINT_SIZE_RANGE, &mMinMaxPointSize[0]);
 	//glGetFloatv(GL_LINE_WIDTH_RANGE, &mMinMaxLineWidth[0]);
 
-	Log::I("OpenGLES Vendor\t: %s", mGLSupport->GetVendor().c_str());
-	Log::I("OpenGLES Renderer\t: %s", mGLSupport->GetRenderer().c_str());
-	Log::I("OpenGLES Version\t: %s", mGLSupport->GetVersion().c_str());
-	Log::I("Min Point32_t Size\t: %f", mMinMaxPoint32_tSize[0]);
-	Log::I("Max Point32_t Size\t: %f", mMinMaxPoint32_tSize[1]);
+	const unsigned char* gl_vendor = glGetString(GL_VENDOR);
+	const unsigned char* gl_renderer = glGetString(GL_RENDERER);
+	const unsigned char* gl_version = glGetString(GL_VERSION);
+
+	Log::I("OpenGL|ES Vendor\t: %s", gl_vendor);
+	Log::I("OpenGL|ES Renderer\t: %s", gl_renderer);
+	Log::I("OpenGL|ES Version\t: %s", gl_version);
+	Log::I("Min Point Size\t: %f", mMinMaxPointSize[0]);
+	Log::I("Max Point Size\t: %f", mMinMaxPointSize[1]);
 	Log::I("Min Line Width\t: %f", mMinMaxLineWidth[0]);
 	Log::I("Max Line Width\t: %f", mMinMaxLineWidth[1]);
 	Log::I("Max Texture Size\t: %dx%d", mMaxTextureSize, mMaxTextureSize);
@@ -118,7 +118,7 @@ GLESRenderer::GLESRenderer() :
 	glLightModelfv(GL_LIGHT_MODEL_AMBIENT, amb);
 
 	// Some hint32_ts
-	glHint32_t(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
+	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
 
 	// Set the framebuffer clear color
 	glClearColor(0.5f, 0.5f, 0.5f, 0.5f);
@@ -138,12 +138,12 @@ GLESRenderer::GLESRenderer() :
 
 GLESRenderer::~GLESRenderer()
 {
-	for (int32_t i = 0; i < mVertexBufferList.GetSize(); i++)
+	for (int32_t i = 0; i < mVertexBufferList.size(); i++)
 	{
 		delete mVertexBufferList[i];
 	}
 
-	for (int32_t i = 0; i < mIndexBufferList.GetSize(); i++)
+	for (int32_t i = 0; i < mIndexBufferList.size(); i++)
 	{
 		delete mIndexBufferList[i];
 	}
@@ -184,7 +184,7 @@ void GLESRenderer::_SetLighting(bool lighting)
 
 void GLESRenderer::_SetAmbientLight(const Color4& color)
 {
-	glLightModelfv(GL_LIGHT_MODEL_AMBIENT, color.ToFloatPtr());
+	glLightModelfv(GL_LIGHT_MODEL_AMBIENT, color.to_float_ptr());
 }
 
 void GLESRenderer::_SetTexturing(uint32_t unit, bool texturing)
@@ -433,7 +433,7 @@ void GLESRenderer::_SetScissorParams(int32_t x, int32_t y, int32_t width, int32_
 	glScissor(x, y, width, height);
 }
 
-void GLESRenderer::_SetPoint32_tSprite(bool sprite)
+void GLESRenderer::_SetPointSprite(bool sprite)
 {
 	if (sprite)
 	{
@@ -447,15 +447,15 @@ void GLESRenderer::_SetPoint32_tSprite(bool sprite)
 	}
 }
 
-void GLESRenderer::_SetPoint32_tSize(float size)
+void GLESRenderer::_SetPointSize(float size)
 {
-	glPoint32_tSize(size);
+	glPointSize(size);
 }
 
-void GLESRenderer::_SetPoint32_tParams(float min, float max)
+void GLESRenderer::_SetPointParams(float min, float max)
 {
-	glPoint32_tParameterf(GL_POINT_SIZE_MIN, min);
-	glPoint32_tParameterf(GL_POINT_SIZE_MAX, max);
+	glPointParameterf(GL_POINT_SIZE_MIN, min);
+	glPointParameterf(GL_POINT_SIZE_MAX, max);
 }
 
 void GLESRenderer::_BeginFrame()
@@ -486,19 +486,19 @@ void GLESRenderer::SetMatrix(MatrixType type, const Mat4& matrix)
 		case MT_MODEL:
 			glMatrixMode(GL_MODELVIEW);
 			// Transformations must be listed in reverse order
-			glLoadMatrixf((mMatrix[MT_VIEW] * mMatrix[MT_MODEL]).ToFloatPtr());
+			glLoadMatrixf((mMatrix[MT_VIEW] * mMatrix[MT_MODEL]).to_float_ptr());
 			break;
 		case MT_PROJECTION:
 			glMatrixMode(GL_PROJECTION);
-			glLoadMatrixf(mMatrix[MT_PROJECTION].ToFloatPtr());
+			glLoadMatrixf(mMatrix[MT_PROJECTION].to_float_ptr());
 			break;
 		case MT_TEXTURE:
 			glMatrixMode(GL_TEXTURE);
-			glLoadMatrixf(mMatrix[MT_TEXTURE].ToFloatPtr());
+			glLoadMatrixf(mMatrix[MT_TEXTURE].to_float_ptr());
 			break;
 		case MT_COLOR:
 			//glMatrixMode(GL_COLOR);
-			//glLoadMatrixf(mMatrix[MT_COLOR].ToFloatPtr());
+			//glLoadMatrixf(mMatrix[MT_COLOR].to_float_ptr());
 			break;
 		default:
 			break;
@@ -559,7 +559,7 @@ void GLESRenderer::RenderVertexIndexBuffer(const VertexBuffer* vertices, const I
 	glDisableClientState(GL_VERTEX_ARRAY);
 }
 
-void GLESRenderer::RenderPoint32_tBuffer(const VertexBuffer* buffer)
+void GLESRenderer::RenderPointBuffer(const VertexBuffer* buffer)
 {
 	if (buffer == NULL)
 		return;
@@ -590,7 +590,7 @@ VertexBuffer*  GLESRenderer::CreateVertexBuffer()
 	if (!vb)
 		return 0;
 
-	mVertexBufferList.Append(vb);
+	mVertexBufferList.push_back(vb);
 	return vb;
 }
 
@@ -601,7 +601,7 @@ IndexBuffer*  GLESRenderer::CreateIndexBuffer()
 	if (!ib)
 		return 0;
 
-	mIndexBufferList.Append(ib);
+	mIndexBufferList.push_back(ib);
 	return ib;
 }
 
@@ -636,7 +636,7 @@ void GLESRenderer::GetScissorBox(uint32_t& x, uint32_t& y, uint32_t& width, uint
 	y = valsViewport[3] - vals[1] - height;
 }
 
-void GLESRenderer::DrawRectangle(const Point32_t2& position, const Point32_t2& dimensions, int32_t drawMode,
+void GLESRenderer::DrawRectangle(const Point2& position, const Point2& dimensions, int32_t drawMode,
 														 const Color4& borderColor, const Color4& fillColor)
 {
 
@@ -692,9 +692,9 @@ void GLESRenderer::_SetLightParams(uint32_t light, LightType type, const Vec3& p
 //-----------------------------------------------------------------------------
 void GLESRenderer::_SetLightColor(uint32_t light, const Color4& ambient, const Color4& diffuse, const Color4& specular)
 {
-	glLightfv(GL_LIGHT0 + light, GL_AMBIENT, ambient.ToFloatPtr());
-	glLightfv(GL_LIGHT0 + light, GL_DIFFUSE, diffuse.ToFloatPtr());
-	glLightfv(GL_LIGHT0 + light, GL_SPECULAR, specular.ToFloatPtr());
+	glLightfv(GL_LIGHT0 + light, GL_AMBIENT, ambient.to_float_ptr());
+	glLightfv(GL_LIGHT0 + light, GL_DIFFUSE, diffuse.to_float_ptr());
+	glLightfv(GL_LIGHT0 + light, GL_SPECULAR, specular.to_float_ptr());
 }
 
 //-----------------------------------------------------------------------------

+ 14 - 20
src/renderers/gles/GLESRenderer.h

@@ -26,7 +26,6 @@ OTHER DEALINGS IN THE SOFTWARE.
 #pragma once
 
 #include <GLES/gl.h>
-#include "List.h"
 #include "Renderer.h"
 
 #define MAX_TEXTURE_UNITS 8
@@ -34,11 +33,8 @@ OTHER DEALINGS IN THE SOFTWARE.
 namespace crown
 {
 
-class GLESSupport;
 
-/**
- * OpenGL|ES 1.1 renderer.
- */
+/// OpenGL|ES 1.1 renderer.
 class GLESRenderer : public Renderer
 {
 	typedef List<VertexBuffer*> VertexBufferList;
@@ -98,9 +94,9 @@ public:
 	void				_SetScissor(bool scissor);
 	void				_SetScissorParams(int32_t x, int32_t y, int32_t width, int32_t height);
 
-	void				_SetPoint32_tSprite(bool sprite);
-	void				_SetPoint32_tSize(float size);
-	void				_SetPoint32_tParams(float min, float max);
+	void				_SetPointSprite(bool sprite);
+	void				_SetPointSize(float size);
+	void				_SetPointParams(float min, float max);
 
 	VertexBuffer*		CreateVertexBuffer();
 	IndexBuffer*		CreateIndexBuffer();
@@ -118,11 +114,11 @@ public:
 	void				SelectMatrix(MatrixType type);
 
 	void				RenderVertexIndexBuffer(const VertexBuffer* vertices, const IndexBuffer* indices);
-	void				RenderPoint32_tBuffer(const VertexBuffer* buffer);
+	void				RenderPointBuffer(const VertexBuffer* buffer);
 
 	void				SetScissorBox(uint32_t x, uint32_t y, uint32_t width, uint32_t height);
 	void				GetScissorBox(uint32_t& x, uint32_t& y, uint32_t& width, uint32_t& height);
-	void				DrawRectangle(const Point32_t2& position, const Point32_t2& dimensions, int32_t drawMode,
+	void				DrawRectangle(const Point2& position, const Point2& dimensions, int32_t drawMode,
 														 const Color4& borderColor, const Color4& fillColor);
 
 	void				AddDebugLine(const Vec3& start, const Vec3& end, const Color4& color) {}
@@ -134,27 +130,25 @@ private:
 
 	void				CheckGLErrors();
 
-	GLESSupport*		mGLESSupport;
-
 	Mat4				mMatrix[MT_COUNT];
 
 	//Mat4				mModelMatrixStack[MAX_MODEL_MATRIX_STACK_DEPTH];
-	//uint32_t				mModelMatrixStackIndex;
+	//uint32_t			mModelMatrixStackIndex;
 
-	int32_t					mMaxLights;
-	int32_t					mMaxTextureSize;
-	int32_t					mMaxTextureUnits;
-	int32_t					mMaxVertexIndices;
-	int32_t					mMaxVertexVertices;
+	int32_t				mMaxLights;
+	int32_t				mMaxTextureSize;
+	int32_t				mMaxTextureUnits;
+	int32_t				mMaxVertexIndices;
+	int32_t				mMaxVertexVertices;
 
 	float				mMaxAnisotropy;
-	float				mMinMaxPoint32_tSize[2];
+	float				mMinMaxPointSize[2];
 	float				mMinMaxLineWidth[2];
 
 	VertexBufferList	mVertexBufferList;
 	IndexBufferList		mIndexBufferList;
 
-	int32_t					mActiveTextureUnit;
+	int32_t				mActiveTextureUnit;
 	Texture*			mTextureUnit[MAX_TEXTURE_UNITS];
 	GLenum				mTextureUnitTarget[MAX_TEXTURE_UNITS];
 };

+ 1 - 1
src/renderers/gles/GLESTextureManager.cpp

@@ -68,7 +68,7 @@ Texture* GLESTextureManager::Load(const char* name, bool generateMipMaps, Color4
 	return texture;
 }
 
-Texture* GLESTextureManager::Load(const char* name, const Str& greyscaleAlpha, bool generateMipMaps)
+Texture* GLESTextureManager::Load(const char* name, const char* greyscaleAlpha, bool generateMipMaps)
 {
 	bool created;
 	Texture* texture = Create(name, created);

+ 1 - 1
src/renderers/gles/GLESTextureManager.h

@@ -68,7 +68,7 @@ public:
 	 */
 	virtual Texture* Load(const char* name, bool generateMipMaps, Color4 colorKey);
 
-	virtual Texture* Load(const char* name, const Str& greyscaleAlpha, bool generateMipMaps);
+	virtual Texture* Load(const char* name, const char* greyscaleAlpha, bool generateMipMaps);
 
 	virtual GLESTexture* CreateSpecific(const char* name);
 

+ 4 - 4
src/renderers/gles/GLESVertexBuffer.cpp

@@ -99,24 +99,24 @@ void GLESVertexBuffer::Bind() const
 
 	glBindBuffer(GL_ARRAY_BUFFER, mBufferID);
 
-	glVertexPoint32_ter(3, GL_FLOAT, vertexSize, (void*) 0);
+	glVertexPointer(3, GL_FLOAT, vertexSize, (void*) 0);
 
 	if (HasNormalCoords())
 	{
-		glNormalPoint32_ter(GL_FLOAT, vertexSize, (void*) offset);
+		glNormalPointer(GL_FLOAT, vertexSize, (void*) offset);
 		offset += sizeof(float) * 3;
 	}
 
 	if (HasTextureCoords())
 	{
 		glClientActiveTexture(GL_TEXTURE0);
-		glTexCoordPoint32_ter(2, GL_FLOAT, vertexSize, (void*) offset);
+		glTexCoordPointer(2, GL_FLOAT, vertexSize, (void*) offset);
 		offset += sizeof(float) * 2;
 	}
 
 	if (HasColorCoords())
 	{
-		glColorPoint32_ter(4, GL_FLOAT, vertexSize, (void*) offset);
+		glColorPointer(4, GL_FLOAT, vertexSize, (void*) offset);
 		offset += sizeof(float) * 4;
 	}
 }