PolyGLES1Renderer.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. * PolyGLES1Renderer.h
  3. * Poly
  4. *
  5. * Created by Ivan Safrin on 2/1/10.
  6. * Copyright 2010 Ivan Safrin. All rights reserved.
  7. *
  8. */
  9. // @package Renderer
  10. #pragma once
  11. #include "PolyLogger.h"
  12. #include "PolyGlobals.h"
  13. #include "PolyRenderer.h"
  14. #include "PolyTexture.h"
  15. #include "PolyGLES1Texture.h"
  16. #include "PolyCubemap.h"
  17. #include "PolyFixedShader.h"
  18. #include "PolyMesh.h"
  19. #include <OpenGLES/ES1/gl.h>
  20. #include <OpenGLES/ES1/glext.h>
  21. #include <glu.h>
  22. namespace Polycode {
  23. class _PolyExport OpenGLES1Renderer : public Renderer {
  24. public:
  25. OpenGLES1Renderer();
  26. virtual ~OpenGLES1Renderer();
  27. void Resize(int xRes, int yRes);
  28. void BeginRender();
  29. void EndRender();
  30. Cubemap *createCubemap(Texture *t0, Texture *t1, Texture *t2, Texture *t3, Texture *t4, Texture *t5);
  31. Texture *createTexture(unsigned int width, unsigned int height, char *textureData, bool clamp, int type=Image::IMAGE_RGBA);
  32. Texture *createFramebufferTexture(unsigned int width, unsigned int height);
  33. void createRenderTextures(Texture **colorBuffer, Texture **depthBuffer, int width, int height);
  34. void enableAlphaTest(bool val);
  35. void createVertexBufferForMesh(Mesh *mesh);
  36. void drawVertexBuffer(VertexBuffer *buffer);
  37. void bindFrameBufferTexture(Texture *texture);
  38. void unbindFramebuffers();
  39. void setOrthoMode();
  40. void setPerspectiveMode();
  41. void enableBackfaceCulling(bool val);
  42. void setViewportSize(int w, int h, float fov=45.0f);
  43. void setLineSmooth(bool val);
  44. void loadIdentity();
  45. void setClearColor(float r, float g, float b);
  46. void setTexture(Texture *texture);
  47. void draw2DPolygon(Polygon *polygon);
  48. void draw2DVertex(Vertex *vertex);
  49. void renderToTexture(Texture *targetTexture);
  50. void renderZBufferToTexture(Texture *targetTexture);
  51. void clearScreen();
  52. void translate2D(float x, float y);
  53. void rotate2D(float angle);
  54. void scale2D(Vector2 *scale);
  55. void setLineSize(float lineSize);
  56. void setVertexColor(float r, float g, float b, float a);
  57. void setBlendingMode(int blendingMode);
  58. void enableLighting(bool enable);
  59. void enableFog(bool enable);
  60. void setFogProperties(int fogMode, Color color, float density, float startDepth, float endDepth);
  61. void draw3DPolygon(Polygon *polygon);
  62. void draw3DVertex(Vertex *vertex, Vector2 *faceUV);
  63. void draw3DVertex2UV(Vertex *vertex, Vector2 *faceUV1, Vector2 *faceUV2);
  64. void draw3DLine(Vector3 origin, Vector3 direction, float length, Color color);
  65. virtual void setNormal(const Vector3 &normal);
  66. void translate3D(Vector3 *position);
  67. void translate3D(float x, float y, float z);
  68. void scale3D(Vector3 *scale);
  69. Matrix4 getProjectionMatrix();
  70. Matrix4 getModelviewMatrix();
  71. void setModelviewMatrix(Matrix4 m);
  72. void multModelviewMatrix(Matrix4 m);
  73. void enableDepthTest(bool val);
  74. void drawScreenQuad(float qx, float qy);
  75. void beginRenderOperation(int meshType);
  76. void endRenderOperation();
  77. void pushMatrix();
  78. void popMatrix();
  79. bool test2DCoordinate(float x, float y, Polygon *poly, const Matrix4 &matrix, bool billboardMode);
  80. void setFOV(float fov);
  81. Vector3 Unproject(float x, float y);
  82. void clearShader();
  83. void applyMaterial(Material *material, ShaderBinding *localOptions, unsigned int shaderIndex);
  84. private:
  85. GLuint defaultFramebuffer, colorRenderbuffer;
  86. float nearPlane;
  87. float farPlane;
  88. GLfloat sceneProjectionMatrix[16];
  89. };
  90. }