1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-16 10:08:36 +03:00
occt/src/OpenGl/OpenGl_PointSprite.cxx
kgv cc8cbabe5c 0028912: Visualization, TKOpenGl - multi-texture support
Graphic3d_AspectFillArea3d now stores array of textures.
Graphic3d_TextureParams stores texture unit for mapping texture.

OpenGl_Context::BindTextures() - context now manages the set of active textures.
Related code has been removed from OpenGl_Workspace.

OpenGl_Sampler has been extended to hold texture parameters structure.
OpenGl_Texture now holds OpenGl_Sampler instance as class field.
OpenGl_Texture inherits new class OpenGl_NamedResource and holds
texture identifier used for sharing resource in OpenGl_Context.

OpenGl_RaytraceGeometry now creates bindless textures taking
Sampler object directly from OpenGl_Texture.
OpenGl_Context::BindTextures() automatically recreates immutable
Sampler Object on texture parameters change.

Declared new structure OpenGl_ArbSamplerObject for platform-neutral
usage of related functionality.
Related functions are now loaded within OpenGL ES 3.0+.

Declarations.glsl - occActiveSampler has been renamed to occSampler0
with aliases occSamplerBaseColor (main) and occActiveSampler (for compatibility).
Additional texture samplers should be declared explicitly
within specific GLSL program as occSampler1, occSampler2, etc.

AIS_Shape and AIS_ColoredShape now computes Shaded presentation
with UV coordinates if texture mapping is enabled in Drawer.

vshaderprog now accepts Shader source code as parameter.
2017-07-21 12:10:41 +03:00

96 lines
3.3 KiB
C++
Executable File

// Created by: Kirill GAVRILOV
// Copyright (c) 2013-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#include <OpenGl_PointSprite.hxx>
#include <Graphic3d_TextureParams.hxx>
#include <OpenGl_Context.hxx>
#include <OpenGl_Sampler.hxx>
#include <Standard_Assert.hxx>
#include <Image_PixMap.hxx>
IMPLEMENT_STANDARD_RTTIEXT(OpenGl_PointSprite,OpenGl_Texture)
// =======================================================================
// function : OpenGl_PointSprite
// purpose :
// =======================================================================
OpenGl_PointSprite::OpenGl_PointSprite (const TCollection_AsciiString& theResourceId)
: OpenGl_Texture (theResourceId, Handle(Graphic3d_TextureParams)()),
myBitmapList (0)
{
//mySampler->Parameters()->SetFilter (Graphic3d_TOTF_NEAREST);
mySampler->Parameters()->SetModulate (Standard_False);
mySampler->Parameters()->SetGenMode (Graphic3d_TOTM_SPRITE,
Graphic3d_Vec4 (0.0f, 0.0f, 0.0f, 0.0f),
Graphic3d_Vec4 (0.0f, 0.0f, 0.0f, 0.0f));
}
// =======================================================================
// function : ~OpenGl_PointSprite
// purpose :
// =======================================================================
OpenGl_PointSprite::~OpenGl_PointSprite()
{
Release (NULL);
}
// =======================================================================
// function : Release
// purpose :
// =======================================================================
void OpenGl_PointSprite::Release (OpenGl_Context* theGlCtx)
{
if (myBitmapList != 0)
{
Standard_ASSERT_RETURN (theGlCtx != NULL,
"OpenGl_PointSprite destroyed without GL context! Possible GPU memory leakage...",);
if (theGlCtx->IsValid())
{
#if !defined(GL_ES_VERSION_2_0)
glDeleteLists (myBitmapList, 1);
#endif
}
myBitmapList = 0;
}
OpenGl_Texture::Release (theGlCtx);
}
// =======================================================================
// function : SetDisplayList
// purpose :
// =======================================================================
void OpenGl_PointSprite::SetDisplayList (const Handle(OpenGl_Context)& theCtx,
const GLuint theBitmapList)
{
Release (theCtx.operator->());
myBitmapList = theBitmapList;
}
// =======================================================================
// function : DrawBitmap
// purpose :
// =======================================================================
void OpenGl_PointSprite::DrawBitmap (const Handle(OpenGl_Context)& ) const
{
if (myBitmapList != 0)
{
#if !defined(GL_ES_VERSION_2_0)
glCallList (myBitmapList);
#endif
}
}