这篇教程C++ ARRAY_SIZE_IN_ELEMENTS函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中ARRAY_SIZE_IN_ELEMENTS函数的典型用法代码示例。如果您正苦于以下问题:C++ ARRAY_SIZE_IN_ELEMENTS函数的具体用法?C++ ARRAY_SIZE_IN_ELEMENTS怎么用?C++ ARRAY_SIZE_IN_ELEMENTS使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了ARRAY_SIZE_IN_ELEMENTS函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: DSGeometryPass void DSGeometryPass() { m_DSGeomPassTech.Enable(); m_gbuffer.BindForWriting(); // Only the geometry pass updates the depth buffer glDepthMask(GL_TRUE); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_DEPTH_TEST); glDisable(GL_BLEND); Pipeline p; p.SetCamera(m_pGameCamera->GetPos(), m_pGameCamera->GetTarget(), m_pGameCamera->GetUp()); p.SetPerspectiveProj(m_persProjInfo); p.Rotate(0.0f, m_scale, 0.0f); for (unsigned int i = 0 ; i < ARRAY_SIZE_IN_ELEMENTS(m_boxPositions) ; i++) { p.WorldPos(m_boxPositions[i]); m_DSGeomPassTech.SetWVP(p.GetWVPTrans()); m_DSGeomPassTech.SetWorldMatrix(p.GetWorldTrans()); m_box.Render(); } // When we get here the depth buffer is already populated and the stencil pass // depends on it, but it does not write to it. glDepthMask(GL_FALSE); glDisable(GL_DEPTH_TEST); }
开发者ID:LSilent,项目名称:OpenGL_Step_By_Step_Source,代码行数:33,
示例2: glGenTexturesbool CubemapTexture::Load(){ glGenTextures(1, &m_textureObj); glBindTexture(GL_TEXTURE_CUBE_MAP, m_textureObj); Magick::Image* pImage = NULL; Magick::Blob blob; for (unsigned int i = 0 ; i < ARRAY_SIZE_IN_ELEMENTS(types) ; i++) { pImage = new Magick::Image(m_fileNames[i]); try { pImage->write(&blob, "RGBA"); } catch (Magick::Error& Error) { cout << "Error loading texture '" << m_fileNames[i] << "': " << Error.what() << endl; delete pImage; return false; } glTexImage2D(types[i], 0, GL_RGB, pImage->columns(), pImage->rows(), 0, GL_RGBA, GL_UNSIGNED_BYTE, blob.data()); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); //delete pImage; } return true;}
开发者ID:alwaystiys,项目名称:OpenGL,代码行数:31,
示例3: Clearbool BasicMesh::LoadMesh(const string& Filename){ // Release the previously loaded mesh (if it exists) Clear(); // Create the VAO glGenVertexArrays(1, &m_VAO); glBindVertexArray(m_VAO); // Create the buffers for the vertices attributes glGenBuffers(ARRAY_SIZE_IN_ELEMENTS(m_Buffers), m_Buffers); bool Ret = false; Assimp::Importer Importer; const aiScene* pScene = Importer.ReadFile(Filename.c_str(), aiProcess_Triangulate | aiProcess_GenSmoothNormals | aiProcess_FlipUVs | aiProcess_FindDegenerates); if (pScene) { Ret = InitFromScene(pScene, Filename); } else { printf("Error parsing '%s': '%s'/n", Filename.c_str(), Importer.GetErrorString()); } // Make sure the VAO is not changed from the outside glBindVertexArray(0); return Ret;}
开发者ID:nburfield,项目名称:CS791-Advanced-Computer-Graphics,代码行数:29,
示例4: Clearbool Mesh::LoadMesh(const string& Filename){ // Release the previously loaded mesh (if it exists) Clear(); // Create the VAO glGenVertexArrays(1, &m_VAO); glBindVertexArray(m_VAO); // Create the buffers for the vertices attributes glGenBuffers(ARRAY_SIZE_IN_ELEMENTS(m_Buffers), m_Buffers); bool Ret = false; m_pScene = m_Importer.ReadFile(Filename.c_str(), aiProcess_Triangulate | aiProcess_GenSmoothNormals | aiProcess_FlipUVs); if (m_pScene) { m_GlobalInverseTransform = m_pScene->mRootNode->mTransformation; m_GlobalInverseTransform.Inverse(); Ret = InitFromScene(m_pScene, Filename); } else { printf("Error parsing '%s': '%s'/n", Filename.c_str(), m_Importer.GetErrorString()); } // Make sure the VAO is not changed from the outside glBindVertexArray(0); return Ret;}
开发者ID:rue-ryuzaki,项目名称:Visual-OpenGL,代码行数:30,
示例5: glGenFramebuffersbool MarkerSamplingFBO::Init(unsigned int WindowWidth, unsigned int WindowHeight, int agentnum, int markernum, bool debug){ this->m_debug = debug; this->m_markernum = markernum; this->m_agentnum = agentnum; // Create the FBO glGenFramebuffers(1, &m_fbo); // Create the depth buffer glGenTextures(1, &m_markersamplingmap); glBindTexture(GL_TEXTURE_2D, m_markersamplingmap); glGenTextures(1, &m_depthTexture); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, WindowWidth, WindowHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fbo); glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_markersamplingmap, 0); glBindTexture(GL_TEXTURE_2D, m_depthTexture); glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32F, WindowWidth, WindowHeight, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL); glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, m_depthTexture, 0); GLenum DrawBuffers[] = { GL_COLOR_ATTACHMENT0 }; glDrawBuffers(ARRAY_SIZE_IN_ELEMENTS(DrawBuffers), DrawBuffers); GLenum Status = glCheckFramebufferStatus(GL_FRAMEBUFFER); if (Status != GL_FRAMEBUFFER_COMPLETE) { printf("FB error, status: 0x%x/n", Status); return false; } glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); if(this->m_debug == true) { glGenBuffers(1, &m_writebuffer); glBindBuffer(GL_TEXTURE_BUFFER, m_writebuffer); //glBufferData(GL_TEXTURE_BUFFER, sizeof(float), NULL, GL_DYNAMIC_READ); //glBindBuffer(GL_TEXTURE_BUFFER, 0); glBufferData(GL_TEXTURE_BUFFER, 4 * markernum*sizeof(float), NULL, GL_DYNAMIC_READ); glBindBuffer(GL_TEXTURE_BUFFER, 0); //floating texture glGenTextures(1, &m_writeTex); glBindTexture(GL_TEXTURE_BUFFER, m_writeTex); glTexBuffer(GL_TEXTURE_BUFFER, GL_RGBA32F, m_writebuffer); glBindTexture(GL_TEXTURE_BUFFER, 0); } return true;}
开发者ID:taviamcboa,项目名称:Crowd-Simulation-,代码行数:59,
示例6: glDrawBuffervoid GBuffer::BindForLightPass(){ glDrawBuffer(GL_COLOR_ATTACHMENT4); for (unsigned int i = 0 ; i < ARRAY_SIZE_IN_ELEMENTS(m_textures); i++) { glActiveTexture(GL_TEXTURE0 + i); glBindTexture(GL_TEXTURE_2D, m_textures[GBUFFER_TEXTURE_TYPE_POSITION + i]); }}
开发者ID:Eizen,项目名称:ogldev,代码行数:9,
示例7: glBindFramebuffervoid EG_GBuffer::bindForReadingLightPass(){ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); for (unsigned int i = 0 ; i < ARRAY_SIZE_IN_ELEMENTS(m_textures); i++) { glActiveTexture(GL_TEXTURE0 + i); glBindTexture(GL_TEXTURE_2D, m_textures[GBUFFER_TEXTURE_TYPE_POSITION + i]); }}
开发者ID:maestro92,项目名称:Explosion-Generator,代码行数:9,
示例8: glGenFramebuffersbool GBuffer::Init(unsigned int WindowWidth, unsigned int WindowHeight){ // Create the FBO glGenFramebuffers(1, &m_fbo); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fbo); // Create the gbuffer textures glGenTextures(ARRAY_SIZE_IN_ELEMENTS(m_textures), m_textures); glGenTextures(1, &m_depthTexture); for (unsigned int i = 0 ; i < ARRAY_SIZE_IN_ELEMENTS(m_textures) ; i++) { glBindTexture(GL_TEXTURE_2D, m_textures[i]);#if !defined (PIPELINE_DEFERRED_DEBUG) glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);#endif glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB32F, WindowWidth, WindowHeight, 0, GL_RGB, GL_FLOAT, NULL); glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_TEXTURE_2D, m_textures[i], 0); } // depth glBindTexture(GL_TEXTURE_2D, m_depthTexture); glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32F, WindowWidth, WindowHeight, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL); glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, m_depthTexture, 0); GLenum DrawBuffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, GL_COLOR_ATTACHMENT3 }; glDrawBuffers(ARRAY_SIZE_IN_ELEMENTS(DrawBuffers), DrawBuffers); GLenum Status = glCheckFramebufferStatus(GL_FRAMEBUFFER); if (Status != GL_FRAMEBUFFER_COMPLETE) { printf("FB error, status: 0x%x/n", Status); return false; } // restore default FBO glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); return true;}
开发者ID:Faham,项目名称:deferred-csm,代码行数:44,
示例9: glDrawBuffervoid EG_GBuffer::BindForLightPass37(){ // we set the target to be the final buffer and bind the attribute buffers as a source glDrawBuffer(GL_COLOR_ATTACHMENT7); for (unsigned int i = 0 ; i < ARRAY_SIZE_IN_ELEMENTS(m_textures); i++) { glActiveTexture(GL_TEXTURE0 + i); glBindTexture(GL_TEXTURE_2D, m_textures[GBUFFER_TEXTURE_TYPE_POSITION + i]); }}
开发者ID:maestro92,项目名称:Explosion-Generator,代码行数:10,
示例10: glGenFramebuffersbool GBuffer::Init(unsigned int WindowWidth, unsigned int WindowHeight){ // Create the FBO glGenFramebuffers(1, &m_fbo); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fbo); // Create the gbuffer textures glGenTextures(ARRAY_SIZE_IN_ELEMENTS(m_textures), m_textures); glGenTextures(1, &m_depthTexture); glGenTextures(1, &m_finalTexture); for (unsigned int i = 0 ; i < ARRAY_SIZE_IN_ELEMENTS(m_textures) ; i++) { glBindTexture(GL_TEXTURE_2D, m_textures[i]); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB32F, WindowWidth, WindowHeight, 0, GL_RGB, GL_FLOAT, NULL); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_TEXTURE_2D, m_textures[i], 0); } // depth glBindTexture(GL_TEXTURE_2D, m_depthTexture); glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH32F_STENCIL8, WindowWidth, WindowHeight, 0, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, NULL); glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_depthTexture, 0); // final glBindTexture(GL_TEXTURE_2D, m_finalTexture); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, WindowWidth, WindowHeight, 0, GL_RGB, GL_FLOAT, NULL); glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT4, GL_TEXTURE_2D, m_finalTexture, 0); GLenum Status = glCheckFramebufferStatus(GL_FRAMEBUFFER); if (Status != GL_FRAMEBUFFER_COMPLETE) { printf("FB error, status: 0x%x/n", Status); return false; } // restore default FBO glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); return true;}
开发者ID:nburfield,项目名称:CS791-Advanced-Computer-Graphics,代码行数:43,
示例11: glBindFramebuffervoid GBuffer::BindForGeomPass(){ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fbo); GLenum DrawBuffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2 }; glDrawBuffers(ARRAY_SIZE_IN_ELEMENTS(DrawBuffers), DrawBuffers);}
开发者ID:Eizen,项目名称:ogldev,代码行数:10,
示例12: AddBoneData void VertexBoneData::AddBoneData(unsigned BoneID, float Weight) { for (unsigned i = 0; i < ARRAY_SIZE_IN_ELEMENTS(IDs); i++) { if (Weights[i] == 0.0) { IDs[i] = BoneID; Weights[i] = Weight; return; } } throw "more bones than available"; //this should never happen because I am asking assimp to only allow 4 bones }
开发者ID:OrlandoAguilar,项目名称:GraphicsSystem,代码行数:11,
示例13: glDeleteBuffersNavigationBuildingBufferGeometry::~NavigationBuildingBufferGeometry(){ if (m_Buffers[0] != 0) { glDeleteBuffers(ARRAY_SIZE_IN_ELEMENTS(m_Buffers), m_Buffers); } if (m_VAO != 0) { glDeleteVertexArrays(1, &m_VAO); m_VAO = 0; }}
开发者ID:taviamcboa,项目名称:Crowd-Simulation-,代码行数:12,
示例14: glBindFramebuffervoid GBuffer::BindForWriting(){ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, frameBuffer); //glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); GLenum DrawBuffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2 //GL_COLOR_ATTACHMENT3 }; glDrawBuffers(ARRAY_SIZE_IN_ELEMENTS(DrawBuffers), DrawBuffers);}
开发者ID:Cigg,项目名称:Screen-space-ambient-occlusion,代码行数:13,
示例15: assertvoid Mesh::VertexBoneData::AddBoneData(uint BoneID, float Weight){ for (uint i = 0 ; i < ARRAY_SIZE_IN_ELEMENTS(IDs) ; i++) { if (Weights[i] == 0.0) { IDs[i] = BoneID; Weights[i] = Weight; return; } } // should never get here - more bones than we have space for assert(0);}
开发者ID:rue-ryuzaki,项目名称:Visual-OpenGL,代码行数:13,
示例16: definedvoid GBuffer::BindForReading(){#if defined (PIPELINE_DEFERRED_DEBUG) glBindFramebuffer(GL_READ_FRAMEBUFFER, m_fbo);#else glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0); for (unsigned int i = 0 ; i < ARRAY_SIZE_IN_ELEMENTS(m_textures); i++) { glActiveTexture(GL_TEXTURE0 + i); glBindTexture(GL_TEXTURE_2D, m_textures[GBUFFER_TEXTURE_TYPE_POSITION + i]); }#endif}
开发者ID:Faham,项目名称:deferred-csm,代码行数:13,
示例17: glDeleteFramebuffersGBuffer::~GBuffer(){ if (frameBuffer != 0) { glDeleteFramebuffers(1, &frameBuffer); } if (textures[0] != 0) { glDeleteTextures(ARRAY_SIZE_IN_ELEMENTS(textures), textures); } if (depthTexture != 0) { glDeleteTextures(1, &depthTexture); }}
开发者ID:Cigg,项目名称:Screen-space-ambient-occlusion,代码行数:14,
示例18: glDeleteFramebuffersEG_GBuffer::~EG_GBuffer(){ if (m_fbo != 0) { glDeleteFramebuffers(1, &m_fbo); } if (m_textures[0] != 0) { glDeleteTextures(ARRAY_SIZE_IN_ELEMENTS(m_textures), m_textures); } if (m_depthTexture != 0) { glDeleteTextures(1, &m_depthTexture); }}
开发者ID:maestro92,项目名称:Explosion-Generator,代码行数:14,
示例19: RenderPhase void RenderPhase() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); Pipeline p; p.Scale(0.1f, 0.1f, 0.1f); p.Rotate(0.0f, 90.0f, 0.0f); p.SetCamera(m_pGameCamera->GetPos(), m_pGameCamera->GetTarget(), m_pGameCamera->GetUp()); p.SetPerspectiveProj(m_persProjInfo); // If the left mouse button is clicked check if it hit a triangle // and color it red if (m_leftMouseButton.IsPressed) { PickingTexture::PixelInfo Pixel = m_pickingTexture.ReadPixel(m_leftMouseButton.x, WINDOW_HEIGHT - m_leftMouseButton.y - 1); GLExitIfError; if (Pixel.PrimID != 0) { m_simpleColorEffect.Enable(); assert(Pixel.ObjectID < ARRAY_SIZE_IN_ELEMENTS(m_worldPos)); p.WorldPos(m_worldPos[(uint)Pixel.ObjectID]); m_simpleColorEffect.SetWVP(p.GetWVPTrans()); // Must compensate for the decrement in the FS! m_pMesh->Render((uint)Pixel.DrawID, (uint)Pixel.PrimID - 1); } } // render the objects as usual m_lightingEffect.Enable(); m_lightingEffect.SetEyeWorldPos(m_pGameCamera->GetPos()); for (unsigned int i = 0 ; i < ARRAY_SIZE_IN_ELEMENTS(m_worldPos) ; i++) { p.WorldPos(m_worldPos[i]); m_lightingEffect.SetWVP(p.GetWVPTrans()); m_lightingEffect.SetWorldMatrix(p.GetWorldTrans()); m_pMesh->Render(NULL); } }
开发者ID:leloulight,项目名称:ogldev,代码行数:36,
示例20: CreateVertexBuffer void CreateVertexBuffer(const unsigned int* pIndices, unsigned int IndexCount) { Vertex Vertices[4] = { Vertex(Vector3f(-10.0f, -2.0f, -10.0f), Vector2f(0.0f, 0.0f)), Vertex(Vector3f(10.0f, -2.0f, -10.0f), Vector2f(1.0f, 0.0f)), Vertex(Vector3f(10.0f, -2.0f, 10.0f), Vector2f(1.0f, 1.0f)), Vertex(Vector3f(-10.0f, -2.0f, 10.0f), Vector2f(0.0f, 1.0f))}; unsigned int VertexCount = ARRAY_SIZE_IN_ELEMENTS(Vertices); CalcNormals(pIndices, IndexCount, Vertices, VertexCount); glGenBuffers(1, &m_VBO); glBindBuffer(GL_ARRAY_BUFFER, m_VBO); glBufferData(GL_ARRAY_BUFFER, sizeof(Vertices), Vertices, GL_STATIC_DRAW); }
开发者ID:andriyut,项目名称:ogldev,代码行数:15,
示例21: SAFE_DELETEvoid BasicMesh::Clear(){ for (unsigned int i = 0 ; i < m_Textures.size() ; i++) { SAFE_DELETE(m_Textures[i]); } if (m_Buffers[0] != 0) { glDeleteBuffers(ARRAY_SIZE_IN_ELEMENTS(m_Buffers), m_Buffers); } if (m_VAO != 0) { glDeleteVertexArrays(1, &m_VAO); m_VAO = 0; }}
开发者ID:nburfield,项目名称:CS791-Advanced-Computer-Graphics,代码行数:15,
示例22: GetUniformLocationint LightingRoutine::Init(){ int shaderInit = Shader::Init(); if (shaderInit != 0) return shaderInit; if (!AddShader(GL_VERTEX_SHADER, m_sVertexShaderFilename.c_str())) return 21; if (!AddShader(GL_FRAGMENT_SHADER, m_sFragmentShaderFilename.c_str())) return 22; if (!Finalize()) return 23; m_wvpLocation = GetUniformLocation("gWVP"); m_worldMatrixLocation = GetUniformLocation("gWorld"); m_samplerLocation = GetUniformLocation("gSampler"); m_dirLightLocation.m_color = GetUniformLocation("gDirectionalLight.Color"); m_dirLightLocation.m_ambientIntensity = GetUniformLocation("gDirectionalLight.AmbientIntensity"); m_dirLightLocation.m_direction = GetUniformLocation("gDirectionalLight.Direction"); m_dirLightLocation.m_diffuseIntensity = GetUniformLocation("gDirectionalLight.DiffuseIntensity"); m_matSpecularIntensityLocation = GetUniformLocation("gMatSpecularIntensity"); m_matSpecularPowerLocation = GetUniformLocation("gSpecularPower"); if (m_dirLightLocation.m_ambientIntensity == 0xFFFFFFFF || m_wvpLocation == 0xFFFFFFFF || m_worldMatrixLocation == 0xFFFFFFFF || m_samplerLocation == 0xFFFFFFFF || m_dirLightLocation.m_color == 0xFFFFFFFF || m_dirLightLocation.m_diffuseIntensity == 0xFFFFFFFF || m_dirLightLocation.m_direction == 0xFFFFFFFF || m_matSpecularIntensityLocation == 0xFFFFFFFF || m_matSpecularPowerLocation == 0xFFFFFFFF) { return 24; } for (unsigned int i = 0 ; i < ARRAY_SIZE_IN_ELEMENTS(m_boneLocation) ; i++) { char name[128]; memset(name, 0, sizeof(name)); SNPRINTF(name, sizeof(name), "gBones[%d]", i); m_boneLocation[i] = GetUniformLocation(name); } return 0;}
开发者ID:Spankadikt,项目名称:Fawrek,代码行数:47,
示例23: DSPointLightsPass void DSPointLightsPass() { m_DSPointLightPassTech.Enable(); m_DSPointLightPassTech.SetEyeWorldPos(m_pGameCamera->GetPos()); Pipeline p; p.SetCamera(m_pGameCamera->GetPos(), m_pGameCamera->GetTarget(), m_pGameCamera->GetUp()); p.SetPerspectiveProj(m_persProjInfo); for (unsigned int i = 0 ; i < ARRAY_SIZE_IN_ELEMENTS(m_pointLight); i++) { m_DSPointLightPassTech.SetPointLight(m_pointLight[i]); p.WorldPos(m_pointLight[i].Position); float BSphereScale = CalcPointLightBSphere(m_pointLight[i]); p.Scale(BSphereScale, BSphereScale, BSphereScale); m_DSPointLightPassTech.SetWVP(p.GetWVPTrans()); m_bsphere.Render(); } }
开发者ID:LIngBY,项目名称:ogldev,代码行数:18,
示例24: glGenTexturesbool CubemapTexture::Load(const string& Directory, const string& PosXFilename, const string& NegXFilename, const string& PosYFilename, const string& NegYFilename, const string& PosZFilename, const string& NegZFilename){ string::const_iterator it = Directory.end(); it--; string BaseDir = (*it == '//') ? Directory : Directory + "//"; m_fileNames[0] = BaseDir + PosXFilename; m_fileNames[1] = BaseDir + NegXFilename; m_fileNames[2] = BaseDir + PosYFilename; m_fileNames[3] = BaseDir + NegYFilename; m_fileNames[4] = BaseDir + PosZFilename; m_fileNames[5] = BaseDir + NegZFilename; glGenTextures(1, &m_textureObj); glBindTexture(GL_TEXTURE_CUBE_MAP, m_textureObj); for (unsigned int i = 0 ; i < ARRAY_SIZE_IN_ELEMENTS(types) ; i++) { nv::Image fImage; fImage.loadImageFromFile(m_fileNames[i].c_str()); unsigned char* data = (unsigned char*)fImage.getLevel(0); glTexImage2D(types[i], 0, fImage.getInternalFormat(), fImage.getWidth(), fImage.getHeight(), 0, fImage.getFormat(), fImage.getType(), data); } glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); return true;}
开发者ID:ak239,项目名称:clouds.technology2,代码行数:39,
示例25: PickingPhase void PickingPhase() { Pipeline p; p.Scale(0.1f, 0.1f, 0.1f); p.Rotate(0.0f, 90.0f, 0.0f); p.SetCamera(m_pGameCamera->GetPos(), m_pGameCamera->GetTarget(), m_pGameCamera->GetUp()); p.SetPerspectiveProj(m_persProjInfo); m_pickingTexture.EnableWriting(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); m_pickingEffect.Enable(); for (unsigned int i = 0 ; i < ARRAY_SIZE_IN_ELEMENTS(m_worldPos) ; i++) { p.WorldPos(m_worldPos[i]); m_pickingEffect.SetObjectIndex(i); m_pickingEffect.SetWVP(p.GetWVPTrans()); m_pMesh->Render(&m_pickingEffect); } m_pickingTexture.DisableWriting(); }
开发者ID:andriyut,项目名称:ogldev,代码行数:23,
示例26: Init bool Init() { Vector3f Pos(0.0f, 0.0f, -3.0f); Vector3f Target(0.0f, 0.0f, 1.0f); Vector3f Up(0.0, 1.0f, 0.0f); m_pGameCamera = new Camera(WINDOW_WIDTH, WINDOW_HEIGHT, Pos, Target, Up); unsigned int Indices[] = { 0, 3, 1, 1, 3, 2, 2, 3, 0, 1, 2, 0 }; CreateIndexBuffer(Indices, sizeof(Indices)); CreateVertexBuffer(Indices, ARRAY_SIZE_IN_ELEMENTS(Indices)); m_pEffect = new LightingTechnique(); if (!m_pEffect->Init()) { printf("Error initializing the lighting technique/n"); return false; } m_pEffect->Enable(); m_pEffect->SetTextureUnit(0); m_pTexture = new Texture(GL_TEXTURE_2D, "test.png"); if (!m_pTexture->Load()) { return false; } return true; }
开发者ID:Barricade,项目名称:ogldev,代码行数:36,
示例27: Posbool Tutorial18::Init(char* pVSFileName, char* pFSFileName){ Vector3f Pos(0.0f, 0.0f, -3.0f); Vector3f Target(0.0f, 0.0f, 1.0f); Vector3f Up(0.0, 1.0f, 0.0f); m_pGameCamera = new Camera(WINDOW_WIDTH, WINDOW_HEIGHT, Pos, Target, Up); unsigned int Indices[] = { 0, 3, 1, 1, 3, 2, 2, 3, 0, 1, 2, 0 }; CreateIndexBuffer(Indices, sizeof(Indices)); CreateVertexBuffer(Indices, ARRAY_SIZE_IN_ELEMENTS(Indices)); m_pEffect = new LightingTechnique(); if (!m_pEffect->Init(pVSFileName, pFSFileName)) { printf("Error initializing the lighting technique/n"); return false; } m_pEffect->Enable(); m_pEffect->SetTextureUnit(0); m_pTexture = new Texture(GL_TEXTURE_2D, "/home/lparkin/Projects/S3/OpenGlDirsProject/LearnOpenGL-nonQt/Project/Content/test.png"); if (!m_pTexture->Load()) { return false; } return true;}
开发者ID:LouisParkin,项目名称:OpenGlDirsProject,代码行数:36,
示例28: GetUniformLocationbool LightingTechnique::Init(){ if (!Technique::Init()) { return false; } if (!AddShader(GL_VERTEX_SHADER, pVS)) { return false; } if (!AddShader(GL_FRAGMENT_SHADER, pFS)) { return false; } if (!Finalize()) { return false; } m_WVPLocation = GetUniformLocation("gWVP"); m_LightWVPLocation = GetUniformLocation("gLightWVP"); m_WorldMatrixLocation = GetUniformLocation("gWorld"); m_samplerLocation = GetUniformLocation("gSampler"); m_shadowMapLocation = GetUniformLocation("gShadowMap"); m_eyeWorldPosLocation = GetUniformLocation("gEyeWorldPos"); m_dirLightLocation.Color = GetUniformLocation("gDirectionalLight.Base.Color"); m_dirLightLocation.AmbientIntensity = GetUniformLocation("gDirectionalLight.Base.AmbientIntensity"); m_dirLightLocation.Direction = GetUniformLocation("gDirectionalLight.Direction"); m_dirLightLocation.DiffuseIntensity = GetUniformLocation("gDirectionalLight.Base.DiffuseIntensity"); m_matSpecularIntensityLocation = GetUniformLocation("gMatSpecularIntensity"); m_matSpecularPowerLocation = GetUniformLocation("gSpecularPower"); m_numPointLightsLocation = GetUniformLocation("gNumPointLights"); m_numSpotLightsLocation = GetUniformLocation("gNumSpotLights"); if (m_dirLightLocation.AmbientIntensity == INVALID_UNIFORM_LOCATION || m_WVPLocation == INVALID_UNIFORM_LOCATION || m_LightWVPLocation == INVALID_UNIFORM_LOCATION || m_WorldMatrixLocation == INVALID_UNIFORM_LOCATION || m_samplerLocation == INVALID_UNIFORM_LOCATION || m_shadowMapLocation == INVALID_UNIFORM_LOCATION || m_eyeWorldPosLocation == INVALID_UNIFORM_LOCATION || m_dirLightLocation.Color == INVALID_UNIFORM_LOCATION || m_dirLightLocation.DiffuseIntensity == INVALID_UNIFORM_LOCATION || m_dirLightLocation.Direction == INVALID_UNIFORM_LOCATION || m_matSpecularIntensityLocation == INVALID_UNIFORM_LOCATION || m_matSpecularPowerLocation == INVALID_UNIFORM_LOCATION || m_numPointLightsLocation == INVALID_UNIFORM_LOCATION || m_numSpotLightsLocation == INVALID_UNIFORM_LOCATION) { return false; } for (unsigned int i = 0 ; i < ARRAY_SIZE_IN_ELEMENTS(m_pointLightsLocation) ; i++) { char Name[128]; memset(Name, 0, sizeof(Name)); snprintf(Name, sizeof(Name), "gPointLights[%d].Base.Color", i); m_pointLightsLocation[i].Color = GetUniformLocation(Name); snprintf(Name, sizeof(Name), "gPointLights[%d].Base.AmbientIntensity", i); m_pointLightsLocation[i].AmbientIntensity = GetUniformLocation(Name); snprintf(Name, sizeof(Name), "gPointLights[%d].Position", i); m_pointLightsLocation[i].Position = GetUniformLocation(Name); snprintf(Name, sizeof(Name), "gPointLights[%d].Base.DiffuseIntensity", i); m_pointLightsLocation[i].DiffuseIntensity = GetUniformLocation(Name); snprintf(Name, sizeof(Name), "gPointLights[%d].Atten.Constant", i); m_pointLightsLocation[i].Atten.Constant = GetUniformLocation(Name); snprintf(Name, sizeof(Name), "gPointLights[%d].Atten.Linear", i); m_pointLightsLocation[i].Atten.Linear = GetUniformLocation(Name); snprintf(Name, sizeof(Name), "gPointLights[%d].Atten.Exp", i); m_pointLightsLocation[i].Atten.Exp = GetUniformLocation(Name); if (m_pointLightsLocation[i].Color == INVALID_UNIFORM_LOCATION || m_pointLightsLocation[i].AmbientIntensity == INVALID_UNIFORM_LOCATION || m_pointLightsLocation[i].Position == INVALID_UNIFORM_LOCATION || m_pointLightsLocation[i].DiffuseIntensity == INVALID_UNIFORM_LOCATION || m_pointLightsLocation[i].Atten.Constant == INVALID_UNIFORM_LOCATION || m_pointLightsLocation[i].Atten.Linear == INVALID_UNIFORM_LOCATION || m_pointLightsLocation[i].Atten.Exp == INVALID_UNIFORM_LOCATION) { return false; } } for (unsigned int i = 0 ; i < ARRAY_SIZE_IN_ELEMENTS(m_spotLightsLocation) ; i++) { char Name[128]; memset(Name, 0, sizeof(Name)); snprintf(Name, sizeof(Name), "gSpotLights[%d].Base.Base.Color", i); m_spotLightsLocation[i].Color = GetUniformLocation(Name); snprintf(Name, sizeof(Name), "gSpotLights[%d].Base.Base.AmbientIntensity", i); m_spotLightsLocation[i].AmbientIntensity = GetUniformLocation(Name); snprintf(Name, sizeof(Name), "gSpotLights[%d].Base.Position", i); m_spotLightsLocation[i].Position = GetUniformLocation(Name); snprintf(Name, sizeof(Name), "gSpotLights[%d].Direction", i); m_spotLightsLocation[i].Direction = GetUniformLocation(Name);//.........这里部分代码省略.........
开发者ID:Barricade,项目名称:ogldev,代码行数:101,
示例29: GetUniformLocationbool SkinnedMeshShaderManager::Init(){ if (!ShaderManager::Init()) { return false; }// if (!AddShader(GL_VERTEX_SHADER, "/mnt/FA404D5B404D1FAD/GitHub/cs1972/res/shaders/skinning.vert")) {// return false;// } QString fileName = QDir::currentPath().append("/res/shaders/skinning.vert"); if (!AddShader(GL_VERTEX_SHADER, fileName)) { return false; }// if (!AddShader(GL_FRAGMENT_SHADER, "/mnt/FA404D5B404D1FAD/GitHub/cs1972/res/shaders/skinning.frag")) {// return false;// } fileName = QDir::currentPath().append("/res/shaders/skinning.frag"); if (!AddShader(GL_FRAGMENT_SHADER, fileName)) { return false; } if (!Finalize()) { return false; } m_WVPLocation = GetUniformLocation("gWVP"); m_WorldMatrixLocation = GetUniformLocation("gWorld"); m_colorTextureLocation = GetUniformLocation("gColorMap"); m_eyeWorldPosLocation = GetUniformLocation("gEyeWorldPos"); m_dirLightLocation.Color = GetUniformLocation("gDirectionalLight.Base.Color"); m_dirLightLocation.AmbientIntensity = GetUniformLocation("gDirectionalLight.Base.AmbientIntensity"); m_dirLightLocation.Direction = GetUniformLocation("gDirectionalLight.Direction"); m_dirLightLocation.DiffuseIntensity = GetUniformLocation("gDirectionalLight.Base.DiffuseIntensity"); m_matSpecularIntensityLocation = GetUniformLocation("gMatSpecularIntensity"); m_matSpecularPowerLocation = GetUniformLocation("gSpecularPower"); m_numPointLightsLocation = GetUniformLocation("gNumPointLights"); m_numSpotLightsLocation = GetUniformLocation("gNumSpotLights"); if (m_dirLightLocation.AmbientIntensity == INVALID_UNIFORM_LOCATION || m_WVPLocation == INVALID_UNIFORM_LOCATION || m_WorldMatrixLocation == INVALID_UNIFORM_LOCATION || m_colorTextureLocation == INVALID_UNIFORM_LOCATION || m_eyeWorldPosLocation == INVALID_UNIFORM_LOCATION || m_dirLightLocation.Color == INVALID_UNIFORM_LOCATION || m_dirLightLocation.DiffuseIntensity == INVALID_UNIFORM_LOCATION || m_dirLightLocation.Direction == INVALID_UNIFORM_LOCATION || m_matSpecularIntensityLocation == INVALID_UNIFORM_LOCATION || m_matSpecularPowerLocation == INVALID_UNIFORM_LOCATION || m_numPointLightsLocation == INVALID_UNIFORM_LOCATION || m_numSpotLightsLocation == INVALID_UNIFORM_LOCATION) { return false; } for (unsigned int i = 0 ; i < ARRAY_SIZE_IN_ELEMENTS(m_pointLightsLocation) ; i++) { char Name[128]; memset(Name, 0, sizeof(Name)); SNPRINTF(Name, sizeof(Name), "gPointLights[%d].Base.Color", i); m_pointLightsLocation[i].Color = GetUniformLocation(Name); SNPRINTF(Name, sizeof(Name), "gPointLights[%d].Base.AmbientIntensity", i); m_pointLightsLocation[i].AmbientIntensity = GetUniformLocation(Name); SNPRINTF(Name, sizeof(Name), "gPointLights[%d].Position", i); m_pointLightsLocation[i].Position = GetUniformLocation(Name); SNPRINTF(Name, sizeof(Name), "gPointLights[%d].Base.DiffuseIntensity", i); m_pointLightsLocation[i].DiffuseIntensity = GetUniformLocation(Name); SNPRINTF(Name, sizeof(Name), "gPointLights[%d].Atten.Constant", i); m_pointLightsLocation[i].Atten.Constant = GetUniformLocation(Name); SNPRINTF(Name, sizeof(Name), "gPointLights[%d].Atten.Linear", i); m_pointLightsLocation[i].Atten.Linear = GetUniformLocation(Name); SNPRINTF(Name, sizeof(Name), "gPointLights[%d].Atten.Exp", i); m_pointLightsLocation[i].Atten.Exp = GetUniformLocation(Name); if (m_pointLightsLocation[i].Color == INVALID_UNIFORM_LOCATION || m_pointLightsLocation[i].AmbientIntensity == INVALID_UNIFORM_LOCATION || m_pointLightsLocation[i].Position == INVALID_UNIFORM_LOCATION || m_pointLightsLocation[i].DiffuseIntensity == INVALID_UNIFORM_LOCATION || m_pointLightsLocation[i].Atten.Constant == INVALID_UNIFORM_LOCATION || m_pointLightsLocation[i].Atten.Linear == INVALID_UNIFORM_LOCATION || m_pointLightsLocation[i].Atten.Exp == INVALID_UNIFORM_LOCATION) { return false; } } for (unsigned int i = 0 ; i < ARRAY_SIZE_IN_ELEMENTS(m_spotLightsLocation) ; i++) { char Name[128]; memset(Name, 0, sizeof(Name)); SNPRINTF(Name, sizeof(Name), "gSpotLights[%d].Base.Base.Color", i); m_spotLightsLocation[i].Color = GetUniformLocation(Name); SNPRINTF(Name, sizeof(Name), "gSpotLights[%d].Base.Base.AmbientIntensity", i); m_spotLightsLocation[i].AmbientIntensity = GetUniformLocation(Name);//.........这里部分代码省略.........
开发者ID:yuzuquats,项目名称:cs1972,代码行数:101,
示例30: GetUniformLocationbool Lighting::Init(){ if (!Graphics::Init()) { return false; } if (!AddShader(GL_VERTEX_SHADER, "D:/GAM300/OneEngine/OneEngine/Shaders/basic_lighting.vs")) { return false; } if (!AddShader(GL_FRAGMENT_SHADER, "D:/GAM300/OneEngine/OneEngine/Shaders/basic_lighting.fs")) { return false; } if (!Finalize()) { return false; } m_WVPLocation = GetUniformLocation("gWVP"); m_WorldMatrixLocation = GetUniformLocation("gWorld"); m_colorTextureLocation = GetUniformLocation("gColorMap"); //m_samplerLocation = GetUniformLocation("gSampler"); m_eyeWorldPosLocation = GetUniformLocation("gEyeWorldPos"); m_dirLightLocation.Color = GetUniformLocation("gDirectionalLight.Base.Color"); m_dirLightLocation.AmbientIntensity = GetUniformLocation("gDirectionalLight.Base.AmbientIntensity"); m_dirLightLocation.Direction = GetUniformLocation("gDirectionalLight.Direction"); m_dirLightLocation.DiffuseIntensity = GetUniformLocation("gDirectionalLight.Base.DiffuseIntensity"); m_matSpecularIntensityLocation = GetUniformLocation("gMatSpecularIntensity"); m_matSpecularPowerLocation = GetUniformLocation("gSpecularPower"); m_numPointLightsLocation = GetUniformLocation("gNumPointLights"); m_numSpotLightsLocation = GetUniformLocation("gNumSpotLights"); if (m_dirLightLocation.AmbientIntensity == INVALID_UNIFORM_LOCATION || m_WVPLocation == INVALID_UNIFORM_LOCATION || m_WorldMatrixLocation == INVALID_UNIFORM_LOCATION || m_colorTextureLocation == INVALID_UNIFORM_LOCATION || m_eyeWorldPosLocation == INVALID_UNIFORM_LOCATION || m_dirLightLocation.Color == INVALID_UNIFORM_LOCATION || m_dirLightLocation.DiffuseIntensity == INVALID_UNIFORM_LOCATION || m_dirLightLocation.Direction == INVALID_UNIFORM_LOCATION || m_matSpecularIntensityLocation == INVALID_UNIFORM_LOCATION || m_matSpecularPowerLocation == INVALID_UNIFORM_LOCATION || m_numPointLightsLocation == INVALID_UNIFORM_LOCATION || m_numSpotLightsLocation == INVALID_UNIFORM_LOCATION) { return false; } for (unsigned int i = 0; i < ARRAY_SIZE_IN_ELEMENTS(m_pointLightsLocation); i++) { char Name[128]; memset(Name, 0, sizeof(Name)); SNPRINTF(Name, sizeof(Name), "gPointLights[%d].Base.Color", i); m_pointLightsLocation[i].Color = GetUniformLocation(Name); SNPRINTF(Name, sizeof(Name), "gPointLights[%d].Base.AmbientIntensity", i); m_pointLightsLocation[i].AmbientIntensity = GetUniformLocation(Name); SNPRINTF(Name, sizeof(Name), "gPointLights[%d].Position", i); m_pointLightsLocation[i].Position = GetUniformLocation(Name); SNPRINTF(Name, sizeof(Name), "gPointLights[%d].Base.DiffuseIntensity", i); m_pointLightsLocation[i].DiffuseIntensity = GetUniformLocation(Name); SNPRINTF(Name, sizeof(Name), "gPointLights[%d].Atten.Constant", i); m_pointLightsLocation[i].Atten.Constant = GetUniformLocation(Name); SNPRINTF(Name, sizeof(Name), "gPointLights[%d].Atten.Linear", i); m_pointLightsLocation[i].Atten.Linear = GetUniformLocation(Name); SNPRINTF(Name, sizeof(Name), "gPointLights[%d].Atten.Exp", i); m_pointLightsLocation[i].Atten.Exp = GetUniformLocation(Name); if (m_pointLightsLocation[i].Color == INVALID_UNIFORM_LOCATION || m_pointLightsLocation[i].AmbientIntensity == INVALID_UNIFORM_LOCATION || m_pointLightsLocation[i].Position == INVALID_UNIFORM_LOCATION || m_pointLightsLocation[i].DiffuseIntensity == INVALID_UNIFORM_LOCATION || m_pointLightsLocation[i].Atten.Constant == INVALID_UNIFORM_LOCATION || m_pointLightsLocation[i].Atten.Linear == INVALID_UNIFORM_LOCATION || m_pointLightsLocation[i].Atten.Exp == INVALID_UNIFORM_LOCATION) { return false; } } for (unsigned int i = 0; i < ARRAY_SIZE_IN_ELEMENTS(m_spotLightsLocation); i++) { char Name[128]; memset(Name, 0, sizeof(Name)); SNPRINTF(Name, sizeof(Name), "gSpotLights[%d].Base.Base.Color", i); m_spotLightsLocation[i].Color = GetUniformLocation(Name); SNPRINTF(Name, sizeof(Name), "gSpotLights[%d].Base.Base.AmbientIntensity", i); m_spotLightsLocation[i].AmbientIntensity = GetUniformLocation(Name); SNPRINTF(Name, sizeof(Name), "gSpotLights[%d].Base.Position", i); m_spotLightsLocation[i].Position = GetUniformLocation(Name); SNPRINTF(Name, sizeof(Name), "gSpotLights[%d].Direction", i); m_spotLightsLocation[i].Direction = GetUniformLocation(Name); SNPRINTF(Name, sizeof(Name), "gSpotLights[%d].Cutoff", i); m_spotLightsLocation[i].Cutoff = GetUniformLocation(Name);//.........这里部分代码省略.........
开发者ID:jingweilim,项目名称:GAM300,代码行数:101,
注:本文中的ARRAY_SIZE_IN_ELEMENTS函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ ARRAY_TYPE函数代码示例 C++ ARRAY_SIZE函数代码示例 |