From 9befaa546866786ca7c05febcd321f12e34e45d6 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Sat, 22 Jun 2013 19:07:09 +0000 Subject: [PATCH] gpu: glGenerateMipmap is not available on the PS3, use glGenerateMipmapOES. --- src/gpu/renderer_private.h | 151 +++++++++++++++++++++++++++++++++++++ src/gpu/texture.cpp | 3 + 2 files changed, 154 insertions(+) create mode 100644 src/gpu/renderer_private.h diff --git a/src/gpu/renderer_private.h b/src/gpu/renderer_private.h new file mode 100644 index 00000000..91b29b2b --- /dev/null +++ b/src/gpu/renderer_private.h @@ -0,0 +1,151 @@ +// +// Lol Engine +// +// Copyright: (c) 2010-2013 Sam Hocevar +// This program is free software; you can redistribute it and/or +// modify it under the terms of the Do What The Fuck You Want To +// Public License, Version 2, as published by Sam Hocevar. See +// http://www.wtfpl.net/ for more details. +// + +// +// The Renderer class +// ------------------ +// + +#if !defined __LOL_RENDERER_H__ +#define __LOL_RENDERER_H__ + +namespace lol +{ + +class RendererData; + +/* A safe enum to indicate the blending factors. */ +struct BlendFunc +{ + enum Value + { + Disabled, + Zero, + One, + SrcColor, + OneMinusSrcColor, + DstColor, + OneMinusDstColor, + SrcAlpha, + OneMinusSrcAlpha, + DstAlpha, + OneMinusDstAlpha, + ConstantColor, + OneMinusConstantColor, + ConstantAlpha, + OneMinusConstantAlpha, + } + m_value; + + inline BlendFunc() : m_value(Zero) {} + inline BlendFunc(Value v) : m_value(v) {} + inline operator Value() { return m_value; } +}; + +/* A safe enum to indicate the face culling mode. */ +struct CullMode +{ + enum Value + { + Disabled, + Clockwise, + CounterClockwise, + } + m_value; + + inline CullMode() : m_value(Disabled) {} + inline CullMode(Value v) : m_value(v) {} + inline operator Value() { return m_value; } +}; + +/* A safe enum to indicate the depth test mode. */ +struct DepthFunc +{ + enum Value + { + Disabled, + Never, + Less, + Equal, + LessOrEqual, + Greater, + NotEqual, + GreaterOrEqual, + Always, + } + m_value; + + inline DepthFunc() : m_value(Disabled) {} + inline DepthFunc(Value v) : m_value(v) {} + inline operator Value() { return m_value; } +}; + +/* A safe enum to indicate the alpha test mode. */ +struct AlphaFunc +{ + enum Value + { + Disabled, + Never, + Less, + Equal, + LessOrEqual, + Greater, + NotEqual, + GreaterOrEqual, + Always, + } + m_value; + + inline AlphaFunc() : m_value(Disabled) {} + inline AlphaFunc(Value v) : m_value(v) {} + inline operator Value() { return m_value; } +}; + +class Renderer +{ +private: + /* Only the Video class can create a renderer for now. */ + friend class Video; + + Renderer(); + ~Renderer(); + +public: + void SetClearColor(vec4 color); + vec4 GetClearColor() const; + + void SetClearDepth(float depth); + float GetClearDepth() const; + + void SetAlphaFunc(AlphaFunc func, float alpha); + AlphaFunc GetAlphaFunc() const; + float GetAlphaValue() const; + + void SetBlendFunc(BlendFunc src, BlendFunc dst); + BlendFunc GetBlendFuncSrc() const; + BlendFunc GetBlendFuncDst() const; + + void SetDepthFunc(DepthFunc func); + DepthFunc GetDepthFunc() const; + + void SetFaceCulling(CullMode mode); + CullMode GetFaceCulling() const; + +private: + RendererData *m_data; +}; + +extern Renderer *g_renderer; + +} /* namespace lol */ + +#endif // __LOL_RENDERER_H__ + diff --git a/src/gpu/texture.cpp b/src/gpu/texture.cpp index 404a9a1c..88794a74 100644 --- a/src/gpu/texture.cpp +++ b/src/gpu/texture.cpp @@ -295,6 +295,9 @@ void Texture::GenerateMipmaps() { #if defined _XBOX || defined USE_D3D9 m_data->m_texture->GenerateMipSubLevels(); +#elif defined __CELLOS_LV2__ + glBindTexture(GL_TEXTURE_2D, m_data->m_texture); + glGenerateMipmapOES(GL_TEXTURE_2D); #else glBindTexture(GL_TEXTURE_2D, m_data->m_texture); glGenerateMipmap(GL_TEXTURE_2D);