Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

Diff Revisions 265 vs 267 for /trunk/Source Code/Hardware/Video/OpenGL/GLStates.cpp

Diff revisions: vs.
  @@ -21,6 +21,7 @@
21 21 bool GL_API::_lastRestartIndexSmall = true;
22 22 bool GL_API::_primitiveRestartEnabled = false;
23 23
24 + GL_API::textureBoundMapDef GL_API::textureBoundMap;
24 25 Unordered_map<GLuint, vec4<GLfloat> > GL_API::_prevClearColor;
25 26
26 27 void GL_API::clearStates(const bool skipShader,const bool skipTextures,const bool skipBuffers, const bool forceAll){
  @@ -29,15 +30,10 @@
29 30 }
30 31
31 32 if(!skipTextures || forceAll){
32 - FOR_EACH(glTexture::textureBoundMapDef::value_type& it, glTexture::textureBoundMap){
33 - if(it.second.second != GL_NONE){
34 - setActiveTextureUnit(it.first);
35 - glSamplerObject::Unbind(it.first);
36 - glBindTexture(it.second.second, 0);
37 - glTexture::textureBoundMap[it.first] = std::make_pair(0, GL_NONE);
38 - }
39 - }
40 - setActiveTextureUnit(0,forceAll);
33 + FOR_EACH(textureBoundMapDef::value_type& it, textureBoundMap)
34 + GL_API::unbindTexture(it.first);
35 +
36 + setActiveTextureUnit(0, forceAll);
41 37 }
42 38
43 39 if(!skipBuffers || forceAll){
  @@ -358,4 +354,27 @@
358 354 newDescriptor._colorWrite.b.b2 == GL_TRUE, // B
359 355 newDescriptor._colorWrite.b.b3 == GL_TRUE);// A
360 356 }
357 + }
358 +
359 + bool GL_API::bindTexture(GLuint unit, GLuint handle, GLenum type, GLuint samplerID){
360 + GL_API::setActiveTextureUnit(unit);
361 + if (checkBinding(unit, handle)){
362 + glBindTexture(type, handle);
363 + textureBoundMap[unit] = std::make_pair(handle, type);
364 + glBindSampler(unit, samplerID);
365 +
366 + return true;
367 + }
368 + return false;
369 + }
370 +
371 + bool GL_API::unbindTexture(GLuint unit){
372 + GLenum textureType = textureBoundMap[unit].second;
373 + if (textureType != GL_NONE){
374 + glBindTexture(textureType, 0);
375 + glBindSampler(unit, 0);
376 + textureBoundMap[unit] = std::make_pair(0, GL_NONE);
377 + return true;
378 + }
379 + return false;
361 380 }