void VertexBuilder::SetVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) { // Currently only 2 and 3 are valid sizes and GL_FLOAT is the only supported pointer type. gl2dxAssert(size == 2 || size == 3, "Only 2 and 3 are valid for size"); gl2dxAssert(type == GL_FLOAT, "GL_FLOAT is the only supported vertex pointer type"); _vectorPointerSize = size; _vectorPointerType = type; _vectorPointerStride = stride; _vectorPointer = (GLbyte*)pointer; _vectorPointerMemberSize = sizeof(GLfloat); }
void OpenGL::PopMatrix() { gl2dxAssert(_matrices.size() > 0, "Matrix stack is empty in PopMatrix"); auto matrix = _matrices.top(); _matrices.pop(); delete matrix; }
void OpenGL::DrawBatch() { if (_currentBatchVertex > 0) { gl2dxAssert(_currentBatchVertex < _maxVertices, "Exceeded max vertices"); if (_batchEnableTexture2D && _batchCurrentTextureId > 0) { ID3D11ShaderResourceView* texture = _textures[_batchCurrentTextureId]; // Set shader texture resource in the pixel shader. _context->PSSetShader(_pixelShaderTexture, nullptr, 0); _context->PSSetShaderResources(0, 1, &texture); } else { _context->PSSetShader(_pixelShaderColor, nullptr, 0); } D3D11_MAPPED_SUBRESOURCE mappedResource; D3D11_MAP mapType = D3D11_MAP::D3D11_MAP_WRITE_DISCARD; auto hr = _context->Map(_vertexBuffer, 0, mapType, 0, &mappedResource); if (SUCCEEDED(hr)) { OpenGLVertex *pData = reinterpret_cast<OpenGLVertex *>(mappedResource.pData); memcpy(pData, _batchVertices, sizeof(OpenGLVertex) * _currentBatchVertex); _context->Unmap(_vertexBuffer, 0); } _context->Draw(_currentBatchVertex, 0); _currentBatchVertex = 0; } }
void VertexBuilder::SetColorPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) { gl2dxAssert(type == GL_UNSIGNED_BYTE, "GL_UNSIGNED_BYTE is the only supported glColorPointer mode"); _colorPointerSize = size; _colorPointerType = type; _colorPointerStride = stride; _colorPointer = (GLubyte*)pointer; }