v_sim.GlExt

g GObject.Object GObject.Object v_sim.GlExt v_sim.GlExt GObject.Object->v_sim.GlExt

Subclasses:

v_sim.GlExtAxes, v_sim.GlExtBg, v_sim.GlExtBox, v_sim.GlExtFrame, v_sim.GlExtInfos, v_sim.GlExtMaps, v_sim.GlExtMarks, v_sim.GlExtNodeVectors, v_sim.GlExtNodes, v_sim.GlExtPairs, v_sim.GlExtPaths, v_sim.GlExtPlanes, v_sim.GlExtScale, v_sim.GlExtSurfaces

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

addBuffers (number)

addTextures (number)

adjustTextureDimensions (texId, width, height)

blitLabels ()

blitLabelsOnScreen ()

blitTextureAt (texId, at, offset)

blitTextureOnScreen (texId, at, hAlign, vAlign)

bookBuffers (number)

bookTextures (number)

call (globals)

callText (globals)

clearBuffers ()

clearLabels ()

cullFace (status)

draw ()

getActive ()

getBufferDimension ()

getGlBuffer (id)

getGlContext ()

getName ()

getPreferedRenderingMode ()

getPriority ()

getTranslation ()

layoutBuffer (id, data)

layoutBufferWithColor (id, data, rgba, material)

rebuild ()

release ()

renderBuffer (id)

renderBufferWithPrimitive (id, primitive, rgba)

renderBuffers ()

setActive (value)

setBuffer (id, data)

setBufferWithAttrib (id, data, iProg, attribs)

setDirty (status)

setGlContext (gl)

setGlView (view)

setImage (texId, pixels, width, height, hasAlpha)

setLabels (labels, size, stroke)

setPreferedRenderingMode (value)

setShader (id, vertexSource, fragmentSource, uniforms)

setShaderById (id, shader)

setTexture2D (texId, pixels, width, height)

setTranslation (trans)

setUniformCamera (iProg, xyz)

setUniformMV (iProg, MV)

setUniformMVP (iProg, MVP)

setUniformMaterial (material)

setUniformRGBA (rgba)

setUniformStipple (stipple)

setUniformTexMVP (MVP)

setUniformTexRGBA (rgba)

setUniformTexResolution (w, h)

setUniformXYZ (id, xyz)

setViewport (x, y, width, height)

startBuffer (iProg, id, layout, primitive)

startRenderShader (shaderId, bufId)

stopRenderShader (shaderId, bufId)

takeBuffer (id, data)

takeBufferWithAttribs (id, data, iProg, attribs)

transferBuffer (id, buffer, offset)

Virtual Methods

Inherited:

GObject.Object (7)

do_draw ()

do_rebuild ()

do_release ()

do_render ()

do_renderText ()

do_setGlView (view)

Properties

Name

Type

Flags

Short Description

active

bool

r/w

extension is used or not

description

str

r/w

description of extension

dirty

int

r/w

object rendering is out of date

label

str

r/w/c

label (translated) of extension

nGlObj

int

r/w/co

number of GL lists dealt with

nGlProg

int

r/w/co

number of GL kernels dealt with

nGlTex

int

r/w/co

number of GL textures dealt with

name

str

r/w/co

name (id) of extension

priority

int

r/w/c

drawing priority of extension

rendering-mode

int

r/w

specific rendering mode for the extension

withFog

bool

r/w/co

rendering is impacted by fog

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent

GObject.Object

r

priv

v_sim.GlExtPrivate

r

Class Details

class v_sim.GlExt(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

v_sim.GlExtClass

Common name to refer to a #_VisuGlExt.

addBuffers(number)
Parameters:

number (int) – a number.

Returns:

the index to be used in v_sim.GlExt.getGlBuffer(), or GObject.G_MAXUINT on error.

Return type:

int

Create number additional buffers. This method should be called only for the current OpenGL context. This should be used only for v_sim.GlExt with varying number of array buffers. Otherwise, the number of array buffers should be declared as a class parameter.

New in version 3.9.

addTextures(number)
Parameters:

number (int) – a number.

Returns:

the index to be used in v_sim.GlExt.blitTextureAt() for instance, or GObject.G_MAXUINT on error.

Return type:

int

Create number new available 2D textures. This method should be called only for the current OpenGL context. This should be used only for v_sim.GlExt with varying number of textures. Otherwise, the number of textures should be declared as a constructor parameter.

New in version 3.9.

adjustTextureDimensions(texId, width, height)
Parameters:
  • texId (int) – a texture id.

  • width (float) – a width value in pixels.

  • height (float) – a height value in pixels.

Adjust texture rendering dimension by hand. By default, textures are not scaled.

New in version 3.9.

blitLabels()

Draw all labels at the stored position in the scene. See v_sim.GlExt.setLabels().

New in version 3.9.

blitLabelsOnScreen()

Draw all labels at the stored position on the screen. See v_sim.GlExt.setLabels().

New in version 3.9.

blitTextureAt(texId, at, offset)
Parameters:
  • texId (int) – a texture id.

  • at (float) – 3 coordinates in cartesian space.

  • offset (float) – 3 coordinates in modelview space.

Displays the texture referred by texId at a position in the scene given by at. The offset is applied in model view space, making it independant of the camera position.

New in version 3.9.

blitTextureOnScreen(texId, at, hAlign, vAlign)
Parameters:

Draw the texture referred by texId at the position at on screen. The texture is positioned on at.

New in version 3.9.

bookBuffers(number)
Parameters:

number (int) – a number.

Ensure that extension can use up to number array buffers. This method should be called only for the current OpenGL context. This should be used only for v_sim.GlExt with varying number of array buffers. Otherwise, the number of array buffers should be declared as a class parameter.

New in version 3.9.

bookTextures(number)
Parameters:

number (int) – a number.

Ensure that extension can use up to number 2D textures. This method should be called only for the current OpenGL context. This should be used only for v_sim.GlExt with varying number of textures. Otherwise, the number of textures should be declared as a constructor parameter.

New in version 3.9.

call(globals)
Parameters:

globals (v_sim.GlExtGlobals) – global uniform values.

Select the v_sim.GlExt matching the given name and call it. The call is indeed done only if the extension is used. If lastOnly is True, the list is called only if it has a v_sim.GL_EXT_PRIORITY_LAST priority. On the contrary the list is called only if its priority is lower than v_sim.GL_EXT_PRIORITY_LAST.

callText(globals)
Parameters:

globals (v_sim.GlExtGlobals) – global uniform values.

Specifically call the text render routine for self.

New in version 3.9.

clearBuffers()

Empty all buffers of this extension.

New in version 3.9.

clearLabels()

Remove all labels displayed by this extension.

New in version 3.9.

cullFace(status)
Parameters:

status (bool) – a boolean.

Render or not polygons pointing inside.

New in version 3.9.

draw()

Send object data of self to GPU, if necessary.

New in version 3.9.

getActive()
Returns:

True if used, False otherwise.

Return type:

bool

Get if the extension is used or not.

getBufferDimension()
Returns:

a GL buffer index.

Return type:

int

Retrieve the size of the current buffer set with v_sim.GlExt.setBuffer().

New in version 3.9.

getGlBuffer(id)
Parameters:

id (int) – an id (within [0; nGlObj[)

Returns:

a GL buffer index.

Return type:

int

Retrieve the OpenGL index used to identify the id buffer.

New in version 3.9.

getGlContext()
Returns:

the v_sim.Gl object this extension draws to.

Return type:

v_sim.Gl or None

The v_sim.Gl object this extension draws to.

New in version 3.8.

getName()
Returns:

the name of the extension.

Return type:

str

Retrieve the name of the extension.

New in version 3.8.

getPreferedRenderingMode()
Returns:

the prefered rendering mode of this self.

Return type:

v_sim.GlRenderingMode

Each v_sim.GlExt method can draw in a mode different from the global one, see v_sim.GlRenderingMode. See also v_sim.GlExt.setPreferedRenderingMode().

New in version 3.7.

getPriority()
Returns:

the v_sim.GlExt priority.

Return type:

int

Inquire the priority of self.

New in version 3.8.

getTranslation()
Returns:

a location to store the translation.

Return type:

trans: [float]

Inquire the translation the extension is drawn with.

New in version 3.9.

layoutBuffer(id, data)
Parameters:
  • id (int) – a buffer id

  • data ([float]) – the data to transfer

Count the number of element added to data with respect to last call. This allow to construct a data buffer with various blocks than need to be drawn together.

New in version 3.9.

layoutBufferWithColor(id, data, rgba, material)
Parameters:

Add a new group of vertices defined in data. Vertices will be rendered using a lighting effect defined by rgba and material. If a flat coloured rendering should be used instead, consider using a v_sim.GlExtPackingModels.RGBA_XYZ packing instead, so the colour can also be transmitted to the GPU.

New in version 3.9.

rebuild()

This routine does not sort the extension on their priority and should be used only to draw some selected extensions. This method is called automatically for all extensions in a v_sim.GlExtSet when required.

release()

This routine frees the OpenGL resources when not needed anymore for the current context.

renderBuffer(id)
Parameters:

id (int) – a buffer id.

Render the buffer identified by id for self.

New in version 3.9.

renderBufferWithPrimitive(id, primitive, rgba)
Parameters:

Render the buffer identified by id, overloading its own rendering primitive with primitive. If rgba is provided this colour is used instead of the vertice colors.

New in version 3.9.

renderBuffers()

Render all the declared buffers for self.

New in version 3.9.

setActive(value)
Parameters:

value (bool) – the new value.

Return type:

bool

Set if an extension is actually used or not.

setBuffer(id, data)
Parameters:
  • id (int) – a buffer id

  • data ([float]) – the data to transfer

Transfer data to the GL buffer id.

New in version 3.9.

setBufferWithAttrib(id, data, iProg, attribs)
Parameters:
  • id (int) – a buffer id.

  • data ([float]) – the buffer data.

  • iProg (int) – a shader id.

  • attribs (v_sim.GlExtAttrib) – the data layout for the shader.

Transfer data to the GPU.

New in version 3.9.

setDirty(status)
Parameters:

status (v_sim.GlExtDirtyStates) – a v_sim.GlExtDirtyStates value.

Returns:

True is status is actually changed.

Return type:

bool

Set an internal flag to mark that self should be redrawn before next OpenGL frame view.

New in version 3.8.

setGlContext(gl)
Parameters:

gl (v_sim.Gl) – a v_sim.Gl object.

Returns:

True if the value is actually changed.

Return type:

bool

Associate gl to self.

New in version 3.8.

setGlView(view)
Parameters:

view (v_sim.GlView) – a v_sim.GlView object.

Returns:

True if the view is changed.

Return type:

bool

Attach a view to the self extension.

New in version 3.8.

setImage(texId, pixels, width, height, hasAlpha)
Parameters:
  • texId (int) – an id for the texture.

  • pixels (int) – some data.

  • width (int) – the width.

  • height (int) – the height.

  • hasAlpha (bool) – if the image is coded in RGB or RGBA.

Upload pixels to the graphic card in the texture registered as texId. The texId must be within 0 and nGlTex property value. The storage of pixels must be RGB or RGBA unsigned bytes.

New in version 3.9.

setLabels(labels, size, stroke)
Parameters:

Store a set of texts to be drawn in the scene at given positions with given colours. These labels will be rendered using the given size and maybe outlined by a black stroke.

New in version 3.9.

setPreferedRenderingMode(value)
Parameters:

value (v_sim.GlRenderingMode) – see v_sim.GlRenderingMode to choose one.

Returns:

True if value is actually changed.

Return type:

bool

This method is used to specify the rendering mode that the extension should use to be drawn. If the value is set to v_sim.GlRenderingMode.FOLLOW, the extension follows the global setting for rendering mode.

setShader(id, vertexSource, fragmentSource, uniforms)
Parameters:
  • id (int) – a shader id.

  • vertexSource (str) – vertex source.

  • fragmentSource (str) – fragment source.

  • uniforms (str) – labels of user defined uniforms.

Raises:

GLib.Error

Returns:

True on success.

Return type:

bool

Create the shader defined by vertexSource and fragmentSource and affect it to id.

New in version 3.9.

setShaderById(id, shader)
Parameters:
Raises:

GLib.Error

Returns:

True on success.

Return type:

bool

Create the shader defined by shader and affect it to id.

New in version 3.9.

setTexture2D(texId, pixels, width, height)
Parameters:
  • texId (int) – an id for the texture.

  • pixels (int) – some data.

  • width (int) – the width.

  • height (int) – the height.

Upload pixels to the graphic card in the texture registered as texId. The texId must be within 0 and nGlTex property value. The storage of pixels must be ARGB unsigned bytes.

New in version 3.9.

setTranslation(trans)
Parameters:

trans ([float]) – a translation vector in real space.

Returns:

True if the translations are indeed changed.

Return type:

bool

Change the translation the extension is drawn at.

New in version 3.8.

setUniformCamera(iProg, xyz)
Parameters:
  • iProg (int) – a shader id.

  • xyz ([float]) – the camera position in object space.

If iProg is using v_sim.GlUniformIds.NIFORM_CAMERA_POS, then xyz is send to the GPU. It is using the current shader if it corresponds to iProg, otherwise the current program is bound to iProg and then unbound.

New in version 3.9.

setUniformMV(iProg, MV)
Parameters:

If iProg is using v_sim.GlUniformIds.NIFORM_MV, then MV is send to the GPU. It is using the current shader if it corresponds to iProg, otherwise the current program is bound to iProg and then unbound.

New in version 3.9.

setUniformMVP(iProg, MVP)
Parameters:

If iProg is using v_sim.GlUniformIds.NIFORM_MVP, then MVP is send to the GPU. It is using the current shader if it corresponds to iProg, otherwise the current program is bound to iProg and then unbound.

New in version 3.9.

setUniformMaterial(material)
Parameters:

material ([float]) – a material.

Send material to the GPU using the various uniforms used for light.

New in version 3.9.

setUniformRGBA(rgba)
Parameters:

rgba ([float]) – a color.

Send rgba to the GPU using the uniform defined by v_sim.GlUniformIds.NIFORM_COLOR.

New in version 3.9.

setUniformStipple(stipple)
Parameters:

stipple (int) – a stipple pattern.

Send stipple to the GPU using the uniform v_sim.GlUniformIds.NIFORM_STIPPLE.

New in version 3.9.

setUniformTexMVP(MVP)
Parameters:

MVP (v_sim.GlMatrix) – a v_sim.GlMatrix object.

Send MVP to the GPU for the texture shader.

New in version 3.9.

setUniformTexRGBA(rgba)
Parameters:

rgba ([float]) – a color.

Send rgba to the GPU for the texture shader.

New in version 3.9.

setUniformTexResolution(w, h)
Parameters:
  • w (int) – a width.

  • h (int) – a height.

Send (w,`h`) to the GPU for the texture shader.

New in version 3.9.

setUniformXYZ(id, xyz)
Parameters:
  • id (int) – a uniform id.

  • xyz ([float]) – a position.

Send xyz to the GPU using the uniform defined by id.

New in version 3.9.

setViewport(x, y, width, height)
Parameters:
  • x (int) – lower-left corner.

  • y (int) – lower-left corner.

  • width (int) – the new width.

  • height (int) – the new height.

Change the current viewport.

New in version 3.9.

startBuffer(iProg, id, layout, primitive)
Parameters:
Returns:

a new GLib.Array structure to store the vertice data in CPU memory before transfering them to GPU.

Return type:

[float]

Create a new data buffer, identified by id. The data storage layout in GPU memory is defined by layout and the prefered rendering scheme is defined by primitive.

New in version 3.9.

startRenderShader(shaderId, bufId)
Parameters:
  • shaderId (int) – a shader id.

  • bufId (int) – a buffer id.

Load the given shaderId and bind the data buffer defined by bufId.

New in version 3.9.

stopRenderShader(shaderId, bufId)
Parameters:
  • shaderId (int) – a shader id.

  • bufId (int) – a buffer id.

Stop using the given shaderId and unbind the data buffer defined by bufId.

New in version 3.9.

takeBuffer(id, data)
Parameters:
  • id (int) – a buffer id.

  • data ([float]) – some vertice data.

Transfer all CPU data stored in data into a GPU buffer identified by id.

New in version 3.9.

takeBufferWithAttribs(id, data, iProg, attribs)
Parameters:
  • id (int) – a buffer id.

  • data ([float]) – some vertice data.

  • iProg (int) – a program id.

  • attribs (v_sim.GlExtAttrib) – the data layout.

Transfer all CPU data stored in data into a GPU buffer identified by id.

New in version 3.9.

transferBuffer(id, buffer, offset)
Parameters:
  • id (int) – a buffer id.

  • buffer ([float]) – some vertice data.

  • offset (int) – an offset.

Transfer buffer data to the GPU at the position given by offset in the data buffer allocated for id.

New in version 3.9.

do_draw() virtual

Send object data of ext to GPU, if necessary.

New in version 3.9.

do_rebuild() virtual

This routine does not sort the extension on their priority and should be used only to draw some selected extensions. This method is called automatically for all extensions in a v_sim.GlExtSet when required.

do_release() virtual

This routine frees the OpenGL resources when not needed anymore for the current context.

do_render() virtual

a method called at each OpenGL rendering cycle.

do_renderText() virtual

a method called at each OpenGL rendering cycle, dedicated to text rendering.

do_setGlView(view) virtual
Parameters:

view (v_sim.GlView) – a v_sim.GlView object.

Returns:

True if the view is changed.

Return type:

bool

Attach a view to the self extension.

New in version 3.8.

Property Details

v_sim.GlExt.props.active
Name:

active

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

extension is used or not

v_sim.GlExt.props.description
Name:

description

Type:

str

Default Value:

''

Flags:

READABLE, WRITABLE

description of extension

v_sim.GlExt.props.dirty
Name:

dirty

Type:

int

Default Value:

2

Flags:

READABLE, WRITABLE

object rendering is out of date

v_sim.GlExt.props.label
Name:

label

Type:

str

Default Value:

''

Flags:

READABLE, WRITABLE, CONSTRUCT

label (translated) of extension

v_sim.GlExt.props.nGlObj
Name:

nGlObj

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

number of GL lists dealt with

v_sim.GlExt.props.nGlProg
Name:

nGlProg

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

number of GL kernels dealt with

v_sim.GlExt.props.nGlTex
Name:

nGlTex

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

number of GL textures dealt with

v_sim.GlExt.props.name
Name:

name

Type:

str

Default Value:

''

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

name (id) of extension

v_sim.GlExt.props.priority
Name:

priority

Type:

int

Default Value:

50

Flags:

READABLE, WRITABLE, CONSTRUCT

drawing priority of extension

v_sim.GlExt.props.rendering_mode
Name:

rendering-mode

Type:

int

Default Value:

5

Flags:

READABLE, WRITABLE

specific rendering mode for the extension

v_sim.GlExt.props.withFog
Name:

withFog

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

rendering is impacted by fog