27 drawable.
draw(*
this, states);
33 glCheck(glDrawArrays(mode, firstVertex, vertexCount));
40 glCheck(glDrawElements(mode, count, type, indices));
45 if (!states.
shader)
return;
60 glCheck(glVertexAttribPointer(states.
shader->
attrib(
"coord3d"), 4, GL_FLOAT, GL_FALSE,
sizeof(
Vertex), reinterpret_cast<GLvoid *>(offsetof(
Vertex, coord3d))));
65 glCheck(glVertexAttribPointer(states.
shader->
attrib(
"normal"), 3, GL_FLOAT, GL_FALSE,
sizeof(
Vertex), reinterpret_cast<GLvoid *>(offsetof(
Vertex, normal))));
70 glCheck(glVertexAttribPointer(states.
shader->
attrib(
"texCoord"), 2, GL_FLOAT, GL_FALSE,
sizeof(
Vertex), reinterpret_cast<GLvoid *>(offsetof(
Vertex, texCoord))));
75 glCheck(glVertexAttribPointer(states.
shader->
attrib(
"color"), 4, GL_FLOAT, GL_FALSE,
sizeof(
Vertex), reinterpret_cast<GLvoid *>(offsetof(
Vertex, color))));
80 glCheck(glVertexAttribPointer(states.
shader->
attrib(
"lightValue"), 2, GL_FLOAT, GL_FALSE,
sizeof(
Vertex), reinterpret_cast<GLvoid *>(offsetof(
Vertex, lightValue))));
85 glCheck(glVertexAttribPointer(states.
shader->
attrib(
"blockType"), 1, GL_FLOAT, GL_FALSE,
sizeof(
Vertex), reinterpret_cast<GLvoid *>(offsetof(
Vertex, blockType))));
90 glCheck(glVertexAttribPointer(states.
shader->
attrib(
"ambientOcclusion"), 1, GL_FLOAT, GL_FALSE,
sizeof(
Vertex), reinterpret_cast<GLvoid *>(offsetof(
Vertex, ambientOcclusion))));
98 if (!states.
shader)
return;
123 float width =
static_cast<float>(
getSize().
x);
124 float height =
static_cast<float>(
getSize().
y);
127 return IntRect(static_cast<int>(0.5f + width * viewport.
x),
128 static_cast<int>(0.5f + height * viewport.
y),
129 static_cast<int>(width * viewport.
width),
130 static_cast<int>(height * viewport.
height));
137 glViewport(viewport.
x, top, viewport.
width, viewport.
height);
void enableVertexAttribArray(const std::string &name) const
Transform projectionMatrix
void beginDrawing(const RenderStates &states)
const FloatRect & getViewport() const
void disableVertexAttribArray(const std::string &name) const
2D view that defines what is shown on screen
void applyCurrentView(const RenderStates &states)
IntRect getViewport(const View &view) const
void endDrawing(const RenderStates &states)
static void bind(const Texture *texture)
Bind a texture for rendering.
virtual Vector2u getSize() const =0
T y
Top coordinate of the rectangle.
void draw(const IDrawable &drawable, const RenderStates &states=RenderStates::Default)
virtual void draw(RenderTarget &target, RenderStates states) const =0
Draw the object to a render target.
static void bind(const Shader *shader)
static void bind(const VertexBuffer *vertexBuffer)
static const RenderStates Default
virtual const Transform & getTransform() const
IntRect m_previousViewport
GLint attrib(const std::string &name) const
Abstract base class for objects that can be drawn to a render target.
T x
Left coordinate of the rectangle.
virtual const Transform & getViewTransform() const
T width
Width of the rectangle.
void setUniform(const std::string &name, int n) const
void drawElements(const VertexBuffer &vertexBuffer, GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, const RenderStates &states=RenderStates::Default)
T height
Height of the rectangle.