本文整理汇总了C++中GLsizei函数的典型用法代码示例。如果您正苦于以下问题:C++ GLsizei函数的具体用法?C++ GLsizei怎么用?C++ GLsizei使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GLsizei函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: set_active
void GL1GraphicContextProvider::set_viewport(const Rectf &viewport)
{
set_active();
glViewport(
GLsizei(viewport.left),
GLsizei(viewport.top),
GLsizei(viewport.right - viewport.left),
GLsizei(viewport.bottom - viewport.top));
}
开发者ID:ArtHome12,项目名称:ClanLib,代码行数:9,代码来源:gl1_graphic_context_provider.cpp
示例2: initTexture
bool initTexture()
{
glGenTextures(texture::MAX, TextureName);
gli::texture2D Texture(gli::loadStorageDDS(glf::DATA_DIRECTORY + TEXTURE_DIFFUSE));
assert(!Texture.empty());
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, TextureName[texture::DIFFUSE]);
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);
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_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexStorage2D(GL_TEXTURE_2D, GLint(Texture.levels()), GL_RGBA8, GLsizei(Texture[0].dimensions().x), GLsizei(Texture[0].dimensions().y));
for(gli::texture2D::size_type Level = 0; Level < Texture.levels(); ++Level)
{
glTexSubImage2D(
GL_TEXTURE_2D,
GLint(Level),
0, 0,
GLsizei(Texture[Level].dimensions().x),
GLsizei(Texture[Level].dimensions().y),
GL_BGR, GL_UNSIGNED_BYTE,
Texture[Level].data());
}
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
GLint TextureBufferOffset(0);
glGetIntegerv(
GL_TEXTURE_BUFFER_OFFSET_ALIGNMENT,
&TextureBufferOffset);
GLint TextureBufferRange = glm::max(GLint(PositionSize), TextureBufferOffset);
glBindTexture(GL_TEXTURE_BUFFER, TextureName[texture::POSITION_INPUT]);
glTexBufferRange(GL_TEXTURE_BUFFER, GL_RGBA32F, BufferName[buffer::POSITION_INPUT], 0, TextureBufferRange);
glBindTexture(GL_TEXTURE_BUFFER, TextureName[texture::TEXCOORD_INPUT]);
glTexBufferRange(GL_TEXTURE_BUFFER, GL_RGBA32F, BufferName[buffer::TEXCOORD_INPUT], 0, TextureBufferRange);
glBindTexture(GL_TEXTURE_BUFFER, TextureName[texture::COLOR_INPUT]);
glTexBufferRange(GL_TEXTURE_BUFFER, GL_RGBA32F, BufferName[buffer::COLOR_INPUT], 0, TextureBufferRange);
glBindTexture(GL_TEXTURE_BUFFER, TextureName[texture::POSITION_OUTPUT]);
glTexBufferRange(GL_TEXTURE_BUFFER, GL_RGBA32F, BufferName[buffer::POSITION_OUTPUT], 0, TextureBufferRange);
glBindTexture(GL_TEXTURE_BUFFER, TextureName[texture::TEXCOORD_OUTPUT]);
glTexBufferRange(GL_TEXTURE_BUFFER, GL_RGBA32F, BufferName[buffer::TEXCOORD_OUTPUT], 0, TextureBufferRange);
glBindTexture(GL_TEXTURE_BUFFER, TextureName[texture::COLOR_OUTPUT]);
glTexBufferRange(GL_TEXTURE_BUFFER, GL_RGBA32F, BufferName[buffer::COLOR_OUTPUT], 0, TextureBufferRange);
glBindTexture(GL_TEXTURE_BUFFER, 0);
return true;
}
开发者ID:alexa-infra,项目名称:ogl-samples,代码行数:56,代码来源:gl-430-program-compute-image.cpp
示例3: adjustViewport
void adjustViewport()
{
float scaleX, scaleY;
int winWidth = glutGet(GLUT_WINDOW_WIDTH);
int winHeight = glutGet(GLUT_WINDOW_HEIGHT);
getAspectRatioAdjustment(XY_ASPECT, float(winWidth) / float(winHeight), &scaleX, &scaleY);
GLsizei vpWidth = GLsizei(winWidth * scaleX);
GLsizei vpHeight = GLsizei(winHeight * scaleY);
glViewport((winWidth-vpWidth)/2, (winHeight-vpHeight)/2, vpWidth, vpHeight);
}
开发者ID:avi-jit,项目名称:kinect-ultra,代码行数:10,代码来源:util.cpp
示例4: png_set_read_fn
void ogl::texture::load_png(const void *buf, size_t len, std::vector<GLubyte>& p)
{
// Initialize all PNG import data structures.
png_structp rp = 0;
png_infop ip = 0;
png_bytep *bp = 0;
if (!(rp = png_create_read_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0)))
throw std::runtime_error("Failure creating PNG read structure");
if (!(ip = png_create_info_struct(rp)))
throw std::runtime_error("Failure creating PNG info structure");
// Initialize the user-defined IO structure.
struct png_user_io user;
user.buf = (png_bytep) buf;
user.len = (png_size_t) len;
png_set_read_fn(rp, &user, png_user_read);
// Enable the default PNG error handler.
if (setjmp(png_jmpbuf(rp)) == 0)
{
// Read the PNG header.
png_read_png(rp, ip, PNG_TRANSFORM_EXPAND |
PNG_TRANSFORM_PACKING |
PNG_TRANSFORM_STRIP_16 |
PNG_TRANSFORM_SWAP_ENDIAN, 0);
// Extract image properties.
w = GLsizei(png_get_image_width (rp, ip));
h = GLsizei(png_get_image_height(rp, ip));
c = GLsizei(png_get_channels (rp, ip));
p.resize(w * h * c);
// Read the pixel data.
if ((bp = png_get_rows(rp, ip)))
for (GLsizei i = 0, j = h - 1; i < h; ++i, --j)
memcpy(&p[w * c * i], bp[j], (w * c));
}
// Release all resources.
png_destroy_read_struct(&rp, &ip, 0);
}
开发者ID:rlk,项目名称:thumb,代码行数:54,代码来源:ogl-texture.cpp
示例5: initTexture
bool initTexture()
{
bool Validated(true);
gli::texture2d Texture(gli::load_dds((getDataDirectory() + TEXTURE_DIFFUSE).c_str()));
assert(!Texture.empty());
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
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, GLint(Texture.levels() - 1));
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
for(std::size_t Level = 0; Level < Texture.levels(); ++Level)
{
glCompressedTexImage2D(GL_TEXTURE_2D,
GLint(Level),
GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
GLsizei(Texture[Level].extent().x),
GLsizei(Texture[Level].extent().y),
0,
GLsizei(Texture[Level].size()),
Texture[Level].data());
}
glm::ivec2 WindowSize(this->getWindowSize() * this->FramebufferScale);
glActiveTexture(GL_TEXTURE0);
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_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, GLint(0), GL_RGBA8, GLsizei(WindowSize.x), GLsizei(WindowSize.y), 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, TextureName[texture::DEPTHBUFFER]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
glTexImage2D(GL_TEXTURE_2D, GLint(0), GL_DEPTH_COMPONENT24, GLsizei(WindowSize.x), GLsizei(WindowSize.y), 0, GL_DEPTH_COMPONENT, GL_FLOAT, nullptr);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, TextureName[texture::STENCILBUFFER]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
glTexImage2D(GL_TEXTURE_2D, GLint(0), GL_STENCIL_INDEX8, GLsizei(WindowSize.x), GLsizei(WindowSize.y), 0, GL_STENCIL_INDEX, GL_UNSIGNED_BYTE, nullptr);
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
return Validated;
}
开发者ID:byhj,项目名称:ogl-samples,代码行数:58,代码来源:gl-440-fbo-depth-stencil.cpp
示例6: initTexture
bool initTexture()
{
bool Validated(true);
gli::gl GL(gli::gl::PROFILE_GL32);
gli::texture2d Texture(gli::load_dds((getDataDirectory() + TEXTURE_DIFFUSE).c_str()));
assert(!Texture.empty());
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
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, GLint(Texture.levels() - 1));
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
gli::gl::format const Format = GL.translate(Texture.format(), Texture.swizzles());
for (gli::texture2d::size_type Level = 0; Level < Texture.levels(); ++Level)
{
glTexImage2D(GL_TEXTURE_2D, static_cast<GLint>(Level),
Format.Internal,
static_cast<GLsizei>(Texture[Level].extent().x), static_cast<GLsizei>(Texture[Level].extent().y), 0,
Format.External, Format.Type,
Texture[Level].data());
}
glm::ivec2 WindowSize(this->getWindowSize() * this->FramebufferScale);
glActiveTexture(GL_TEXTURE0);
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_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, GLint(0), GL_RGBA8, GLsizei(WindowSize.x), GLsizei(WindowSize.y), 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, TextureName[texture::RENDERBUFFER]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
glTexImage2D(GL_TEXTURE_2D, GLint(0), GL_DEPTH_COMPONENT24, GLsizei(WindowSize.x), GLsizei(WindowSize.y), 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, NULL);
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
return Validated;
}
开发者ID:g-truc,项目名称:ogl-samples,代码行数:51,代码来源:gl-320-fbo-readpixels-async.cpp
示例7: initTexture
bool initTexture()
{
bool Validated(true);
gli::texture2D Texture(gli::loadStorageDDS(glf::DATA_DIRECTORY + TEXTURE_DIFFUSE));
assert(!Texture.empty());
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glBindBuffer(GL_PIXEL_PACK_BUFFER, BufferName[buffer::VERTEX]);
glGenTextures(1, &TextureName);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, TextureName);
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);
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_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexStorage2D(GL_TEXTURE_2D,
GLint(Texture.levels()),
gli::internal_format(Texture.format()),
GLsizei(Texture.dimensions().x), GLsizei(Texture.dimensions().y));
for(gli::texture2D::size_type Level(0); Level < Texture.levels(); ++Level)
{
glTexSubImage2D(
GL_TEXTURE_2D,
GLint(Level),
0, 0,
GLsizei(Texture[Level].dimensions().x),
GLsizei(Texture[Level].dimensions().y),
gli::external_format(Texture.format()),
gli::type_format(Texture.format()),
Texture[Level].data());
}
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
// Query the texture handle and make the texture resident
TextureHandle = glGetTextureHandleNV(TextureName);
glMakeTextureHandleResidentNV(TextureHandle);
glBindTexture(GL_TEXTURE_2D, 0);
return Validated;
}
开发者ID:Daft-Freak,项目名称:vogl,代码行数:51,代码来源:gl-420-texture-bindless-nv.cpp
示例8: initTexture
bool initTexture()
{
bool Validated(true);
gli::texture2d Texture(gli::load_dds((getDataDirectory() + TEXTURE_DIFFUSE).c_str()));
assert(!Texture.empty());
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
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, 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_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
for(std::size_t Level = 0; Level < Texture.levels(); ++Level)
{
glCompressedTexImage2D(GL_TEXTURE_2D,
GLint(Level),
GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
GLsizei(Texture[Level].extent().x),
GLsizei(Texture[Level].extent().y),
0,
GLsizei(Texture[Level].size()),
Texture[Level].data());
}
glm::ivec2 WindowSize(this->getWindowSize());
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, TextureName[texture::MULTISAMPLE]);
this->checkError("initTexture 1");
glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_BASE_LEVEL, 0);
glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MAX_LEVEL, 0);
this->checkError("initTexture 2");
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 4, GL_DEPTH_COMPONENT24, GLsizei(WindowSize.x), GLsizei(WindowSize.y), GL_TRUE);
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
return Validated && this->checkError("initTexture");
}
开发者ID:byhj,项目名称:ogl-samples,代码行数:50,代码来源:gl-320-fbo-depth-multisample.cpp
示例9: GL_RET_CALL
// ************************************************************************* //
ScissorRect::ScissorRect( float _x, float _y, float _w, float _h )
{
// Store old state to restore it later
m_wasEnabled = GL_RET_CALL(glIsEnabled, GL_SCISSOR_TEST) == GL_TRUE;
GL_CALL(glGetIntegerv, GL_SCISSOR_BOX, m_previousRect); // TODO: Avoid glgetter
IVec2 size = Device::GetBackbufferSize();
// Translate coordinates to absolute pixel coordinates and set directly.
GL_CALL(glScissor, GLint((_x * 0.5f + 0.5f) * size[0]),
GLint((_y * 0.5f + 0.5f) * size[1]),
GLsizei(_w * 0.5f * size[0]),
GLsizei(_h * 0.5f * size[1]) );
GL_CALL(glEnable, GL_SCISSOR_TEST);
}
开发者ID:Jojendersie,项目名称:Monolith,代码行数:16,代码来源:scissor.cpp
示例10: drawElementsInstancedBaseVertex
inline void drawElementsInstancedBaseVertex(
DrawElementsInstancedBaseVertexMode mode,
GLsizei count,
DrawElementsInstancedBaseVertexType type,
GLvoid *indices,
GLsizei primcount,
GLint basevertex) {
glDrawElementsInstancedBaseVertex(
GLenum(mode),
GLsizei(count),
GLenum(type),
(GLvoid*)(indices),
GLsizei(primcount),
GLint(basevertex));
}
开发者ID:ngzHappy,项目名称:OpenGL45Book,代码行数:15,代码来源:DrawFunctions.hpp
示例11: render
bool render()
{
glm::vec2 WindowSize(this->getWindowSize());
{
glBindBuffer(GL_UNIFORM_BUFFER, BufferName[buffer::TRANSFORM]);
glm::mat4* Pointer = (glm::mat4*)glMapBufferRange(
GL_UNIFORM_BUFFER, 0, sizeof(glm::mat4),
GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
glm::mat4 Projection = glm::perspective(glm::pi<float>() * 0.25f, WindowSize.x * 0.5f / WindowSize.y, 0.1f, 100.0f);
glm::mat4 Model = glm::mat4(1.0f);
*Pointer = Projection * this->view() * Model;
// Make sure the uniform buffer is uploaded
glUnmapBuffer(GL_UNIFORM_BUFFER);
}
float Depth(1.0f);
glClearBufferfv(GL_DEPTH, 0, &Depth);
glClearBufferfv(GL_COLOR, 0, &glm::vec4(1.0f, 0.5f, 0.0f, 1.0f)[0]);
glActiveTexture(GL_TEXTURE0 + sementics::sampler::RGB8);
glBindTexture(GL_TEXTURE_2D, TextureName[texture::RGB8]);
glActiveTexture(GL_TEXTURE0 + sementics::sampler::DXT1);
glBindTexture(GL_TEXTURE_2D, TextureName[texture::DXT1]);
glBindProgramPipeline(PipelineName);
glBindBufferBase(GL_UNIFORM_BUFFER, semantic::uniform::TRANSFORM0, BufferName[buffer::TRANSFORM]);
glBindVertexArray(VertexArrayName);
glUseProgram(ProgramName);
std::vector<GLuint> Index(2);
Index[0] = sementics::sampling::RGB8;
Index[1] = sementics::sampling::DXT1;
glViewportIndexedf(0, 0, 0, GLfloat(WindowSize.x) / 2.0f, GLfloat(WindowSize.y));
glUniformSubroutinesuiv(GL_FRAGMENT_SHADER, GLsizei(1), &Index[0]);
glDrawElementsInstancedBaseVertex(GL_TRIANGLES, ElementCount, GL_UNSIGNED_INT, nullptr, 1, 0);
glViewportIndexedf(0, GLfloat(WindowSize.x) / 2.0f, 0, GLfloat(WindowSize.x) / 2.0f, GLfloat(WindowSize.y));
glUniformSubroutinesuiv(GL_FRAGMENT_SHADER, GLsizei(1), &Index[1]);
glDrawElementsInstancedBaseVertex(GL_TRIANGLES, ElementCount, GL_UNSIGNED_INT, nullptr, 1, 0);
return true;
}
开发者ID:h3rb,项目名称:ogl-samples,代码行数:48,代码来源:gl-430-program-subroutine.cpp
示例12: glBindVertexArray
void ScreenText::draw(GLContext* context)
{
if(!usedSize_)
return;
#ifdef SCIGMA_USE_OPENGL_3_2
glBindVertexArray(vertexArray_);
#else
glBindBuffer(GL_ARRAY_BUFFER,glBuffer_);
prepare_attributes();
#endif
glUniform4fv(fColorLocation_,1,fColor_);
glUniform4fv(bColorLocation_,1,bColor_);
glUniform2fv(offsetLocation_,1,offset_);
switch(screenAnchor_)
{
case SCREEN_ANCHOR_BOTTOM_LEFT:
glUniform4f(screenAnchorLocation_,-1,-1,0,0);break;
case SCREEN_ANCHOR_BOTTOM_RIGHT:
glUniform4f(screenAnchorLocation_,1,-1,0,0);break;
case SCREEN_ANCHOR_TOP_RIGHT:
glUniform4f(screenAnchorLocation_,1,1,0,0);;break;
case SCREEN_ANCHOR_TOP_LEFT:
glUniform4f(screenAnchorLocation_,-1,1,0,0);break;
}
glBindTexture(GL_TEXTURE_2D,font_.textureID);
glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
glDrawArrays(GL_TRIANGLES, 0, GLsizei(usedSize_/4));
GLERR;
}
开发者ID:rhoelzel,项目名称:scigma,代码行数:34,代码来源:screentext.cpp
示例13: drawFillCircle
// 塗り潰し円
// center_x, center_y 円の中心位置
// radius_x, radius_y 半径(横と縦)
// division 円の分割数(数値が大きいと滑らかな円になる)
// color 色
void drawFillCircle(const float center_x, const float center_y,
const float radius_x, const float radius_y,
const int division,
const Color& color) {
// 色を設定
color.setToGl();
// 頂点データを生成
std::vector<GLfloat> vtx;
vtx.reserve(division * 2);
vtx.push_back(center_x);
vtx.push_back(center_y);
for (int i = 0; i <= division; ++i) {
float r = (M_PI * 2.0 * i) / division;
// 反時計回りが表面となる
vtx.push_back(radius_x * -std::sin(r) + center_x);
vtx.push_back(radius_y * std::cos(r) + center_y);
}
glVertexPointer(2, GL_FLOAT, 0, &vtx[0]);
glEnableClientState(GL_VERTEX_ARRAY);
glDrawArrays(GL_TRIANGLE_FAN, 0, GLsizei(vtx.size() / 2));
glDisableClientState(GL_VERTEX_ARRAY);
}
开发者ID:tek-nishi,项目名称:FadeTest,代码行数:33,代码来源:graph.cpp
示例14: drawCircle
// 円を描画
// center_x, center_y 円の中心位置
// radius_x, radius_y 半径(横と縦)
// division 円の分割数(数値が大きいと滑らかな円になる)
// line_width 線幅
// color 色
void drawCircle(const float center_x, const float center_y,
const float radius_x, const float radius_y,
const int division,
const float line_width,
const Color& color) {
// 線分の太さを指示
glLineWidth(line_width);
// 色を設定
color.setToGl();
// 頂点データを生成
std::vector<GLfloat> vtx;
vtx.reserve(division * 2);
for (int i = 0; i < division; ++i) {
float r = (M_PI * 2.0 * i) / division;
vtx.push_back(radius_x * std::sin(r) + center_x);
vtx.push_back(radius_y * std::cos(r) + center_y);
}
glVertexPointer(2, GL_FLOAT, 0, &vtx[0]);
glEnableClientState(GL_VERTEX_ARRAY);
glDrawArrays(GL_LINE_LOOP, 0, GLsizei(vtx.size() / 2));
glDisableClientState(GL_VERTEX_ARRAY);
}
开发者ID:tek-nishi,项目名称:FadeTest,代码行数:35,代码来源:graph.cpp
示例15: PrintShaderWarning
bool PickingShaderForPointCloud::PrepareBinding(const Geometry &geometry,
const RenderOption &option, const ViewControl &view,
std::vector<Eigen::Vector3f> &points,
std::vector<float> &indices)
{
if (geometry.GetGeometryType() !=
Geometry::GeometryType::PointCloud) {
PrintShaderWarning("Rendering type is not PointCloud.");
return false;
}
const PointCloud &pointcloud = (const PointCloud &)geometry;
if (pointcloud.HasPoints() == false) {
PrintShaderWarning("Binding failed with empty pointcloud.");
return false;
}
points.resize(pointcloud.points_.size());
indices.resize(pointcloud.points_.size());
for (size_t i = 0; i < pointcloud.points_.size(); i++) {
const auto &point = pointcloud.points_[i];
points[i] = point.cast<float>();
indices[i] = (float)i;
}
draw_arrays_mode_ = GL_POINTS;
draw_arrays_size_ = GLsizei(points.size());
return true;
}
开发者ID:rvbust,项目名称:Open3D,代码行数:26,代码来源:PickingShader.cpp
示例16: render
bool render()
{
glm::vec2 WindowSize(this->getWindowSize());
{
float Aspect = (WindowSize.x * 0.33f) / (WindowSize.y * 0.50f);
glm::mat4 Projection = glm::perspective(glm::pi<float>() * 0.25f, Aspect, 0.1f, 100.0f);
glm::mat4 MVP = Projection * this->view() * glm::mat4(1.0f);
*UniformPointer = MVP;
}
glClearBufferfv(GL_COLOR, 0, &glm::vec4(1.0f, 0.5f, 0.0f, 1.0f)[0]);
glBindProgramPipeline(PipelineName);
glBindBuffersBase(GL_UNIFORM_BUFFER, semantic::uniform::TRANSFORM0, 1, &BufferName[buffer::TRANSFORM]);
glBindTextures(semantic::sampler::DIFFUSE, 1, &TextureName);
glBindVertexArray(VertexArrayName);
glBindVertexBuffer(semantic::buffer::STATIC, BufferName[buffer::VERTEX], 0, GLsizei(sizeof(vertex)));
for(std::size_t Index = 0; Index < viewport::MAX; ++Index)
{
glViewportIndexedf(0,
Viewport[Index].x,
Viewport[Index].y,
Viewport[Index].z,
Viewport[Index].w);
glBindSamplers(0, 1, &SamplerName[Index]);
glDrawArraysInstanced(GL_TRIANGLES, 0, VertexCount, 1);
}
return true;
}
开发者ID:h3rb,项目名称:ogl-samples,代码行数:34,代码来源:gl-440-sampler-wrap.cpp
示例17: processor
void NVprPathRendererState::validate()
{
if (valid) {
return;
}
NVprPathCacheProcessor processor(owner, path, fill_rule);
owner->processSegments(processor);
if (owner->style.do_stroke) {
glPathParameteriNV(path, GL_PATH_JOIN_STYLE_NV, lineJoinConverter(owner));
glPathParameteriNV(path, GL_PATH_END_CAPS_NV, lineCapConverter(owner));
glPathParameterfNV(path, GL_PATH_STROKE_WIDTH_NV, owner->style.stroke_width);
glPathParameterfNV(path, GL_PATH_MITER_LIMIT_NV, owner->style.miter_limit);
if (owner->style.dash_array.size()) {
glPathDashArrayNV(path, GLsizei(owner->style.dash_array.size()), &owner->style.dash_array[0]);
glPathParameteriNV(path, GL_PATH_DASH_CAPS_NV, lineCapConverter(owner));
glPathParameterfNV(path, GL_PATH_DASH_OFFSET_NV, owner->style.dash_offset);
GLenum dash_offset_reset = (owner->style.dash_phase == PathStyle::MOVETO_RESETS)
? GL_MOVE_TO_RESETS_NV
: GL_MOVE_TO_CONTINUES_NV;
glPathParameteriNV(path, GL_PATH_DASH_OFFSET_RESET_NV, dash_offset_reset);
} else {
glPathDashArrayNV(path, 0, NULL);
}
}
valid = true;
}
开发者ID:ghub,项目名称:NVprSDK,代码行数:27,代码来源:renderer_nvpr_path.cpp
示例18: initDataItem
void Raycaster::initDataItem(Raycaster::DataItem* dataItem) const
{
/* Calculate the appropriate volume texture's size: */
if(dataItem->hasNPOTDTextures)
{
/* Use the data size directly: */
for(int i=0;i<3;++i)
dataItem->textureSize[i]=dataSize[i];
}
else
{
/* Pad to the next power of two: */
for(int i=0;i<3;++i)
for(dataItem->textureSize[i]=1;dataItem->textureSize[i]<GLsizei(dataSize[i]);dataItem->textureSize[i]<<=1)
;
}
/* Calculate the texture coordinate box for trilinear interpolation and the transformation from model space to data space: */
Point tcMin,tcMax;
for(int i=0;i<3;++i)
{
tcMin[i]=Scalar(0.5)/Scalar(dataItem->textureSize[i]);
tcMax[i]=(Scalar(dataSize[i])-Scalar(0.5))/Scalar(dataItem->textureSize[i]);
Scalar scale=(tcMax[i]-tcMin[i])/domain.getSize(i);
dataItem->mcScale[i]=GLfloat(scale);
dataItem->mcOffset[i]=GLfloat(tcMin[i]-domain.min[i]*scale);
}
dataItem->texCoords=Box(tcMin,tcMax);
}
开发者ID:VisualIdeation,项目名称:ATR-Vessel,代码行数:29,代码来源:Raycaster.cpp
示例19: 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;
}
开发者ID:g-truc,项目名称:ogl-samples,代码行数:16,代码来源:gl-500-conservative-raster-nv.cpp
示例20: SetBounds
/// @brief Sets the render bounds
/// @param fX Screen x coordinate, in [0, 1]
/// @param fY Screen y coordinate, in [0, 1]
/// @param fW Screen width, in [0, 1]
/// @param fH Screen height, in [0, 1]
/// @return 0 on failure, non-0 for success
/// @note Tested
int SetBounds (float fX, float fY, float fW, float fH)
{
Graphics::Main & g = Graphics::Main::Get();
fX *= g.mResW;
fY = (1.0f - fY - fH) * g.mResH;
fW *= g.mResW;
fH *= g.mResH;
fX = floorf(fX), fY = floorf(fY);
fW = ceilf(fW), fH = ceilf(fH);
glScissor(GLint(fX), GLint(fY), GLsizei(fW), GLsizei(fH));
return 1;
}
开发者ID:ggcrunchy,项目名称:ui-edit-v2,代码行数:23,代码来源:Graphics.cpp
注:本文中的GLsizei函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论