本文整理匯總了C++中GLint函數的典型用法代碼示例。如果您正苦於以下問題:C++ GLint函數的具體用法?C++ GLint怎麽用?C++ GLint使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了GLint函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: initBuffer
bool initBuffer()
{
GLint UniformBufferOffset(0);
glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &UniformBufferOffset);
this->UniformBlockSize = glm::max(GLint(sizeof(glm::mat4)), UniformBufferOffset);
glCreateBuffers(buffer::MAX, &BufferName[0]);
glNamedBufferStorage(BufferName[buffer::ELEMENT], ElementSize, ElementData, 0);
glNamedBufferStorage(BufferName[buffer::VERTEX], VertexSize, VertexData, 0);
glNamedBufferStorage(BufferName[buffer::TRANSFORM], this->UniformBlockSize * 2, nullptr, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT);
this->UniformPointer = static_cast<glm::uint8*>(glMapNamedBufferRange(
BufferName[buffer::TRANSFORM], 0, this->UniformBlockSize * 2, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT | GL_MAP_INVALIDATE_BUFFER_BIT));
return true;
}
示例2: light2Active
static void light2Active(OSG::SHLChunk::GetUniformLocProc fULoc,
OSG::DrawEnv *pEnv,
GLuint uiProg)
{
GLint iLoc = fULoc(uiProg, "Light2Active");
if(iLoc != -1)
{
OSGGETGLFUNC_EXT(glUniform1i,
osgGlUniform1i,
OSG::ShaderProgram::getFuncIdUniform1i());
osgGlUniform1i(iLoc,
GLint(pEnv->getLightState() & 0x0004));
}
}
示例3: initTexture
bool initTexture()
{
gli::texture2d Texture(gli::load_dds((getDataDirectory() + TEXTURE_DIFFUSE).c_str()));
assert(!Texture.empty());
glm::uvec2 FramebufferSize(this->getWindowSize() / 16u);
glCreateTextures(GL_TEXTURE_2D_ARRAY, texture::MAX, &TextureName[0]);
glTextureParameteri(TextureName[0], GL_TEXTURE_BASE_LEVEL, 0);
glTextureParameteri(TextureName[0], GL_TEXTURE_MAX_LEVEL, 0);
glTextureParameteri(TextureName[0], GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTextureParameteri(TextureName[0], GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTextureStorage3D(TextureName[0], GLint(1), GL_RGBA8, GLsizei(FramebufferSize.x), GLsizei(FramebufferSize.y), 1);
return true;
}
示例4: if
void WrappedOpenGL::glGetIntegeri_v(GLenum pname, GLuint index, GLint *data)
{
if(pname == eGL_MIN_MAP_BUFFER_ALIGNMENT)
{
if(data)
*data = (GLint)64;
return;
}
else if(pname == eGL_DEBUG_TOOL_PURPOSE_EXT)
{
if(data)
*data = GLint(eGL_DEBUG_TOOL_FRAME_CAPTURE_BIT_EXT);
return;
}
m_Real.glGetIntegeri_v(pname, index, data);
}
示例5: initTexture
bool initTexture()
{
bool Validated(true);
gli::gl GL;
gli::texture2D Texture(gli::load_dds((getDataDirectory() + TEXTURE_DIFFUSE).c_str()));
gli::gl::format const Format = GL.translate(Texture.format());
assert(!Texture.empty());
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glGenTextures(texture::MAX, &TextureName[0]);
glBindTexture(GL_TEXTURE_2D, TextureName[texture::DIFFUSE]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, GLint(Texture.levels() - 1));
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_R, GL_RED);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_G, GL_GREEN);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_B, GL_BLUE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_ALPHA);
glTexStorage2D(GL_TEXTURE_2D, static_cast<GLint>(Texture.levels()), Format.Internal, static_cast<GLsizei>(Texture.dimensions().x), static_cast<GLsizei>(Texture.dimensions().y));
for (std::size_t Level = 0; Level < Texture.levels(); ++Level)
{
glCompressedTexSubImage2D(GL_TEXTURE_2D, static_cast<GLint>(Level),
0, 0,
static_cast<GLsizei>(Texture[Level].dimensions().x), static_cast<GLsizei>(Texture[Level].dimensions().y),
Format.External,
static_cast<GLsizei>(Texture[Level].size()),
Texture[Level].data());
}
glm::vec2 WindowSize(this->getWindowSize());
glBindTexture(GL_TEXTURE_2D, TextureName[texture::COLORBUFFER]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexStorage2D(GL_TEXTURE_2D, static_cast<GLint>(1), GL_RGBA8, static_cast<GLsizei>(WindowSize.x), static_cast<GLsizei>(WindowSize.y));
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
return Validated;
}
示例6: initTexture
bool initTexture()
{
gli::texture2D Texture(gli::loadStorageDDS(glf::DATA_DIRECTORY + TEXTURE_DIFFUSE));
glGenTextures(texture::MAX, &TextureName[0]);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, TextureName[texture::DIFFUSE]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
for(std::size_t Level = 0; Level < Texture.levels(); ++Level)
{
glTexImage2D(
GL_TEXTURE_2D,
GLint(Level),
GL_RGBA8UI,
GLsizei(Texture[Level].dimensions().x),
GLsizei(Texture[Level].dimensions().y),
0,
GL_BGR_INTEGER, GL_UNSIGNED_BYTE,
Texture[Level].data());
}
glBindTexture(GL_TEXTURE_2D, 0);
GLint MaxSampleMaskWords(0);
GLint MaxColorTextureSamples(0);
GLint MaxDepthTextureSamples(0);
GLint MaxIntegerSamples(0);
glGetIntegerv(GL_MAX_SAMPLE_MASK_WORDS, &MaxSampleMaskWords);
glGetIntegerv(GL_MAX_COLOR_TEXTURE_SAMPLES, &MaxColorTextureSamples);
glGetIntegerv(GL_MAX_DEPTH_TEXTURE_SAMPLES, &MaxDepthTextureSamples);
glGetIntegerv(GL_MAX_INTEGER_SAMPLES, &MaxIntegerSamples);
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, TextureName[texture::MULTISAMPLE]);
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, MaxIntegerSamples, GL_RGBA8UI, FRAMEBUFFER_SIZE.x, FRAMEBUFFER_SIZE.y, GL_TRUE);
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, 0);
glBindTexture(GL_TEXTURE_2D, TextureName[texture::COLORBUFFER]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8UI, FRAMEBUFFER_SIZE.x, FRAMEBUFFER_SIZE.y, 0, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, 0);
glBindTexture(GL_TEXTURE_2D, 0);
return glf::checkError("initTexture");
}
示例7: initTexture
bool initTexture()
{
GLint MaxSampleMaskWords(0);
GLint MaxColorTextureSamples(0);
GLint MaxDepthTextureSamples(0);
GLint MaxIntegerSamples(0);
glGetIntegerv(GL_MAX_SAMPLE_MASK_WORDS, &MaxSampleMaskWords);
glGetIntegerv(GL_MAX_COLOR_TEXTURE_SAMPLES, &MaxColorTextureSamples);
glGetIntegerv(GL_MAX_DEPTH_TEXTURE_SAMPLES, &MaxDepthTextureSamples);
glGetIntegerv(GL_MAX_INTEGER_SAMPLES, &MaxIntegerSamples);
gli::texture2d Texture(gli::load_dds((getDataDirectory() + TEXTURE_DIFFUSE).c_str()));
gli::gl GL(gli::gl::PROFILE_GL32);
glGenTextures(texture::MAX, &TextureName[0]);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, TextureName[texture::DIFFUSE]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 3);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
gli::gl::format const Format = GL.translate(gli::FORMAT_RGB8_UINT_PACK8, Texture.swizzles());
for(std::size_t Level = 0; Level < Texture.levels(); ++Level)
{
glTexImage2D(GL_TEXTURE_2D, GLint(Level),
Format.Internal,
GLsizei(Texture[Level].extent().x), GLsizei(Texture[Level].extent().y),
0,
Format.External, Format.Type,
Texture[Level].data());
}
glm::ivec2 WindowSize(this->getWindowSize());
glBindTexture(GL_TEXTURE_2D, TextureName[texture::RENDERBUFFER]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8UI,
WindowSize.x / FRAMEBUFFER_SIZE, WindowSize.y / FRAMEBUFFER_SIZE,
0, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, 0);
glBindTexture(GL_TEXTURE_2D, 0);
return this->checkError("initTexture");
}
示例8: snprintf
void Pager::addChild(Widget* newChild)
{
/* Do nothing if the new child is actually a page button: */
if(addingPageButton)
return;
/* Add the child to the list at the selected position: */
children.insert(children.begin()+nextChildIndex,newChild);
/* Create a new page button: */
char pbName[20];
snprintf(pbName,sizeof(pbName),"PageButton%u",nextPageIndex);
++nextPageIndex;
Button* newPageButton;
addingPageButton=true;
if(!nextPageName.empty())
{
newPageButton=new Button(pbName,this,nextPageName.c_str());
nextPageName="";
}
else
{
/* Create a default page button label: */
char pbLabel[20];
snprintf(pbLabel,sizeof(pbLabel),"Page %u",nextPageIndex);
newPageButton=new Button(pbName,this,pbLabel);
}
addingPageButton=false;
newPageButton->setBorderWidth(newPageButton->getBorderWidth()*0.5f);
newPageButton->getSelectCallbacks().add(this,&Pager::pageButtonSelectCallback);
/* Add the page button to the list: */
pageButtons.insert(pageButtons.begin()+nextChildIndex,newPageButton);
/* Select the just-added child: */
setCurrentChildIndex(nextChildIndex);
/* Prepare for the next page: */
nextChildIndex=GLint(children.size());
if(isManaged)
{
/* Try to resize the widget to accomodate the new child: */
parent->requestResize(this,calcNaturalSize());
}
}
示例9: initTexture2D
bool initTexture2D()
{
glGenTextures(1, &Texture2DName);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, Texture2DName);
gli::texture2D Texture(gli::loadStorageDDS(glf::DATA_DIRECTORY + TEXTURE_DIFFUSE_DXT5));
for(std::size_t Level = 0; Level < Texture.levels(); ++Level)
{
glCompressedTexImage2D(
GL_TEXTURE_2D,
GLint(Level),
GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
GLsizei(Texture[Level].dimensions().x),
GLsizei(Texture[Level].dimensions().y),
0,
GLsizei(Texture[Level].size()),
Texture[Level].data());
}
SwizzleR[viewport::V00] = GL_RED;
SwizzleG[viewport::V00] = GL_GREEN;
SwizzleB[viewport::V00] = GL_BLUE;
SwizzleA[viewport::V00] = GL_ALPHA;
SwizzleR[viewport::V10] = GL_BLUE;
SwizzleG[viewport::V10] = GL_GREEN;
SwizzleB[viewport::V10] = GL_RED;
SwizzleA[viewport::V10] = GL_ALPHA;
SwizzleR[viewport::V11] = GL_ONE;
SwizzleG[viewport::V11] = GL_GREEN;
SwizzleB[viewport::V11] = GL_BLUE;
SwizzleA[viewport::V11] = GL_ALPHA;
SwizzleR[viewport::V01] = GL_ZERO;
SwizzleG[viewport::V01] = GL_GREEN;
SwizzleB[viewport::V01] = GL_BLUE;
SwizzleA[viewport::V01] = GL_ALPHA;
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, 0);
return glf::checkError("initTexture2D");
}
示例10: initTexture2D
bool initTexture2D()
{
glGenTextures(1, &Texture2DName);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, Texture2DName);
gli::image Image = gli::import_as(TEXTURE_DIFFUSE_DXT5);
for(std::size_t Level = 0; Level < Image.levels(); ++Level)
{
glCompressedTexImage2D(
GL_TEXTURE_2D,
GLint(Level),
GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
GLsizei(Image[Level].dimensions().x),
GLsizei(Image[Level].dimensions().y),
0,
GLsizei(Image[Level].capacity()),
Image[Level].data());
}
SwizzleR[viewport::V00] = GL_RED;
SwizzleG[viewport::V00] = GL_GREEN;
SwizzleB[viewport::V00] = GL_BLUE;
SwizzleA[viewport::V00] = GL_ALPHA;
SwizzleR[viewport::V10] = GL_BLUE;
SwizzleG[viewport::V10] = GL_GREEN;
SwizzleB[viewport::V10] = GL_RED;
SwizzleA[viewport::V10] = GL_ALPHA;
SwizzleR[viewport::V11] = GL_ONE;
SwizzleG[viewport::V11] = GL_GREEN;
SwizzleB[viewport::V11] = GL_BLUE;
SwizzleA[viewport::V11] = GL_ALPHA;
SwizzleR[viewport::V01] = GL_ZERO;
SwizzleG[viewport::V01] = GL_GREEN;
SwizzleB[viewport::V01] = GL_BLUE;
SwizzleA[viewport::V01] = GL_ALPHA;
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, 0);
return glf::checkError("initTexture2D");
}
示例11: drawElementsInstancedBaseVertexBaseInstance
inline void drawElementsInstancedBaseVertexBaseInstance(
DrawElementsInstancedBaseVertexBaseInstanceMode mode,
GLsizei count,
DrawElementsInstancedBaseVertexBaseInstanceType type,
GLvoid *indices,
GLsizei primcount,
GLint basevertex,
GLuint baseinstance) {
glDrawElementsInstancedBaseVertexBaseInstance(
GLenum(mode),
GLsizei(count),
GLenum(type),
(GLvoid*)(indices),
GLsizei(primcount),
GLint(basevertex),
GLuint(baseinstance));
}
示例12: glCompileShaderFromFile
void glCompileShaderFromFile(GLhandleARB shaderObject,const char* shaderSourceFileName,IO::File& shaderSourceFile)
{
/* Read the entire shader source: */
size_t shaderAllocSize=8192;
GLcharARB* shaderSource=new GLcharARB[shaderAllocSize];
size_t shaderSourceLength=0;
while(!shaderSourceFile.eof())
{
/* Make room in the shader source buffer: */
if(shaderSourceLength==shaderAllocSize)
{
shaderAllocSize=(shaderAllocSize*3)/2;
GLcharARB* newShaderSource=new GLcharARB[shaderAllocSize];
memcpy(newShaderSource,shaderSource,shaderSourceLength);
delete[] shaderSource;
shaderSource=newShaderSource;
}
/* Read more data from the file: */
size_t numBytesRead=shaderSourceFile.readUpTo(shaderSource+shaderSourceLength,shaderAllocSize-shaderSourceLength);
shaderSourceLength+=numBytesRead;
}
/* Upload the shader source into the shader object: */
const GLcharARB* ss=shaderSource;
GLint ssl=GLint(shaderSourceLength);
glShaderSourceARB(shaderObject,1,&ss,&ssl);
delete[] shaderSource;
/* Compile the shader source: */
glCompileShaderARB(shaderObject);
/* Check if the shader compiled successfully: */
GLint compileStatus;
glGetObjectParameterivARB(shaderObject,GL_OBJECT_COMPILE_STATUS_ARB,&compileStatus);
if(!compileStatus)
{
/* Get some more detailed information: */
GLcharARB compileLogBuffer[2048];
GLsizei compileLogSize;
glGetInfoLogARB(shaderObject,sizeof(compileLogBuffer),&compileLogSize,compileLogBuffer);
/* Signal an error: */
Misc::throwStdErr("glCompileShaderFromFile: Error \"%s\" while compiling shader %s",compileLogBuffer,shaderSourceFileName);
}
}
示例13: initBuffer
bool initBuffer()
{
glGenBuffers(buffer::MAX, BufferName);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, BufferName[buffer::ELEMENT]);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, ElementSize, ElementData, GL_STATIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glBindBuffer(GL_ARRAY_BUFFER, BufferName[buffer::POSITION_INPUT]);
glBufferData(GL_ARRAY_BUFFER, PositionSize * 2, NULL, GL_STATIC_DRAW);
glBufferSubData(GL_ARRAY_BUFFER, 0, PositionSize, PositionData);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ARRAY_BUFFER, BufferName[buffer::TEXCOORD_INPUT]);
glBufferData(GL_ARRAY_BUFFER, TexcoordSize * 2, TexcoordData, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ARRAY_BUFFER, BufferName[buffer::COLOR_INPUT]);
glBufferData(GL_ARRAY_BUFFER, ColorSize * 2, ColorData, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ARRAY_BUFFER, BufferName[buffer::POSITION_OUTPUT]);
glBufferData(GL_ARRAY_BUFFER, PositionSize * 2, NULL, GL_STATIC_COPY);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ARRAY_BUFFER, BufferName[buffer::TEXCOORD_OUTPUT]);
glBufferData(GL_ARRAY_BUFFER, TexcoordSize * 2, NULL, GL_STATIC_COPY);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ARRAY_BUFFER, BufferName[buffer::COLOR_OUTPUT]);
glBufferData(GL_ARRAY_BUFFER, ColorSize * 2, NULL, GL_STATIC_COPY);
glBindBuffer(GL_ARRAY_BUFFER, 0);
GLint UniformBufferOffset(0);
glGetIntegerv(
GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT,
&UniformBufferOffset);
GLint UniformBlockSize = glm::max(GLint(sizeof(glm::mat4)), UniformBufferOffset);
glBindBuffer(GL_UNIFORM_BUFFER, BufferName[buffer::TRANSFORM]);
glBufferData(GL_UNIFORM_BUFFER, UniformBlockSize, NULL, GL_DYNAMIC_DRAW);
glBindBuffer(GL_UNIFORM_BUFFER, 0);
return true;
}
示例14: flags
void VertexData::use()
{
uint32_t flags(0);
for(auto& element : _vertexStreams)
{
flags = flags | (1 << element.second._stream._semantic);
}
GL::enableVertexAttribs(flags);
for(auto& element : _vertexStreams)
{
//glEnableVertexAttribArray((GLint)element.second._stream._semantic);
glBindBuffer(GL_ARRAY_BUFFER, element.second._buffer->getVBO());
glVertexAttribPointer(GLint(element.second._stream._semantic),element.second._stream._size,
element.second._stream._type,element.second._stream._normalize, element.second._buffer->getSizePerVertex(), (GLvoid*)element.second._stream._offset);
}
}
示例15: initBuffer
bool initBuffer()
{
GLint UniformBufferOffset(0);
glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &UniformBufferOffset);
GLint UniformBlockSize = glm::max(GLint(sizeof(glm::mat4)), UniformBufferOffset);
glm::vec4 Material0(1.0f, 0.5f, 0.0f, 1.0f);
glm::vec4 Material1(0.0f, 0.5f, 1.0f, 1.0f);
glCreateBuffers(buffer::MAX, &BufferName[0]);
glNamedBufferStorage(BufferName[buffer::VERTEX], VertexSize, VertexData, 0);
glNamedBufferStorage(BufferName[buffer::ELEMENT], ElementSize, ElementData, 0);
glNamedBufferStorage(BufferName[buffer::TRANSFORM], UniformBlockSize, nullptr, GL_MAP_WRITE_BIT);
glNamedBufferStorage(BufferName[buffer::MATERIAL0], sizeof(glm::vec4), &Material0[0], 0);
glNamedBufferStorage(BufferName[buffer::MATERIAL1], sizeof(glm::vec4), &Material1[0], 0);
return true;
}