15 #ifndef TINYGRAPHICSSTATEGUARDIAN_H 16 #define TINYGRAPHICSSTATEGUARDIAN_H 18 #include "pandabase.h" 20 #include "graphicsStateGuardian.h" 21 #include "colorBlendAttrib.h" 22 #include "simpleLru.h" 26 #include "geomVertexReader.h" 51 virtual void free_pointers();
52 virtual void close_gsg();
62 virtual CPT(TransformState) calc_projection_mat(
const Lens *lens);
90 const TransformState *transform);
106 void do_issue_transform();
107 void do_issue_render_mode();
108 void do_issue_cull_face();
109 void do_issue_rescale_normal();
110 void do_issue_depth_offset();
111 void do_issue_material();
112 void do_issue_texture();
113 void do_issue_scissor();
115 void set_scissor(PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top);
120 bool setup_gltex(
GLTexture *gltex,
int x_size,
int y_size,
int num_levels);
121 int get_tex_shift(
int orig_size);
131 void do_auto_rescale_normal();
132 static void load_matrix(
M4 *matrix,
const TransformState *transform);
133 static int get_color_blend_op(ColorBlendAttrib::Operand operand);
134 static ZB_lookupTextureFunc get_tex_filter_func(SamplerState::FilterType filter);
135 static ZB_texWrapFunc get_tex_wrap_func(SamplerState::WrapMode wrap_mode);
137 INLINE
void clear_light_state();
146 typedef void GenTexcoordFunc(
V2 &result, TexCoordData &tcdata);
148 static void texgen_null(
V2 &result, TexCoordData &tcdata);
149 static void texgen_simple(
V2 &result, TexCoordData &tcdata);
150 static void texgen_texmat(
V2 &result, TexCoordData &tcdata);
151 static void texgen_sphere_map(
V2 &result, TexCoordData &tcdata);
154 ZBuffer *_current_frame_buffer;
163 enum ColorMaterialFlags {
167 int _color_material_flags;
168 int _texturing_state;
169 int _texfilter_state;
170 bool _texture_replace;
172 bool _auto_rescale_normal;
174 CPT(TransformState) _scissor_mat;
180 Lights _plights, _dlights, _slights;
206 static void init_type() {
207 GraphicsStateGuardian::init_type();
208 register_type(_type_handle,
"TinyGraphicsStateGuardian",
209 GraphicsStateGuardian::get_class_type());
212 return get_class_type();
214 virtual TypeHandle force_init_type() {init_type();
return get_class_type();}
220 #include "tinyGraphicsStateGuardian.I" A light shining from infinitely far away in a particular direction, like sunlight.
virtual bool draw_points(const GeomPrimitivePipelineReader *reader, bool force)
Draws a series of disconnected points.
virtual bool framebuffer_copy_to_ram(Texture *tex, int view, int z, const DisplayRegion *dr, const RenderBuffer &rb)
Copy the pixels within the indicated display region from the framebuffer into system memory...
virtual void end_frame(Thread *current_thread)
Called after each frame is rendered, to allow the GSG a chance to do any internal cleanup after rende...
Encapsulates the data from a DisplayRegion, pre-fetched for one stage of the pipeline.
virtual bool depth_offset_decals()
Returns true if this GSG can implement decals using a DepthOffsetAttrib, or false if that is unreliab...
virtual TextureContext * prepare_texture(Texture *tex)
Creates whatever structures the GSG requires to represent the texture internally, and returns a newly...
This is a base class for GraphicsWindow (actually, GraphicsOutput) and DisplayRegion, both of which are conceptually rectangular regions into which drawing commands may be issued.
virtual void clear(DrawableRegion *clearable)
Clears the framebuffer within the current DisplayRegion, according to the flags indicated by the give...
A base class for any number of different kinds of lenses, linear and otherwise.
virtual bool update_texture(TextureContext *tc, bool force)
Ensures that the current Texture data is refreshed onto the GSG.
virtual void prepare_display_region(DisplayRegionPipelineReader *dr)
Makes the specified DisplayRegion current.
virtual void end_draw_primitives()
Called after a sequence of draw_primitive() functions are called, this should do whatever cleanup is ...
Objects of this class are used to convert vertex data from a Geom into a format suitable for passing ...
Represents a texture object, which is typically a single 2-d image but may also represent a 1-d or 3-...
This is a special class object that holds all the information returned by a particular GSG to indicat...
Encapsulates the data from a Geom, pre-fetched for one stage of the pipeline.
virtual bool draw_tristrips(const GeomPrimitivePipelineReader *reader, bool force)
Draws a series of triangle strips.
A lightweight class that represents a single element that may be timed and/or counted via stats...
virtual void set_state_and_transform(const RenderState *state, const TransformState *transform)
Simultaneously resets the render state and the transform state.
This is a 4-by-4 transform matrix.
An object to create GraphicsOutputs that share a particular 3-D API.
virtual bool draw_triangles(const GeomPrimitivePipelineReader *reader, bool force)
Draws a series of disconnected triangles.
virtual void release_texture(TextureContext *tc)
Frees the resources previously allocated via a call to prepare_texture(), including deleting the Text...
virtual bool draw_lines(const GeomPrimitivePipelineReader *reader, bool force)
Draws a series of disconnected line segments.
A light originating from a single point in space, and shining in a particular direction, with a cone-shaped falloff.
virtual void do_issue_light()
This implementation of do_issue_light() assumes we have a limited number of hardware lights available...
Defines the way an object appears in the presence of lighting.
This represents a unique collection of RenderAttrib objects that correspond to a particular renderabl...
virtual bool begin_draw_primitives(const GeomPipelineReader *geom_reader, const GeomMunger *munger, const GeomVertexDataPipelineReader *data_reader, bool force)
Called before a sequence of draw_primitive() functions are called, this should prepare the vertex dat...
A thread; that is, a lightweight process.
This object provides a high-level interface for quickly reading a sequence of numeric values from a v...
Encapsulates all the communication with a particular instance of a given rendering backend...
virtual void end_scene()
Called between begin_frame() and end_frame() to mark the end of drawing commands for a "scene" (usual...
A rectangular subregion within a window for rendering into.
Encapsulates the data from a GeomVertexData, pre-fetched for one stage of the pipeline.
This class is the main interface to controlling the render process.
virtual void reset()
Resets all internal state as if the gsg were newly created.
virtual bool framebuffer_copy_to_texture(Texture *tex, int view, int z, const DisplayRegion *dr, const RenderBuffer &rb)
Copy the pixels within the indicated display region from the framebuffer into texture memory...
virtual bool begin_frame(Thread *current_thread)
Called before each frame is rendered, to allow the GSG a chance to do any internal cleanup before beg...
TypeHandle is the identifier used to differentiate C++ class types.
Encapsulates the data from a GeomPrimitive, pre-fetched for one stage of the pipeline.
virtual bool prepare_lens()
Makes the current lens (whichever lens was most recently specified with set_scene()) active...
A RenderBuffer is an arbitrary subset of the various layers (depth buffer, color buffer, etc.) of a drawing region.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
An interface to the TinyPanda software rendering code within this module.
A light originating from a single point in space, and shining in all directions.
virtual bool begin_scene()
Called between begin_frame() and end_frame() to mark the beginning of drawing commands for a "scene" ...
virtual void bind_light(PointLight *light_obj, const NodePath &light, int light_id)
Called the first time a particular light has been bound to a given id within a frame, this should set up the associated hardware light with the light's properties.