GteGL4Engine.cpp
Go to the documentation of this file.
1 // David Eberly, Geometric Tools, Redmond WA 98052
2 // Copyright (c) 1998-2017
3 // Distributed under the Boost Software License, Version 1.0.
4 // http://www.boost.org/LICENSE_1_0.txt
5 // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
6 // File Version: 3.0.2 (2016/12/09)
7 
8 #include <GTEnginePCH.h>
31 #if defined(NDEBUG)
32 #include <iostream>
33 #endif
34 using namespace gte;
35 
36 //----------------------------------------------------------------------------
37 // Interface specific to GL4.
38 //----------------------------------------------------------------------------
40 {
41 }
42 
44  :
45  mMajor(0),
46  mMinor(0),
47  mMeetsRequirements(false)
48 {
49  // Initialization of GraphicsEngine members that depend on GL4.
50  mILMap = std::make_unique<GL4InputLayoutManager>();
51 
53  {
54  nullptr, // GT_GRAPHICS_OBJECT (abstract base)
55  nullptr, // GT_RESOURCE (abstract base)
56  nullptr, // GT_BUFFER (abstract base)
58  nullptr, // &DX11TextureBuffer::Create,
62  nullptr, // TODO: Implement TypedBuffer
63  nullptr, // &DX11RawBuffer::Create,
64  nullptr, // &DX11IndirectArgumentsBuffer::Create,
65  nullptr, // GT_TEXTURE (abstract base)
66  nullptr, // GT_TEXTURE_SINGLE (abstract base)
72  nullptr, // GT_TEXTURE_ARRAY (abstract base)
77  nullptr, // GT_SHADER (abstract base)
78  nullptr, // &DX11VertexShader::Create,
79  nullptr, // &DX11GeometryShader::Create,
80  nullptr, // &DX11PixelShader::Create,
81  nullptr, // &DX11ComputeShader::Create,
82  nullptr, // GT_DRAWING_STATE (abstract base)
87  };
88 
90 }
91 
93 {
94  std::shared_ptr<GLSLProgramFactory> factory = std::make_shared<GLSLProgramFactory>();
95  mDefaultFont = std::make_shared<FontArialW400H18>(factory, 256);
97 }
98 
100 {
101  if (mDefaultFont)
102  {
103  mDefaultFont = nullptr;
104  mActiveFont = nullptr;
105  }
106 }
107 
108 bool GL4Engine::Initialize(int requiredMajor, int requiredMinor, bool saveDriverInfo)
109 {
110  if (saveDriverInfo)
111  {
112  InitializeOpenGL(mMajor, mMinor, "OpenGLDriverInfo.txt");
113  }
114  else
115  {
116  InitializeOpenGL(mMajor, mMinor, nullptr);
117  }
118 
119  mMeetsRequirements = (mMajor > requiredMajor ||
120  (mMajor == requiredMajor && mMinor >= requiredMinor));
121 
122  if (mMeetsRequirements)
123  {
124  SetViewport(0, 0, mXSize, mYSize);
125  SetDepthRange(0.0f, 1.0f);
128  }
129 #if defined(NDEBUG)
130  else
131  {
132  std::string message = "OpenGL " + std::to_string(requiredMajor) + "."
133  + std::to_string(requiredMinor) + " is required.";
134  std::cout << message << std::endl;
135  }
136 #endif
137  return mMeetsRequirements;
138 }
139 
141 {
142  // The render state objects (and fonts) are destroyed first so that the
143  // render state objects are removed from the bridges before they are
144  // cleared later in the destructor.
147 
148  // Need to remove all the RawBuffer objects used to manage atomic
149  // counter buffers.
150  mAtomicCounterRawBuffers.clear();
151 
153  mGOListener = nullptr;
154 
156  mDTListener = nullptr;
157 
158  if (mGOMap.HasElements())
159  {
161  {
162  LogWarning("Bridge map is nonempty on destruction.");
163  }
164 
165  mGOMap.RemoveAll();
166  }
167 
168  if (mDTMap.HasElements())
169  {
171  {
172  LogWarning("Draw target map nonempty on destruction.");
173  }
174 
175  mDTMap.RemoveAll();
176  }
177 
178  if (mILMap->HasElements())
179  {
181  {
182  LogWarning("Input layout map nonempty on destruction.");
183  }
184 
185  mILMap->UnbindAll();
186  }
187  mILMap = nullptr;
188 }
189 
190 uint64_t GL4Engine::DrawPrimitive(VertexBuffer const* vbuffer, IndexBuffer const* ibuffer)
191 {
192  unsigned int numActiveVertices = vbuffer->GetNumActiveElements();
193  unsigned int vertexOffset = vbuffer->GetOffset();
194 
195  unsigned int numActiveIndices = ibuffer->GetNumActiveIndices();
196  unsigned int indexSize = ibuffer->GetElementSize();
197  GLenum indexType = (indexSize == 4 ? GL_UNSIGNED_INT : GL_UNSIGNED_SHORT);
198 
199  GLenum topology = 0;
200  IPType type = ibuffer->GetPrimitiveType();
201  switch (type)
202  {
204  topology = GL_POINTS;
205  break;
207  topology = GL_LINES;
208  break;
210  topology = GL_LINE_STRIP;
211  break;
212  case IPType::IP_TRIMESH:
213  topology = GL_TRIANGLES;
214  break;
215  case IPType::IP_TRISTRIP:
216  topology = GL_TRIANGLE_STRIP;
217  break;
219  topology = GL_LINES_ADJACENCY;
220  break;
222  topology = GL_LINE_STRIP_ADJACENCY;
223  break;
225  topology = GL_TRIANGLES_ADJACENCY;
226  break;
228  topology = GL_TRIANGLE_STRIP_ADJACENCY;
229  break;
230  default:
231  LogError("Unknown primitive topology = " + std::to_string(type));
232  return 0;
233  }
234 
235  unsigned int offset = ibuffer->GetOffset();
236  if (ibuffer->IsIndexed())
237  {
238  void const* data = (char*)0 + indexSize * offset;
239  glDrawRangeElements(topology, 0, numActiveVertices - 1,
240  static_cast<GLsizei>(numActiveIndices), indexType, data);
241  }
242  else
243  {
244  // From the OpenGL documentation on gl_VertexID vertex shader variable:
245  // "gl_VertexID is a vertex language input variable that holds an integer index
246  // for the vertex. The index is impliclty generated by glDrawArrays and other
247  // commands that do not reference the content of the GL_ELEMENT_ARRAY_BUFFER,
248  // or explicitly generated from the content of the GL_ELEMENT_ARRAY_BUFFER
249  // by commands such as glDrawElements."
250  glDrawArrays(topology, static_cast<GLint>(vertexOffset),
251  static_cast<GLint>(numActiveVertices));
252  }
253  return 0;
254 }
255 
256 bool GL4Engine::EnableShaders(std::shared_ptr<VisualEffect> const& effect, GLuint program)
257 {
258  VertexShader* vshader = effect->GetVertexShader().get();
259  if (!vshader)
260  {
261  LogError("Effect does not have a vertex shader.");
262  return false;
263  }
264 
265  PixelShader* pshader = effect->GetPixelShader().get();
266  if (!pshader)
267  {
268  LogError("Effect does not have a pixel shader.");
269  return false;
270  }
271 
272  GeometryShader* gshader = effect->GetGeometryShader().get();
273 
274  // Enable the shader resources.
275  Enable(vshader, program);
276  Enable(pshader, program);
277  if (gshader)
278  {
279  Enable(gshader, program);
280  }
281 
282  return true;
283 }
284 
285 void GL4Engine::DisableShaders(std::shared_ptr<VisualEffect> const& effect, GLuint program)
286 {
287  VertexShader* vshader = effect->GetVertexShader().get();
288  PixelShader* pshader = effect->GetPixelShader().get();
289  GeometryShader* gshader = effect->GetGeometryShader().get();
290 
291  if (gshader)
292  {
293  Disable(gshader, program);
294  }
295  Disable(pshader, program);
296  Disable(vshader, program);
297 }
298 
300 {
301  EnableCBuffers(shader, program);
302  EnableTBuffers(shader, program);
303  EnableSBuffers(shader, program);
304  EnableRBuffers(shader, program);
305  EnableTextures(shader, program);
306  EnableTextureArrays(shader, program);
307  EnableSamplers(shader, program);
308 }
309 
311 {
312  DisableSamplers(shader, program);
313  DisableTextureArrays(shader, program);
314  DisableTextures(shader, program);
315  DisableRBuffers(shader, program);
316  DisableSBuffers(shader, program);
317  DisableTBuffers(shader, program);
318  DisableCBuffers(shader, program);
319 }
320 
322 {
324  for (auto const& cb : shader->GetData(index))
325  {
326  if (cb.object)
327  {
328  auto gl4CB = static_cast<GL4ConstantBuffer*>(Bind(cb.object));
329  if (gl4CB)
330  {
331  auto const blockIndex = cb.bindPoint;
332  if (GL_INVALID_INDEX != blockIndex)
333  {
334  auto const unit = mUniformUnitMap.AcquireUnit(program, blockIndex);
335  glUniformBlockBinding(program, blockIndex, unit);
336  gl4CB->AttachToUnit(unit);
337  }
338  }
339  else
340  {
341  LogError("Failed to bind constant buffer.");
342  }
343  }
344  else
345  {
346  LogError(cb.name + " is null constant buffer.");
347  }
348  }
349 }
350 
352 {
354  for (auto const& cb : shader->GetData(index))
355  {
356  auto const blockIndex = cb.bindPoint;
357  if (GL_INVALID_INDEX != blockIndex)
358  {
359  auto const unit = mUniformUnitMap.GetUnit(program, blockIndex);
362  }
363  }
364 }
365 
367 {
368  // TODO
369 }
370 
372 {
373  // TODO
374 }
375 
377 {
378  // Configure atomic counter buffer objects used by the shader.
379  auto const& atomicCounters = shader->GetData(Shader::AtomicCounterShaderDataLookup);
380  auto const& atomicCounterBuffers = shader->GetData(Shader::AtomicCounterBufferShaderDataLookup);
381  for (unsigned acbIndex = 0; acbIndex < atomicCounterBuffers.size(); ++acbIndex)
382  {
383  auto const& acb = atomicCounterBuffers[acbIndex];
384 
385  // Allocate a new raw buffer?
386  if (acbIndex >= mAtomicCounterRawBuffers.size())
387  {
388  mAtomicCounterRawBuffers.push_back(nullptr);
389  }
390 
391  // Look at the current raw buffer defined at this index.
392  // Could be nullptr if a new location was just inserted.
393  auto& rawBuffer = mAtomicCounterRawBuffers[acbIndex];
394 
395  // If the raw buffer is not large enough, then unbind old one and
396  // ready to create new one.
397  if (rawBuffer && (acb.numBytes > static_cast<int>(rawBuffer->GetNumBytes())))
398  {
399  Unbind(rawBuffer.get());
400  rawBuffer = nullptr;
401  }
402 
403  // Find the currently mapped GL4AtomicCounterBuffer.
404  GL4AtomicCounterBuffer* gl4ACB = nullptr;
405  if (rawBuffer)
406  {
407  gl4ACB = static_cast<GL4AtomicCounterBuffer*>(Get(rawBuffer));
408  }
409 
410  // Create a new buffer?
411  else
412  {
413  // By definition, RawBuffer contains 4-byte elements. Do not need
414  // CPU side storage but must be able to copy values between buffers.
415  rawBuffer = std::make_shared<RawBuffer>((acb.numBytes + 3) / 4, false);
416  rawBuffer->SetUsage(Resource::DYNAMIC_UPDATE);
417 
418  // Manual Bind operation since this is a special mapping from
419  // RawBuffer to GL4AtomicCounterBuffer.
420  auto temp = GL4AtomicCounterBuffer::Create(mGEObjectCreator, rawBuffer.get());
421  mGOMap.Insert(rawBuffer.get(), temp);
422  gl4ACB = static_cast<GL4AtomicCounterBuffer*>(temp.get());
423  }
424 
425  // TODO:
426  // ShaderStorage blocks have a glShaderStorageBlockBinding() call
427  // Uniform blocks have glUniforBlockBinding() call
428  // Is there something equivalent for atomic counters buffers?
429 
430  // Bind this atomic counter buffer
431  gl4ACB->AttachToUnit(acb.bindPoint);
432  }
433 
434  int const indexSB = StructuredBuffer::shaderDataLookup;
435  for (auto const& sb : shader->GetData(indexSB))
436  {
437  if (sb.object)
438  {
439  auto gl4SB = static_cast<GL4StructuredBuffer*>(Bind(sb.object));
440  if (gl4SB)
441  {
442  auto const blockIndex = sb.bindPoint;
443  if (GL_INVALID_INDEX != blockIndex)
444  {
445  auto const unit = mShaderStorageUnitMap.AcquireUnit(program, blockIndex);
446  glShaderStorageBlockBinding(program, blockIndex, unit);
447 
448  // Do not use glBindBufferBase here. Use AttachToUnit
449  // method in GL4StructuredBuffer.
450  gl4SB->AttachToUnit(unit);
451 
452  // The sb.isGpuWritable flag is used to indicate whether
453  // or not there is atomic counter associated with this
454  // structured buffer.
455  if (sb.isGpuWritable)
456  {
457  // Does the structured buffer counter need to be reset?
458  gl4SB->SetNumActiveElements();
459 
460  // This structured buffer has index to associated
461  // atomic counter table entry.
462  auto const acIndex = sb.extra;
463 
464  // Where does the associated counter exist in the shader?
465  auto const acbIndex = atomicCounters[acIndex].bindPoint;
466  auto const acbOffset = atomicCounters[acIndex].extra;
467 
468  // Retrieve the GL4 atomic counter buffer object.
469  auto gl4ACB = static_cast<GL4AtomicCounterBuffer*>(Get(mAtomicCounterRawBuffers[acbIndex]));
470 
471  // Copy the counter value from the structured buffer object
472  // to the appropriate place in the atomic counter buffer.
473  gl4SB->CopyCounterValueToBuffer(gl4ACB, acbOffset);
474  }
475  }
476  }
477  else
478  {
479  LogError("Failed to bind structured buffer.");
480  }
481  }
482  else
483  {
484  LogError(sb.name + " is null structured buffer.");
485  }
486  }
487 }
488 
490 {
491  // Unbind any atomic counter buffers.
492  auto const& atomicCounters = shader->GetData(Shader::AtomicCounterShaderDataLookup);
493  auto const& atomicCounterBuffers = shader->GetData(Shader::AtomicCounterBufferShaderDataLookup);
494  for (unsigned acbIndex = 0; acbIndex < atomicCounterBuffers.size(); ++acbIndex)
495  {
496  auto const& acb = atomicCounterBuffers[acbIndex];
497  glBindBufferBase(GL_ATOMIC_COUNTER_BUFFER, acb.bindPoint, 0);
498  }
499 
501  for (auto const& sb : shader->GetData(index))
502  {
503  if (sb.object)
504  {
505  auto gl4SB = static_cast<GL4StructuredBuffer*>(Get(sb.object));
506 
507  if (gl4SB)
508  {
509  auto const blockIndex = sb.bindPoint;
510  if (GL_INVALID_INDEX != blockIndex)
511  {
512  auto const unit = mShaderStorageUnitMap.GetUnit(program, blockIndex);
515 
516  // The sb.isGpuWritable flag is used to indicate whether
517  // or not there is atomic counter associated with this
518  // structured buffer.
519  if (sb.isGpuWritable)
520  {
521  // This structured buffer has index to associated
522  // atomic counter table entry.
523  auto const acIndex = sb.extra;
524 
525  // Where does the associated counter exist in the shader?
526  auto const acbIndex = atomicCounters[acIndex].bindPoint;
527  auto const acbOffset = atomicCounters[acIndex].extra;
528 
529  // Retrieve the GL4 atomic counter buffer object.
530  auto gl4ACB = static_cast<GL4AtomicCounterBuffer*>(Get(mAtomicCounterRawBuffers[acbIndex]));
531 
532  // Copy the counter value from the appropriate place
533  // in the atomic counter buffer to the structured buffer
534  // object.
535  gl4SB->CopyCounterValueFromBuffer(gl4ACB, acbOffset);
536  }
537  }
538  }
539  }
540  }
541 }
542 
544 {
545  // TODO
546 }
547 
549 {
550  // TODO
551 }
552 
554 {
556  for (auto const& ts : shader->GetData(index))
557  {
558  if (!ts.object)
559  {
560  LogError(ts.name + " is null texture.");
561  continue;
562  }
563 
564  auto texture = static_cast<GL4TextureSingle*>(Bind(ts.object));
565  if (!texture)
566  {
567  LogError("Failed to bind texture.");
568  continue;
569  }
570 
571  // By convension, ts.isGpuWritable is true for "image*" and false
572  // for "sampler*".
573  GLuint handle = texture->GetGLHandle();
574  if (ts.isGpuWritable)
575  {
576  // For "image*" objects in the shader, use "readonly" or
577  // "writeonly" attributes in the layout to control R/W/RW access
578  // using shader compiler and then connect as GL_READ_WRITE here.
579  // Always bind level 0 and all layers.
580  GLint unit = mTextureImageUnitMap.AcquireUnit(program, ts.bindPoint);
581  glUniform1i(ts.bindPoint, unit);
582  DFType format = texture->GetTexture()->GetFormat();
583  GLuint internalFormat = texture->GetInternalFormat(format);
584  glBindImageTexture(unit, handle, 0, GL_TRUE, 0, GL_READ_WRITE, internalFormat);
585  }
586  else
587  {
588  GLint unit = mTextureSamplerUnitMap.AcquireUnit(program, ts.bindPoint);
589  glUniform1i(ts.bindPoint, unit);
591  glBindTexture(texture->GetTarget(), handle);
592  }
593  }
594 }
595 
597 {
599  for (auto const& ts : shader->GetData(index))
600  {
601  if (!ts.object)
602  {
603  LogError(ts.name + " is null texture.");
604  continue;
605  }
606 
607  auto texture = static_cast<GL4TextureSingle*>(Get(ts.object));
608  if (!texture)
609  {
610  LogError("Failed to get texture.");
611  continue;
612  }
613 
614  // By convension, ts.isGpuWritable is true for "image*" and false
615  // for "sampler*".
616  if (ts.isGpuWritable)
617  {
618  // For "image*" objects in the shader, use "readonly" or
619  // "writeonly" attributes in the layout to control R/W/RW access
620  // using shader compiler and then connect as GL_READ_WRITE here.
621  // Always bind level 0 and all layers. TODO: Decide if unbinding
622  // the texture from the image unit is necessary.
623  // glBindImageTexture(unit, 0, 0, 0, 0, 0, 0);
624  GLint unit = mTextureImageUnitMap.GetUnit(program, ts.bindPoint);
626  }
627  else
628  {
629  GLint unit = mTextureSamplerUnitMap.GetUnit(program, ts.bindPoint);
631  glBindTexture(texture->GetTarget(), 0);
633  }
634  }
635 }
636 
638 {
640  for (auto const& ta : shader->GetData(index))
641  {
642  if (!ta.object)
643  {
644  LogError(ta.name + " is null texture array.");
645  continue;
646  }
647 
648  auto texture = static_cast<GL4TextureArray*>(Bind(ta.object));
649  if (!texture)
650  {
651  LogError("Failed to bind texture array.");
652  continue;
653  }
654 
655  // By convension, ta.isGpuWritable is true for "image*" and false
656  // for "sampler*".
657  GLuint handle = texture->GetGLHandle();
658  if (ta.isGpuWritable)
659  {
660  // For "image*" objects in the shader, use "readonly" or
661  // "writeonly" attributes in the layout to control R/W/RW access
662  // using shader compiler and then connect as GL_READ_WRITE here.
663  // Always bind level 0 and all layers.
664  GLint unit = mTextureImageUnitMap.AcquireUnit(program, ta.bindPoint);
665  glUniform1i(ta.bindPoint, unit);
666  DFType format = texture->GetTexture()->GetFormat();
667  GLuint internalFormat = texture->GetInternalFormat(format);
668  glBindImageTexture(unit, handle, 0, GL_TRUE, 0, GL_READ_WRITE, internalFormat);
669  }
670  else
671  {
672  GLint unit = mTextureSamplerUnitMap.AcquireUnit(program, ta.bindPoint);
673  glUniform1i(ta.bindPoint, unit);
675  glBindTexture(texture->GetTarget(), handle);
676  }
677  }
678 }
679 
681 {
683  for (auto const& ta : shader->GetData(index))
684  {
685  if (!ta.object)
686  {
687  LogError(ta.name + " is null texture array.");
688  continue;
689  }
690 
691  auto texture = static_cast<GL4TextureArray*>(Get(ta.object));
692  if (!texture)
693  {
694  LogError("Failed to get texture array.");
695  continue;
696  }
697 
698  // By convension, ta.isGpuWritable is true for "image*" and false
699  // for "sampler*".
700  if (ta.isGpuWritable)
701  {
702  // For "image*" objects in the shader, use "readonly" or
703  // "writeonly" attributes in the layout to control R/W/RW access
704  // using shader compiler and then connect as GL_READ_WRITE here.
705  // Always bind level 0 and all layers. TODO: Decide if unbinding
706  // the texture from the image unit is necessary.
707  // glBindImageTexture(unit, 0, 0, 0, 0, 0, 0);
708  GLint unit = mTextureImageUnitMap.GetUnit(program, ta.bindPoint);
710  }
711  else
712  {
713  GLint unit = mTextureSamplerUnitMap.GetUnit(program, ta.bindPoint);
715  glBindTexture(texture->GetTarget(), 0);
717  }
718  }
719 }
720 
722 {
724  for (auto const& ts : shader->GetData(index))
725  {
726  if (ts.object)
727  {
728  auto gl4Sampler = static_cast<GL4SamplerState*>(Bind(ts.object));
729  if (gl4Sampler)
730  {
731  auto const location = ts.bindPoint;
732  auto const unit = mTextureSamplerUnitMap.AcquireUnit(program, location);
733  glBindSampler(unit, gl4Sampler->GetGLHandle());
734  }
735  else
736  {
737  LogError("Failed to bind sampler.");
738  }
739  }
740  else
741  {
742  LogError(ts.name + " is null sampler.");
743  }
744  }
745 }
746 
748 {
750  for (auto const& ts : shader->GetData(index))
751  {
752  if (ts.object)
753  {
754  auto gl4Sampler = static_cast<GL4SamplerState*>(Get(ts.object));
755 
756  if (gl4Sampler)
757  {
758  auto const location = ts.bindPoint;
759  auto const unit = mTextureSamplerUnitMap.GetUnit(program, location);
760  glBindSampler(unit, 0);
762  }
763  else
764  {
765  LogError("Failed to get sampler.");
766  }
767  }
768  else
769  {
770  LogError(ts.name + " is null sampler.");
771  }
772  }
773 }
774 
776 {
777 }
778 
780 {
781 }
782 
784 {
785  int availUnit = -1;
786  for (int unit = 0; unit < static_cast<int>(mLinkMap.size()); ++unit)
787  {
788  auto& item = mLinkMap[unit];
789 
790  // Increment link count if already assigned and in use?
791  if (program == item.program && index == item.index)
792  {
793  ++item.linkCount;
794  return unit;
795  }
796 
797  // Found a unit that was previously used but is now avaialble.
798  if (0 == item.linkCount)
799  {
800  if (-1 == availUnit)
801  {
802  availUnit = unit;
803  }
804  }
805  }
806 
807  // New unit number not previously used?
808  if (-1 == availUnit)
809  {
810  // TODO: Consider querying the max number of units
811  // and check that this number is not exceeded.
812  availUnit = static_cast<int>(mLinkMap.size());
813  mLinkMap.push_back({ 0, 0, 0 });
814  }
815 
816  auto& item = mLinkMap[availUnit];
817  item.linkCount = 1;
818  item.program = program;
819  item.index = index;
820  return availUnit;
821 }
822 
824 {
825  for (int unit = 0; unit < static_cast<int>(mLinkMap.size()); ++unit)
826  {
827  auto& item = mLinkMap[unit];
828  if (program == item.program && index == item.index)
829  {
830  return unit;
831  }
832  }
833  return -1;
834 }
835 
837 {
838  if (index < mLinkMap.size())
839  {
840  auto& item = mLinkMap[index];
841  if (item.linkCount > 0)
842  {
843  --item.linkCount;
844  }
845  }
846 }
847 
849 {
850  if (unit < mLinkMap.size())
851  {
852  return mLinkMap[unit].linkCount;
853  }
854  return 0;
855 }
856 
858 {
859  if (unit < mLinkMap.size())
860  {
861  auto& item = mLinkMap[index];
862  if (item.linkCount > 0)
863  {
864  program = item.program;
865  index = item.index;
866  return true;
867  }
868  }
869  return false;
870 }
871 
872 //----------------------------------------------------------------------------
873 // Overrides from GraphicsEngine
874 //----------------------------------------------------------------------------
875 void GL4Engine::SetViewport(int x, int y, int w, int h)
876 {
877  glViewport(x, y, w, h);
878 }
879 
880 void GL4Engine::GetViewport(int& x, int& y, int& w, int& h) const
881 {
882  int param[4];
883  glGetIntegerv(GL_VIEWPORT, param);
884  x = param[0];
885  y = param[1];
886  w = param[2];
887  h = param[3];
888 }
889 
890 void GL4Engine::SetDepthRange(float zmin, float zmax)
891 {
892  glDepthRange(static_cast<GLdouble>(zmin), static_cast<GLdouble>(zmax));
893 }
894 
895 void GL4Engine::GetDepthRange(float& zmin, float& zmax) const
896 {
897  GLdouble param[2];
899  zmin = static_cast<float>(param[0]);
900  zmax = static_cast<float>(param[1]);
901 }
902 
903 bool GL4Engine::Resize(unsigned int w, unsigned int h)
904 {
905  mXSize = w;
906  mYSize = h;
907  int param[4];
908  glGetIntegerv(GL_VIEWPORT, param);
909  glViewport(param[0], param[1], static_cast<GLint>(w), static_cast<GLint>(h));
910  return true;
911 }
912 
914 {
917 }
918 
920 {
923 }
924 
926 {
927  glClearStencil(static_cast<GLint>(mClearStencil));
929 }
930 
932 {
935  glClearStencil(static_cast<GLint>(mClearStencil));
937 }
938 
939 void GL4Engine::SetBlendState(std::shared_ptr<BlendState> const& state)
940 {
941  if (state)
942  {
943  if (state != mActiveBlendState)
944  {
945  GL4BlendState* gl4State = static_cast<GL4BlendState*>(Bind(state));
946  if (gl4State)
947  {
948  gl4State->Enable();
949  mActiveBlendState = state;
950  }
951  else
952  {
953  LogError("Failed to bind blend state.");
954  }
955  }
956  }
957  else
958  {
959  LogError("Input state is null.");
960  }
961 }
962 
963 void GL4Engine::SetDepthStencilState(std::shared_ptr<DepthStencilState> const& state)
964 {
965  if (state)
966  {
967  if (state != mActiveDepthStencilState)
968  {
969  GL4DepthStencilState* gl4State = static_cast<GL4DepthStencilState*>(Bind(state));
970  if (gl4State)
971  {
972  gl4State->Enable();
973  mActiveDepthStencilState = state;
974  }
975  else
976  {
977  LogError("Failed to bind depth-stencil state.");
978  }
979  }
980  }
981  else
982  {
983  LogError("Input state is null.");
984  }
985 }
986 
987 void GL4Engine::SetRasterizerState(std::shared_ptr<RasterizerState> const& state)
988 {
989  if (state)
990  {
991  if (state != mActiveRasterizerState)
992  {
993  GL4RasterizerState* gl4State = static_cast<GL4RasterizerState*>(Bind(state));
994  if (gl4State)
995  {
996  gl4State->Enable();
997  mActiveRasterizerState = state;
998  }
999  else
1000  {
1001  LogError("Failed to bind rasterizer state.");
1002  }
1003  }
1004  }
1005  else
1006  {
1007  LogError("Input state is null.");
1008  }
1009 }
1010 
1011 void GL4Engine::Enable(std::shared_ptr<DrawTarget> const& target)
1012 {
1013  auto gl4Target = static_cast<GL4DrawTarget*>(Bind(target));
1014  gl4Target->Enable();
1015 }
1016 
1017 void GL4Engine::Disable(std::shared_ptr<DrawTarget> const& target)
1018 {
1019  auto gl4Target = static_cast<GL4DrawTarget*>(Get(target));
1020  if (gl4Target)
1021  {
1022  gl4Target->Disable();
1023  }
1024 }
1025 
1026 bool GL4Engine::Update(std::shared_ptr<Buffer> const& buffer)
1027 {
1028  if (!buffer->GetData())
1029  {
1030  LogWarning("Buffer does not have system memory, creating it.");
1031  buffer->CreateStorage();
1032  }
1033 
1034  auto glBuffer = static_cast<GL4Buffer*>(Bind(buffer));
1035  return glBuffer->Update();
1036 }
1037 
1038 bool GL4Engine::Update(std::shared_ptr<TextureSingle> const& texture)
1039 {
1040  if (!texture->GetData())
1041  {
1042  LogWarning("Texture does not have system memory, creating it.");
1043  texture->CreateStorage();
1044  }
1045 
1046  auto glTexture = static_cast<GL4TextureSingle*>(Bind(texture));
1047  return glTexture->Update();
1048 }
1049 
1050 bool GL4Engine::Update(std::shared_ptr<TextureSingle> const& texture, unsigned int level)
1051 {
1052  if (!texture->GetData())
1053  {
1054  LogWarning("Texture does not have system memory, creating it.");
1055  texture->CreateStorage();
1056  }
1057 
1058  auto glTexture = static_cast<GL4TextureSingle*>(Bind(texture));
1059  return glTexture->Update(level);
1060 }
1061 
1062 bool GL4Engine::Update(std::shared_ptr<TextureArray> const& textureArray)
1063 {
1064  if (!textureArray->GetData())
1065  {
1066  LogWarning("Texture array does not have system memory, creating it.");
1067  textureArray->CreateStorage();
1068  }
1069 
1070  auto glTextureArray = static_cast<GL4TextureArray*>(Bind(textureArray));
1071  return glTextureArray->Update();
1072 }
1073 
1074 bool GL4Engine::Update(std::shared_ptr<TextureArray> const& textureArray, unsigned int item, unsigned int level)
1075 {
1076  if (!textureArray->GetData())
1077  {
1078  LogWarning("Texture array does not have system memory, creating it.");
1079  textureArray->CreateStorage();
1080  }
1081 
1082  auto glTextureArray = static_cast<GL4TextureArray*>(Bind(textureArray));
1083  return glTextureArray->Update(item, level);
1084 }
1085 
1086 bool GL4Engine::CopyCpuToGpu(std::shared_ptr<Buffer> const& buffer)
1087 {
1088  if (!buffer->GetData())
1089  {
1090  LogWarning("Buffer does not have system memory, creating it.");
1091  buffer->CreateStorage();
1092  }
1093 
1094  auto glBuffer = static_cast<GL4Buffer*>(Bind(buffer));
1095  return glBuffer->CopyCpuToGpu();
1096 }
1097 
1098 bool GL4Engine::CopyCpuToGpu(std::shared_ptr<TextureSingle> const& texture)
1099 {
1100  if (!texture->GetData())
1101  {
1102  LogWarning("Texture does not have system memory, creating it.");
1103  texture->CreateStorage();
1104  }
1105 
1106  auto glTexture = static_cast<GL4TextureSingle*>(Bind(texture));
1107  return glTexture->CopyCpuToGpu();
1108 }
1109 
1110 bool GL4Engine::CopyCpuToGpu(std::shared_ptr<TextureSingle> const& texture, unsigned int level)
1111 {
1112  if (!texture->GetData())
1113  {
1114  LogWarning("Texture does not have system memory, creating it.");
1115  texture->CreateStorage();
1116  }
1117 
1118  auto glTexture = static_cast<GL4TextureSingle*>(Bind(texture));
1119  return glTexture->CopyCpuToGpu(level);
1120 }
1121 
1122 bool GL4Engine::CopyCpuToGpu(std::shared_ptr<TextureArray> const& textureArray)
1123 {
1124  if (!textureArray->GetData())
1125  {
1126  LogWarning("Texture array does not have system memory, creating it.");
1127  textureArray->CreateStorage();
1128  }
1129 
1130  auto glTextureArray = static_cast<GL4TextureArray*>(Bind(textureArray));
1131  return glTextureArray->CopyCpuToGpu();
1132 }
1133 
1134 bool GL4Engine::CopyCpuToGpu(std::shared_ptr<TextureArray> const& textureArray, unsigned int item, unsigned int level)
1135 {
1136  if (!textureArray->GetData())
1137  {
1138  LogWarning("Texture array does not have system memory, creating it.");
1139  textureArray->CreateStorage();
1140  }
1141 
1142  auto glTextureArray = static_cast<GL4TextureArray*>(Bind(textureArray));
1143  return glTextureArray->CopyCpuToGpu(item, level);
1144 }
1145 
1146 bool GL4Engine::CopyGpuToCpu(std::shared_ptr<Buffer> const& buffer)
1147 {
1148  if (!buffer->GetData())
1149  {
1150  LogWarning("Buffer does not have system memory, creating it.");
1151  buffer->CreateStorage();
1152  }
1153 
1154  auto glBuffer = static_cast<GL4Buffer*>(Bind(buffer));
1155  return glBuffer->CopyGpuToCpu();
1156 }
1157 
1158 bool GL4Engine::CopyGpuToCpu(std::shared_ptr<TextureSingle> const& texture)
1159 {
1160  if (!texture->GetData())
1161  {
1162  LogWarning("Texture does not have system memory, creating it.");
1163  texture->CreateStorage();
1164  }
1165 
1166  auto glTexture = static_cast<GL4TextureSingle*>(Bind(texture));
1167  return glTexture->CopyGpuToCpu();
1168 }
1169 
1170 bool GL4Engine::CopyGpuToCpu(std::shared_ptr<TextureSingle> const& texture, unsigned int level)
1171 {
1172  if (!texture->GetData())
1173  {
1174  LogWarning("Texture does not have system memory, creating it.");
1175  texture->CreateStorage();
1176  }
1177 
1178  auto glTexture = static_cast<GL4TextureSingle*>(Bind(texture));
1179  return glTexture->CopyGpuToCpu(level);
1180 }
1181 
1182 bool GL4Engine::CopyGpuToCpu(std::shared_ptr<TextureArray> const& textureArray)
1183 {
1184  if (!textureArray->GetData())
1185  {
1186  LogWarning("Texture array does not have system memory, creating it.");
1187  textureArray->CreateStorage();
1188  }
1189 
1190  auto glTextureArray = static_cast<GL4TextureArray*>(Bind(textureArray));
1191  return glTextureArray->CopyGpuToCpu();
1192 }
1193 
1194 bool GL4Engine::CopyGpuToCpu(std::shared_ptr<TextureArray> const& textureArray, unsigned int item, unsigned int level)
1195 {
1196  if (!textureArray->GetData())
1197  {
1198  LogWarning("Texture array does not have system memory, creating it.");
1199  textureArray->CreateStorage();
1200  }
1201 
1202  auto glTextureArray = static_cast<GL4TextureArray*>(Bind(textureArray));
1203  return glTextureArray->CopyGpuToCpu(item, level);
1204 }
1205 
1207  std::shared_ptr<Buffer> const& buffer0,
1208  std::shared_ptr<Buffer> const& buffer1)
1209 {
1210  (void)buffer0;
1211  (void)buffer1;
1212  LogError("Not yet implemented.");
1213 }
1214 
1216  std::shared_ptr<TextureSingle> const& texture0,
1217  std::shared_ptr<TextureSingle> const& texture1)
1218 {
1219  (void)texture0;
1220  (void)texture1;
1221  LogError("Not yet implemented.");
1222 }
1223 
1225  std::shared_ptr<TextureSingle> const& texture0,
1226  std::shared_ptr<TextureSingle> const& texture1,
1227  unsigned int level)
1228 {
1229  (void)texture0;
1230  (void)texture1;
1231  (void)level;
1232  LogError("Not yet implemented.");
1233 }
1234 
1236  std::shared_ptr<TextureArray> const& textureArray0,
1237  std::shared_ptr<TextureArray> const& textureArray1)
1238 {
1239  (void)textureArray0;
1240  (void)textureArray1;
1241  LogError("Not yet implemented.");
1242 }
1243 
1245  std::shared_ptr<TextureArray> const& textureArray0,
1246  std::shared_ptr<TextureArray> const& textureArray1,
1247  unsigned int item, unsigned int level)
1248 {
1249  (void)textureArray0;
1250  (void)textureArray1;
1251  (void)item;
1252  (void)level;
1253  LogError("Not yet implemented.");
1254 }
1255 
1256 bool GL4Engine::GetNumActiveElements(std::shared_ptr<StructuredBuffer> const& buffer)
1257 {
1258  auto gl4Object = Get(buffer);
1259  if (gl4Object)
1260  {
1261  auto gl4SBuffer = static_cast<GL4StructuredBuffer*>(gl4Object);
1262  return gl4SBuffer->GetNumActiveElements();
1263  }
1264  return false;
1265 }
1266 
1267 bool GL4Engine::BindProgram(std::shared_ptr<ComputeProgram> const&)
1268 {
1269  // TODO: Why are we not adding the compute shader to the mGOMap?
1270  return true;
1271 }
1272 
1273 void GL4Engine::Execute(std::shared_ptr<ComputeProgram> const& program,
1274  unsigned int numXGroups, unsigned int numYGroups, unsigned int numZGroups)
1275 {
1276  auto glslProgram = std::dynamic_pointer_cast<GLSLComputeProgram>(program);
1277  if (glslProgram && numXGroups > 0 && numYGroups > 0 && numZGroups > 0)
1278  {
1279  auto cshader = glslProgram->GetCShader();
1280  auto programHandle = glslProgram->GetProgramHandle();
1281  if (cshader && programHandle > 0)
1282  {
1283  glUseProgram(programHandle);
1284  Enable(cshader.get(), programHandle);
1285  glDispatchCompute(numXGroups, numYGroups, numZGroups);
1286  Disable(cshader.get(), programHandle);
1287  glUseProgram(0);
1288  }
1289  }
1290  else
1291  {
1292  LogError("Invalid input parameter.");
1293  }
1294 }
1295 
1297 {
1298  // TODO. Determine whether OpenGL can wait for a compute program to finish.
1299 }
1300 
1302 {
1303  glFlush();
1304 }
1305 
1306 uint64_t GL4Engine::DrawPrimitive(std::shared_ptr<VertexBuffer> const& vbuffer,
1307  std::shared_ptr<IndexBuffer> const& ibuffer, std::shared_ptr<VisualEffect> const& effect)
1308 {
1309  GLSLVisualProgram* gl4program = dynamic_cast<GLSLVisualProgram*>(effect->GetProgram().get());
1310  if (!gl4program)
1311  {
1312  LogError("HLSL effect passed to GLSL engine.");
1313  return 0;
1314  }
1315 
1316  uint64_t numPixelsDrawn = 0;
1317  auto programHandle = gl4program->GetProgramHandle();
1318  glUseProgram(programHandle);
1319 
1320  if (EnableShaders(effect, programHandle))
1321  {
1322  // Enable the vertex buffer and input layout.
1323  GL4VertexBuffer* gl4VBuffer = nullptr;
1324  GL4InputLayout* gl4Layout = nullptr;
1325  if (vbuffer->StandardUsage())
1326  {
1327  gl4VBuffer = static_cast<GL4VertexBuffer*>(Bind(vbuffer));
1328  GL4InputLayoutManager* manager = static_cast<GL4InputLayoutManager*>(mILMap.get());
1329  gl4Layout = manager->Bind(programHandle, gl4VBuffer->GetGLHandle(), vbuffer.get());
1330  gl4Layout->Enable();
1331  }
1332 
1333  // Enable the index buffer.
1334  GL4IndexBuffer* gl4IBuffer = nullptr;
1335  if (ibuffer->IsIndexed())
1336  {
1337  gl4IBuffer = static_cast<GL4IndexBuffer*>(Bind(ibuffer));
1338  gl4IBuffer->Enable();
1339  }
1340 
1341  numPixelsDrawn = DrawPrimitive(vbuffer.get(), ibuffer.get());
1342 
1343  // Disable the vertex buffer and input layout.
1344  if (vbuffer->StandardUsage())
1345  {
1346  gl4Layout->Disable();
1347  }
1348 
1349  // Disable the index buffer.
1350  if (gl4IBuffer)
1351  {
1352  gl4IBuffer->Disable();
1353  }
1354 
1355  DisableShaders(effect, programHandle);
1356  }
1357 
1358  glUseProgram(0);
1359 
1360  return numPixelsDrawn;
1361 }
virtual bool Update(std::shared_ptr< Buffer > const &buffer) override
static std::shared_ptr< GEObject > Create(void *unused, GraphicsObject const *object)
ThreadSafeMap< GraphicsObject const *, std::shared_ptr< GEObject > > mGOMap
std::shared_ptr< Font > mActiveFont
DYNAMIC_UPDATE
Definition: GteResource.h:42
static std::shared_ptr< GEObject > Create(void *unused, GraphicsObject const *object)
static int const shaderDataLookup
virtual void GetViewport(int &x, int &y, int &w, int &h) const override
ProgramIndexUnitMap mUniformUnitMap
Definition: GteGL4Engine.h:113
GLint location
Definition: glcorearb.h:800
GLenum GLfloat param
Definition: glcorearb.h:99
std::array< CreateGEObject, GT_NUM_TYPES > mCreateGEObject
virtual void ClearColorBuffer() override
#define GL_LINE_STRIP_ADJACENCY
Definition: glcorearb.h:1525
std::shared_ptr< RasterizerState > mActiveRasterizerState
int GLint
Definition: glcorearb.h:85
static std::shared_ptr< GEObject > Create(void *unused, GraphicsObject const *object)
unsigned int GLuint
Definition: glcorearb.h:89
void APIENTRY glDrawArrays(GLenum mode, GLint first, GLsizei count)
Definition: GteOpenGL.cpp:837
virtual bool Resize(unsigned int w, unsigned int h) override
std::shared_ptr< BlendState > mActiveBlendState
void EnableTextures(Shader const *shader, GLuint program)
#define GL_TRIANGLE_STRIP
Definition: glcorearb.h:206
void EnableCBuffers(Shader const *shader, GLuint program)
IP_TRISTRIP_ADJ
void APIENTRY glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
Definition: GteOpenGL.cpp:755
CreateGEDrawTarget mCreateGEDrawTarget
void EnableSBuffers(Shader const *shader, GLuint program)
void DisableShaders(std::shared_ptr< VisualEffect > const &effect, GLuint program)
bool mMeetsRequirements
Definition: GteGL4Engine.h:50
virtual bool CopyCpuToGpu() override
void APIENTRY glDepthRange(GLdouble near, GLdouble far)
Definition: GteOpenGL.cpp:742
virtual ~GL4Engine()
IP_TRIMESH
static int const shaderDataLookup
#define GL_TEXTURE0
Definition: glcorearb.h:484
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
#define GL_UNIFORM_BUFFER
Definition: glcorearb.h:1419
unsigned int GetOffset() const
Definition: GteResource.h:173
void CreateDefaultFont()
static std::shared_ptr< GEDrawTarget > Create(DrawTarget const *target, std::vector< GEObject * > &rtTextures, GEObject *dsTexture)
#define GL_SHADER_STORAGE_BUFFER
Definition: glcorearb.h:2468
virtual void ClearDepthBuffer() override
virtual void SetDepthStencilState(std::shared_ptr< DepthStencilState > const &state) override
void DisableTextures(Shader const *shader, GLuint program)
GLint level
Definition: glcorearb.h:103
IP_TRIMESH_ADJ
virtual void CopyGpuToGpu(std::shared_ptr< Buffer > const &buffer0, std::shared_ptr< Buffer > const &buffer1) override
static std::shared_ptr< GEObject > Create(void *unused, GraphicsObject const *object)
ProgramIndexUnitMap mShaderStorageUnitMap
Definition: GteGL4Engine.h:114
void Disable(Shader const *shader, GLuint program)
#define GL_COLOR_BUFFER_BIT
Definition: glcorearb.h:198
GEObject * Get(std::shared_ptr< GraphicsObject > const &object) const
GLbitfield GLuint program
Definition: glcorearb.h:1926
unsigned int mXSize
Definition: GteBaseEngine.h:95
#define GL_VIEWPORT
Definition: glcorearb.h:271
std::unique_ptr< GEInputLayoutManager > mILMap
virtual void WaitForFinish() override
void APIENTRY glShaderStorageBlockBinding(GLuint program, GLuint storageBlockIndex, GLuint storageBlockBinding)
Definition: GteOpenGL.cpp:8038
void APIENTRY glDispatchCompute(GLuint num_groups_x, GLuint num_groups_y, GLuint num_groups_z)
Definition: GteOpenGL.cpp:7769
ProgramIndexUnitMap mTextureImageUnitMap
Definition: GteGL4Engine.h:112
#define GL_LINE_STRIP
Definition: glcorearb.h:204
static int const shaderDataLookup
IP_POLYSEGMENT_CONTIGUOUS_ADJ
GLenum target
Definition: glcorearb.h:1662
static std::shared_ptr< GEObject > Create(void *unused, GraphicsObject const *object)
GLint GLenum GLint x
Definition: glcorearb.h:404
static int const shaderDataLookup
static std::shared_ptr< GEObject > Create(void *unused, GraphicsObject const *object)
std::shared_ptr< GOListener > mGOListener
bool Unbind(std::shared_ptr< GraphicsObject > const &object)
void DisableRBuffers(Shader const *shader, GLuint program)
void APIENTRY glBindSampler(GLuint unit, GLuint sampler)
Definition: GteOpenGL.cpp:5128
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:852
void Enable(Shader const *shader, GLuint program)
static std::shared_ptr< GEObject > Create(void *unused, GraphicsObject const *object)
IP_POLYSEGMENT_CONTIGUOUS
void APIENTRY glBindTexture(GLenum target, GLuint texture)
Definition: GteOpenGL.cpp:967
void DisableTBuffers(Shader const *shader, GLuint program)
void DestroyDefaultFont()
virtual void DestroyDefaultGlobalState()
virtual bool GetNumActiveElements(std::shared_ptr< StructuredBuffer > const &buffer) override
std::array< float, 4 > mClearColor
Definition: GteBaseEngine.h:98
virtual void Flush() override
unsigned int mClearStencil
void EnableSamplers(Shader const *shader, GLuint program)
virtual bool CopyCpuToGpu(std::shared_ptr< Buffer > const &buffer) override
virtual bool CopyGpuToCpu() override
unsigned int GetElementSize() const
Definition: GteResource.h:111
virtual void Execute(std::shared_ptr< ComputeProgram > const &program, unsigned int numXGroups, unsigned int numYGroups, unsigned int numZGroups) override
static std::shared_ptr< GEObject > Create(void *unused, GraphicsObject const *object)
virtual bool CopyGpuToCpu(std::shared_ptr< Buffer > const &buffer) override
#define GL_LINES
Definition: glcorearb.h:202
virtual bool CopyCpuToGpu()
void APIENTRY glUniform1i(GLint location, GLint v0)
Definition: GteOpenGL.cpp:2346
virtual bool CopyGpuToCpu() override
static std::shared_ptr< GEObject > Create(void *unused, GraphicsObject const *object)
void APIENTRY glUseProgram(GLuint program)
Definition: GteOpenGL.cpp:2281
static std::shared_ptr< GEObject > Create(void *unused, GraphicsObject const *object)
GLenum internalFormat
Definition: glext.h:5432
unsigned int GLenum
Definition: glcorearb.h:83
virtual bool BindProgram(std::shared_ptr< ComputeProgram > const &program) override
void CreateDefaultGlobalState()
GLsizei const GLchar *const * string
Definition: glcorearb.h:809
bool GetUnitProgramIndex(unsigned unit, GLint &program, GLint &index) const
GLuint GetProgramHandle() const
#define LogError(message)
Definition: GteLogger.h:92
ProgramIndexUnitMap mTextureSamplerUnitMap
Definition: GteGL4Engine.h:111
#define GL_POINTS
Definition: glcorearb.h:201
IP_POLYSEGMENT_DISJOINT_ADJ
void EnableRBuffers(Shader const *shader, GLuint program)
GLboolean * data
Definition: glcorearb.h:126
static std::shared_ptr< GEObject > Create(void *unused, GraphicsObject const *object)
IP_POLYSEGMENT_DISJOINT
GLuint texture
Definition: glcorearb.h:410
virtual bool Initialize(int requiredMajor, int requiredMinor, bool saveDriverInfo)
#define GL_TRIANGLES_ADJACENCY
Definition: glcorearb.h:1526
static void UnsubscribeForDestruction(std::shared_ptr< ListenerForDestruction > const &listener)
ThreadSafeMap< DrawTarget const *, std::shared_ptr< GEDrawTarget > > mDTMap
GLuint GLsizei const GLchar * message
Definition: glcorearb.h:2538
virtual bool Update() override
std::shared_ptr< DepthStencilState > mActiveDepthStencilState
#define LogWarning(message)
Definition: GteLogger.h:95
void InitializeOpenGL(int &major, int &minor, char const *infofile)
void APIENTRY glActiveTexture(GLenum texture)
Definition: GteOpenGL.cpp:1127
IPType GetPrimitiveType() const
GLclampd zmax
Definition: glext.h:6450
#define GL_TRIANGLE_STRIP_ADJACENCY
Definition: glcorearb.h:1527
void APIENTRY glFlush()
Definition: GteOpenGL.cpp:448
GLint GLint GLsizei GLint GLenum format
Definition: glcorearb.h:103
GL4InputLayout * Bind(GLuint programHandle, GLuint vbufferHandle, VertexBuffer const *vbuffer)
static std::shared_ptr< GEObject > Create(void *unused, GraphicsObject const *object)
unsigned int GetNumActiveElements() const
Definition: GteResource.h:178
std::shared_ptr< Font > mDefaultFont
GEObject * Bind(std::shared_ptr< GraphicsObject > const &object)
IP_POLYPOINT
bool IsIndexed() const
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:1997
GLuint shader
Definition: glcorearb.h:780
void APIENTRY glClearDepth(GLdouble depth)
Definition: GteOpenGL.cpp:357
static std::shared_ptr< GEObject > Create(void *unused, GraphicsObject const *object)
virtual void SetBlendState(std::shared_ptr< BlendState > const &state) override
#define GL_UNSIGNED_INT
Definition: glcorearb.h:328
static std::shared_ptr< GEObject > Create(void *unused, GraphicsObject const *object)
double GLdouble
Definition: glcorearb.h:88
void APIENTRY glGetIntegerv(GLenum pname, GLint *data)
Definition: GteOpenGL.cpp:632
unsigned int mYSize
Definition: GteBaseEngine.h:95
GLuint index
Definition: glcorearb.h:781
int AcquireUnit(GLint program, GLint index)
void APIENTRY glBindImageTexture(GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format)
Definition: GteOpenGL.cpp:7587
IP_TRISTRIP
virtual void SetViewport(int x, int y, int w, int h) override
int GetUnit(GLint program, GLint index) const
void APIENTRY glClear(GLbitfield mask)
Definition: GteOpenGL.cpp:318
#define GL_UNSIGNED_SHORT
Definition: glcorearb.h:326
virtual bool Update() override
#define GL_STENCIL_BUFFER_BIT
Definition: glcorearb.h:197
static std::shared_ptr< GEObject > Create(void *unused, GraphicsObject const *object)
void APIENTRY glBindBufferBase(GLenum target, GLuint index, GLuint buffer)
Definition: GteOpenGL.cpp:3442
void DisableTextureArrays(Shader const *shader, GLuint program)
GLfloat f
Definition: glcorearb.h:1921
void APIENTRY glGetDoublev(GLenum pname, GLdouble *data)
Definition: GteOpenGL.cpp:591
void APIENTRY glUniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding)
Definition: GteOpenGL.cpp:4690
void APIENTRY glClearColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
Definition: GteOpenGL.cpp:331
#define GL_TRUE
Definition: glcorearb.h:200
#define GL_ATOMIC_COUNTER_BUFFER
Definition: glcorearb.h:2114
#define GL_READ_WRITE
Definition: glcorearb.h:632
GLintptr offset
Definition: glcorearb.h:660
uint64_t DrawPrimitive(VertexBuffer const *vbuffer, IndexBuffer const *ibuffer)
static std::shared_ptr< GEObject > Create(void *unused, GraphicsObject const *object)
GLuint buffer
Definition: glcorearb.h:655
void APIENTRY glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const void *indices)
Definition: GteOpenGL.cpp:1052
void EnableTextureArrays(Shader const *shader, GLuint program)
bool EnableShaders(std::shared_ptr< VisualEffect > const &effect, GLuint program)
static int const shaderDataLookup
virtual void ClearStencilBuffer() override
#define GL_DEPTH_RANGE
Definition: glcorearb.h:257
static void UnsubscribeForDestruction(std::shared_ptr< ListenerForDestruction > const &listener)
void APIENTRY glClearStencil(GLint s)
Definition: GteOpenGL.cpp:344
void AttachToUnit(GLint atomicCounterBufferUnit)
#define GL_LINES_ADJACENCY
Definition: glcorearb.h:1524
virtual void SetRasterizerState(std::shared_ptr< RasterizerState > const &state) override
unsigned GetUnitLinkCount(unsigned unit) const
void EnableTBuffers(Shader const *shader, GLuint program)
virtual bool Update()
static std::shared_ptr< GEObject > Create(void *unused, GraphicsObject const *object)
void DisableSBuffers(Shader const *shader, GLuint program)
std::shared_ptr< DTListener > mDTListener
void DisableCBuffers(Shader const *shader, GLuint program)
#define GL_DEPTH_BUFFER_BIT
Definition: glcorearb.h:196
#define GL_TRIANGLES
Definition: glcorearb.h:205
GLint y
Definition: glcorearb.h:98
virtual void SetDepthRange(float zmin, float zmax) override
std::vector< std::shared_ptr< RawBuffer > > mAtomicCounterRawBuffers
Definition: GteGL4Engine.h:84
static std::shared_ptr< GEObject > Create(void *unused, GraphicsObject const *object)
void DisableSamplers(Shader const *shader, GLuint program)
virtual void ClearBuffers() override
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:103
virtual bool CopyCpuToGpu() override
virtual void GetDepthRange(float &zmin, float &zmax) const override
virtual bool CopyGpuToCpu()
uint32_t GetNumActiveIndices() const
std::vector< Data > const & GetData(int lookup) const
Definition: GteShader.h:393
#define GL_INVALID_INDEX
Definition: glcorearb.h:1451
std::shared_ptr< ComputeShader > const & GetCShader() const


geometric_tools_engine
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 04:00:00