void GL3CharacterRenderer::render() {
	Character &localCharacter = client->getLocalCharacter();

		auto &defaultShader = ((GL3Renderer *) renderer)->getShaderManager()->getDefaultShader();

	glm::mat4 viewMatrix = glm::rotate(glm::mat4(1.0f), (float) (-localCharacter.getPitch() / 36000.0f * TAU), glm::vec3(1.0f, 0.0f, 0.0f));
	viewMatrix = glm::rotate(viewMatrix, (float) (-localCharacter.getYaw() / 36000.0f * TAU), glm::vec3(0.0f, 1.0f, 0.0f));
	viewMatrix = glm::rotate(viewMatrix, (float) (-TAU / 4.0), glm::vec3(1.0f, 0.0f, 0.0f));
	viewMatrix = glm::rotate(viewMatrix, (float) (TAU / 4.0), glm::vec3(0.0f, 0.0f, 1.0f));

	defaultShader.setViewMatrix(viewMatrix);
	defaultShader.setLightEnabled(true);
	defaultShader.setFogEnabled(client->getConf().fog != Fog::NONE);

	for (uint i = 0; i < MAX_CLIENTS; i++) {
		if (i == client->getLocalClientId())
			continue;
		Character &character = client->getWorld()->getCharacter(i);
		if (!character.isValid())
			continue;
		vec3i64 pDiff = character.getPos() - localCharacter.getPos();
		glm::mat4 modelMatrix = glm::translate(glm::mat4(1.0f), glm::vec3(
			(float) pDiff[0] / RESOLUTION,
			(float) pDiff[1] / RESOLUTION,
			(float) pDiff[2] / RESOLUTION)
		);
		modelMatrix = glm::rotate(modelMatrix, (float) (character.getYaw() / 36000.0f * TAU), glm::vec3(0.0f, 0.0f, 1.0f));

		defaultShader.setModelMatrix(modelMatrix);
		defaultShader.useProgram();

		GL(BindVertexArray(bodyVao));
		GL(DrawArrays(GL_TRIANGLES, 0, 144));

		modelMatrix = glm::translate(modelMatrix, glm::vec3(
			0.0f,
			0.0f,
			(float)  HEAD_ANCHOR_Z_OFFSET / RESOLUTION)
		);

		int pitch = clamp(character.getPitch(), PITCH_MIN * 100, PITCH_MAX * 100);
		modelMatrix = glm::rotate(modelMatrix, (float) (-pitch / 36000.0f * TAU), glm::vec3(0.0f, 1.0f, 0.0f));

		defaultShader.setModelMatrix(modelMatrix);
		defaultShader.useProgram();

		GL(BindVertexArray(headVao));
		GL(DrawArrays(GL_TRIANGLES, 0, 144));
		GL(BindVertexArray(0));
	}
}
Example #2
0
void GLCpuPosInstancedArraysBench::glDraw(int loops, const GrGLContext* ctx) {
    const GrGLInterface* gl = ctx->interface();

    uint32_t maxTrianglesPerFlush = fDrawDiv == 0 ?  kNumTri :
                                                     kDrawMultiplier / fDrawDiv;
    uint32_t trianglesToDraw = loops * kDrawMultiplier;

    if (kUseInstance_VboSetup == fVboSetup) {
        while (trianglesToDraw > 0) {
            uint32_t triangles = SkTMin(trianglesToDraw, maxTrianglesPerFlush);
            GR_GL_CALL(gl, DrawArraysInstanced(GR_GL_TRIANGLES, 0, kVerticesPerTri, triangles));
            trianglesToDraw -= triangles;
        }
    } else {
        while (trianglesToDraw > 0) {
            uint32_t triangles = SkTMin(trianglesToDraw, maxTrianglesPerFlush);
            GR_GL_CALL(gl, DrawArrays(GR_GL_TRIANGLES, 0, kVerticesPerTri * triangles));
            trianglesToDraw -= triangles;
        }
    }

#if 0
    //const char* filename = "/data/local/tmp/out.png";
    SkString filename("out");
    filename.appendf("_%s.png", this->getName());
    DumpImage(gl, kScreenWidth, kScreenHeight, filename.c_str());
#endif
}
Example #3
0
void CVertexArray::DrawArray0(const int drawType,int stride) {
	CheckEndStrip();
	glEnableClientState(GL_VERTEX_ARRAY);
	glVertexPointer(3,GL_FLOAT,stride,drawArray);
	DrawArrays(drawType, stride);
	glDisableClientState(GL_VERTEX_ARRAY);
}
Example #4
0
void CVertexArray::DrawArrayT(const int drawType,int stride) {
	CheckEndStrip();
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
	glEnableClientState(GL_VERTEX_ARRAY);
	glVertexPointer(3,GL_FLOAT,stride,drawArray);
	glTexCoordPointer(2,GL_FLOAT,stride,drawArray+3);
	DrawArrays(drawType, stride);
	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
	glDisableClientState(GL_VERTEX_ARRAY);
}
Example #5
0
void CVertexArray::DrawArrayC(const int drawType,int stride) {
	CheckEndStrip();
	glEnableClientState(GL_VERTEX_ARRAY);
	glEnableClientState(GL_COLOR_ARRAY);
	glVertexPointer(3,GL_FLOAT,stride,drawArray);
	glColorPointer(4,GL_UNSIGNED_BYTE,stride,drawArray+3);
	DrawArrays(drawType, stride);
	glDisableClientState(GL_VERTEX_ARRAY);
	glDisableClientState(GL_COLOR_ARRAY);
}
Example #6
0
void CVertexArrayRange::DrawArrayT(int drawType,int stride) {
    CheckEndStrip();
    glVertexPointer(3,GL_FLOAT,stride,&drawArray[0]);
    glTexCoordPointer(2,GL_FLOAT,stride,&drawArray[3]);
    glEnableClientState(GL_TEXTURE_COORD_ARRAY);
    glEnableClientState(GL_VERTEX_ARRAY);
    DrawArrays(drawType, stride);
    glSetFenceNV(fence, GL_ALL_COMPLETED_NV);
    glDisableClientState(GL_TEXTURE_COORD_ARRAY);
    glDisableClientState(GL_VERTEX_ARRAY);
}
Example #7
0
void CVertexArray::DrawArray2d0(const int drawType, unsigned int stride)
{
	if (drawIndex() == 0)
		return;

	CheckEndStrip();
	glEnableClientState(GL_VERTEX_ARRAY);
	glVertexPointer(2, GL_FLOAT, stride, drawArray);
	DrawArrays(drawType, stride);
	glDisableClientState(GL_VERTEX_ARRAY);
}
Example #8
0
void CVertexArray::DrawArrayTC(const int drawType, unsigned int stride)
{
	CheckEndStrip();
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
	glEnableClientState(GL_VERTEX_ARRAY);
	glEnableClientState(GL_COLOR_ARRAY);
	glVertexPointer(3,GL_FLOAT,stride,drawArray);
	glTexCoordPointer(2,GL_FLOAT,stride,drawArray+3);
	glColorPointer(4,GL_UNSIGNED_BYTE,stride,drawArray+5);
	DrawArrays(drawType, stride);
	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
	glDisableClientState(GL_VERTEX_ARRAY);
	glDisableClientState(GL_COLOR_ARRAY);
}
Example #9
0
void GLVec4ScalarBench::glDraw(int loops, const GrGLContext* ctx) {
    const GrGLInterface* gl = ctx->interface();

    for (int i = 0; i < loops; i++) {
        GR_GL_CALL(gl, DrawArrays(GR_GL_TRIANGLES, 0, kVerticesPerTri * kNumTriPerDraw));
    }

// using -w when running nanobench will not produce correct images;
// changing this to #if 1 will write the correct images to the Skia folder.
#if 0
    SkString filename("out");
    filename.appendf("_%s.png", this->getName());
    DumpImage(gl, kScreenWidth, kScreenHeight, filename.c_str());
#endif
}
Example #10
0
void CVertexArray::DrawArrayTN(const int drawType, unsigned int stride)
{
	if (drawIndex() == 0)
		return;

	CheckEndStrip();
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
	glEnableClientState(GL_VERTEX_ARRAY);
	glEnableClientState(GL_NORMAL_ARRAY);

	glVertexPointer(3, GL_FLOAT, stride, drawArray);
	glTexCoordPointer(2, GL_FLOAT, stride, drawArray + 3);
	glNormalPointer(GL_FLOAT, stride, drawArray + 5);
	DrawArrays(drawType, stride);

	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
	glDisableClientState(GL_VERTEX_ARRAY);
	glDisableClientState(GL_NORMAL_ARRAY);
}
Example #11
0
void CVertexArray::DrawArrayT2(const int drawType,unsigned int stride)
{
	CheckEndStrip();
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
	glEnableClientState(GL_VERTEX_ARRAY);
	glVertexPointer(3,GL_FLOAT,stride,drawArray);
	glTexCoordPointer(2,GL_FLOAT,stride,drawArray+3);

	glClientActiveTextureARB(GL_TEXTURE1_ARB);
	glTexCoordPointer(2,GL_FLOAT,stride,drawArray+5);
	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
	glClientActiveTextureARB(GL_TEXTURE0_ARB);
	DrawArrays(drawType, stride);
	glClientActiveTextureARB(GL_TEXTURE1_ARB);
	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
	glClientActiveTextureARB(GL_TEXTURE0_ARB);

	glDisableClientState(GL_TEXTURE_COORD_ARRAY);
	glDisableClientState(GL_VERTEX_ARRAY);
}
Example #12
0
void CVertexArray::DrawArrayTNT(const int drawType, unsigned int stride)
{
	if (drawIndex() == 0)
		return;

	CheckEndStrip();

	#define SET_ENABLE_ACTIVE_TEX(texUnit)            \
		glClientActiveTexture(texUnit);               \
		glEnableClientState(GL_TEXTURE_COORD_ARRAY);
	#define SET_DISABLE_ACTIVE_TEX(texUnit)           \
		glClientActiveTexture(texUnit);               \
		glDisableClientState(GL_TEXTURE_COORD_ARRAY);

	glEnableClientState(GL_VERTEX_ARRAY);
	glEnableClientState(GL_NORMAL_ARRAY);

	SET_ENABLE_ACTIVE_TEX(GL_TEXTURE0); glTexCoordPointer(2, GL_FLOAT, stride, drawArray +  3);
	SET_ENABLE_ACTIVE_TEX(GL_TEXTURE1); glTexCoordPointer(2, GL_FLOAT, stride, drawArray +  3); // FIXME? (format-specific)
	SET_ENABLE_ACTIVE_TEX(GL_TEXTURE5); glTexCoordPointer(3, GL_FLOAT, stride, drawArray +  8);
	SET_ENABLE_ACTIVE_TEX(GL_TEXTURE6); glTexCoordPointer(3, GL_FLOAT, stride, drawArray + 11);

	glVertexPointer(3, GL_FLOAT, stride, drawArray + 0);
	glNormalPointer(GL_FLOAT, stride, drawArray + 5);

	DrawArrays(drawType, stride);

	SET_DISABLE_ACTIVE_TEX(GL_TEXTURE6);
	SET_DISABLE_ACTIVE_TEX(GL_TEXTURE5);
	SET_DISABLE_ACTIVE_TEX(GL_TEXTURE1);
	SET_DISABLE_ACTIVE_TEX(GL_TEXTURE0);

	glDisableClientState(GL_NORMAL_ARRAY);
	glDisableClientState(GL_VERTEX_ARRAY);

	#undef SET_ENABLE_ACTIVE_TEX
	#undef SET_DISABLE_ACTIVE_TEX
}
Example #13
0
GL_APICALL void GL_APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count)
{
    CONTEXT_EXEC(DrawArrays(mode, first, count));
}