Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

ps2gl.h File Reference

#include "GL/gl.h"

Go to the source code of this file.

Defines

#define PGL_CLIPPING   2
#define PGL_FORCE_IMMEDIATE_STOP   1
#define PGL_DONT_FORCE_IMMEDIATE_STOP   0
#define PGL_NONINTERLACED   0
#define PGL_INTERLACED   1
#define PGL_DONT_MERGE_CONTIGUOUS   0
#define PGL_MERGE_CONTIGUOUS   1
#define PGL_MAX_CUSTOM_RENDERERS   64
#define PGL_MAX_CUSTOM_PRIM_TYPES   32

Typedefs

typedef long pgl64_t
typedef unsigned long pglU64_t
typedef unsigned int pgl_slot_handle_t
typedef unsigned int pgl_area_handle_t

Functions

int pglInit (int immBufferVertexSize, int immDrawBufferQwordSize)
 Initialize the ps2gl library. More...

int pglHasLibraryBeenInitted (void)
 Has pglInit() been called? More...

void pglFinish (void)
 Do any necessary clean up when finished using ps2gl. More...

void pglWaitForVU1 (void)
 Wait for dma transfers to vif1 to end. More...

void pglWaitForVSync (void)
 Wait for the vertical retrace. More...

void pglSwapBuffers (void)
 Signals the end of the current rendering loop and swaps anything double-buffered (display, draw buffers). More...

void pglPrintGsMemAllocation (void)
 prints the current gs memory allocation to stdout. More...

int pglHasGsMemBeenInitted (void)
 returns whether gs memory has been initialized (by adding one or more slots). More...

pgl_slot_handle_t pglAddGsMemSlot (int startingPage, int pageLength, unsigned int pixelMode)
 Adds a memory slot to the list of free slots. More...

void pglLockGsMemSlot (pgl_slot_handle_t slot_handle)
 Prevents a slot from being allocated or freed automatically. More...

void pglUnlockGsMemSlot (pgl_slot_handle_t slot_handle)
 Lets the memory manager automatically allocate/free a slot that was previously locked. More...

void pglRemoveAllGsMemSlots ()
 Removes all gs memory slots. More...

pgl_area_handle_t pglCreateGsMemArea (int width, int height, unsigned int pix_format)
 Create a memory area. More...

void pglDestroyGsMemArea (pgl_area_handle_t mem_area)
 Destroy a memory area (free the memory it occupies). More...

void pglAllocGsMemArea (pgl_area_handle_t mem_area)
 Allocate GS ram by binding to a slot. More...

void pglFreeGsMemArea (pgl_area_handle_t mem_area)
 Free a memory area. More...

void pglSetGsMemAreaWordAddr (pgl_area_handle_t mem_area, unsigned int addr)
 Manually set the starting GS ram word address of this area (mainly for compatibility with existing code). More...

void pglBindGsMemAreaToSlot (pgl_area_handle_t mem_area, pgl_slot_handle_t mem_slot)
 This is the manual equivalent of pglAllocGsMemArea() (except that the slot does not have to be unlocked). More...

void pglUnbindGsMemArea (pgl_area_handle_t mem_area)
 Release the slot bound to this area. More...

void pglLockGsMemArea (pgl_area_handle_t mem_area)
 Prevent this area from being allocated or freed automatically by the memory manager (it may still be operated on manually). More...

void pglUnlockGsMemArea (pgl_area_handle_t mem_area)
 Let the memory manager affect the allocation of this area. More...

int pglGsMemAreaIsAllocated (pgl_area_handle_t mem_area)
unsigned int pglGetGsMemAreaWordAddr (pgl_area_handle_t mem_area)
void pglSetDisplayBuffers (int interlaced, pgl_area_handle_t frame0_mem, pgl_area_handle_t frame1_mem)
 Tell ps2gl what areas in GS ram to display. More...

void pglSetDrawBuffers (int interlaced, pgl_area_handle_t frame0_mem, pgl_area_handle_t frame1_mem, pgl_area_handle_t depth_mem)
 Set the area(s) in gs mem to draw. More...

void pglTextureFromGsMemArea (pgl_area_handle_t tex_area_handle)
 Texture from the given memory area. More...

void pglBindTextureToSlot (GLuint texId, pgl_slot_handle_t mem_slot)
 Bind the named GL texture object to the given GS memory slot. More...

void pglFreeTexture (GLuint texId)
 Free the named GL texture object. More...

void pglNormalPointer (GLint size, GLenum type, GLsizei stride, const GLvoid *ptr)
 Specify a normal pointer with either 3 or 4 elements. More...

void pglDrawIndexedArrays (GLenum primType, int numIndices, const unsigned char *indices, int numVertices)
void pglBeginImmediateGeometry (void)
void pglEndImmediateGeometry (void)
void pglRenderImmediateGeometry (void)
void pglFinishRenderingImmediateGeometry (int forceImmediateStop)
void pglBeginGeometry (void)
void pglEndGeometry (void)
void pglRenderGeometry (void)
void pglFinishRenderingGeometry (int forceImmediateStop)
void pglSetRenderingFinishedCallback (void(*cb)(void))
 Set a function to be called back when rendering finishes. More...

void pglEnable (GLenum cap)
void pglDisable (GLenum cap)
void pglSetInterlacingOffset (float yPixels)
const char * pglGetCurRendererName ()
 Returns the name (string) of the current renderer. More...

void pglBeginRendererDefs ()
 Call this before registering any renderers. More...

void pglRegisterRenderer (void *renderer)
 Register a custom renderer. More...

void pglEndRendererDefs ()
 Call this after registering custom renderers. More...

void pglRegisterCustomPrimType (GLenum primType, pglU64_t requirements, pglU64_t rendererReqMask, int mergeContiguous)
 Register a new primitive. More...

void pglEnableCustom (pglU64_t flag)
 Enable a custom attribute/state change. More...

void pglDisableCustom (pglU64_t flag)
 Disable a custom attribute/state change. More...


Define Documentation

#define PGL_CLIPPING   2
 

Definition at line 136 of file ps2gl.h.

#define PGL_DONT_FORCE_IMMEDIATE_STOP   0
 

Definition at line 141 of file ps2gl.h.

#define PGL_DONT_MERGE_CONTIGUOUS   0
 

Definition at line 150 of file ps2gl.h.

#define PGL_FORCE_IMMEDIATE_STOP   1
 

Definition at line 140 of file ps2gl.h.

#define PGL_INTERLACED   1
 

Definition at line 146 of file ps2gl.h.

#define PGL_MAX_CUSTOM_PRIM_TYPES   32
 

Definition at line 156 of file ps2gl.h.

#define PGL_MAX_CUSTOM_RENDERERS   64
 

Definition at line 155 of file ps2gl.h.

#define PGL_MERGE_CONTIGUOUS   1
 

Definition at line 151 of file ps2gl.h.

#define PGL_NONINTERLACED   0
 

Definition at line 145 of file ps2gl.h.


Typedef Documentation

typedef long pgl64_t
 

Definition at line 16 of file ps2gl.h.

typedef unsigned long pglU64_t
 

Definition at line 17 of file ps2gl.h.

typedef unsigned int pgl_area_handle_t
 

Definition at line 50 of file ps2gl.h.

typedef unsigned int pgl_slot_handle_t
 

Definition at line 41 of file ps2gl.h.


Function Documentation

void pglBeginGeometry void   
 

Definition at line 670 of file glcontext.cpp.

void pglBeginImmediateGeometry void   
 

Definition at line 645 of file glcontext.cpp.

void pglBeginRendererDefs  
 

Call this before registering any renderers.

Definition at line 736 of file renderermanager.cpp.

void pglBindTextureToSlot GLuint    texId,
pgl_slot_handle_t    mem_slot
 

Bind the named GL texture object to the given GS memory slot.

This functions allows the application to bypass the GS memory manager.

Definition at line 730 of file texture.cpp.

void pglDisable GLenum    cap
 

Definition at line 707 of file glcontext.cpp.

void pglDisableCustom pglU64_t    flag
 

Disable a custom attribute/state change.

Call this to disable the corresponding bit(s) in the renderer requirements bitfield. The lower 32 bits should be zero.

Parameters:
flag  the bit(s) to disable (lower 32 should be zero). This is the same constant passed to pglEnableCustom.

Definition at line 398 of file gmanager.cpp.

void pglDrawIndexedArrays GLenum    primType,
int    numIndices,
const unsigned char *    indices,
int    numVertices
 

Definition at line 330 of file gmanager.cpp.

void pglEnable GLenum    cap
 

Definition at line 695 of file glcontext.cpp.

void pglEnableCustom pglU64_t    flag
 

Enable a custom attribute/state change.

Call this to enable the corresponding bit(s) in the renderer requirements bitfield (see above). The lower 32 bits should be zero.

Parameters:
flag  the bit(s) to enable (lower 32 should be zero)

Definition at line 385 of file gmanager.cpp.

void pglEndGeometry void   
 

Definition at line 675 of file glcontext.cpp.

void pglEndImmediateGeometry void   
 

Definition at line 650 of file glcontext.cpp.

void pglEndRendererDefs  
 

Call this after registering custom renderers.

Definition at line 759 of file renderermanager.cpp.

void pglFinish void   
 

Do any necessary clean up when finished using ps2gl.

Definition at line 545 of file glcontext.cpp.

void pglFinishRenderingGeometry int    forceImmediateStop
 

Definition at line 685 of file glcontext.cpp.

Referenced by glutMainLoop().

void pglFinishRenderingImmediateGeometry int    forceImmediateStop
 

Definition at line 660 of file glcontext.cpp.

void pglFreeTexture GLuint    texId
 

Free the named GL texture object.

Note that this only frees any GS ram the texture is using, not main ram.

Definition at line 717 of file texture.cpp.

const char* pglGetCurRendererName  
 

Returns the name (string) of the current renderer.

You'll need to call glFlush() to be sure that the renderer is in in sync. Probably doesn't make much sense to call this inside of a glBegin/glEnd pair.

Returns:
pointer to the renderer's name

Definition at line 771 of file renderermanager.cpp.

int pglHasLibraryBeenInitted void   
 

Has pglInit() been called?

Returns:
1 if pglInit has been called, 0 otherwise

Definition at line 536 of file glcontext.cpp.

int pglInit int    immBufferVertexSize,
int    immDrawBufferQwordSize
 

Initialize the ps2gl library.

You must call this before any other pgl* or gl* functions! (When using glut, it will be called in glutInit() if the ps2gl library was not initialized by the app previously.) Also, the application is now responsible for resetting the machine, including the display mode (putting the gs into the right output state, i.e., resolution and interlaced), usually this just means calling sceGsResetGraph.

Parameters:
immBufferVertexSize  ps2gl uses fixed-size internal buffers to store geometry; this argument tells the library how much space to allocate.

Definition at line 523 of file glcontext.cpp.

Referenced by glutInit(), and pglU64_t().

void pglNormalPointer GLint    size,
GLenum    type,
GLsizei    stride,
const GLvoid   ptr
 

Specify a normal pointer with either 3 or 4 elements.

If 4-element normals are specified, the last element (w) will be ignored.

Definition at line 313 of file gmanager.cpp.

Referenced by glNormalPointer().

void pglRegisterCustomPrimType GLenum    primType,
pglU64_t    requirements,
pglU64_t    rendererReqMask,
int    mergeContiguous
 

Register a new primitive.

After registering a primitive with this call it can be used anywhere a normal primitive can be used (glBegin, glDrawArrays, etc.). Defining a new primitive usually implies writing a renderer to go along with it.

Parameters:
primType  bit 31 must be set (this indicates a user prim to ps2gl). The lower 31 bits should be a number from 0 to PGL_MAX_CUSTOM_PRIM_TYPES.
requirements  gives the bit flags to be set in the renderer requirements bitfield (see the documentation for custom renderers). Usually this will be one bit indicating the prim type used to select a renderer.
rendererReqMask  a mask to be applied to the renderer requirements bitfield before testing against renderer capabilities. This could be used, for example, to mask off the default lower 32 bits if they are irrelevent to this custom primitive type.
mergeContiguous  rather calling a renderer with every block of geometry that is specified (with glBegin/End, DrawArrays, etc.), ps2gl tries to combine multiple blocks into a single call to the renderer. This flag tells ps2gl whether it can treat blocks of geometry that were specified independently but are contiguous in memory as a single block. (State changes will of course force them to be treated separately.) This is done, for example, with points, lines, triangles, and quads, but not with strips, since merging would lose the strip boundaries.

Definition at line 371 of file gmanager.cpp.

void pglRegisterRenderer void *    renderer
 

Register a custom renderer.

The maximum number of custom renderers is indicated by PGL_MAX_CUSTOM_RENDERERS.

Parameters:
renderer  should point to a CRenderer object (passed as a void* for compatibility with C code)

Definition at line 749 of file renderermanager.cpp.

void pglRenderGeometry void   
 

Definition at line 680 of file glcontext.cpp.

void pglRenderImmediateGeometry void   
 

Definition at line 655 of file glcontext.cpp.

void pglSetDisplayBuffers int    interlaced,
pgl_area_handle_t    frame0_mem,
pgl_area_handle_t    frame1_mem
 

Tell ps2gl what areas in GS ram to display.

Parameters:
interlaced  PGL_INTERLACED or PGL_NONINTERLACED
frame0_mem  the first area if double-buffered, otherwise the only area
frame1_mem  the second area if double-buffered, otherwise NULL

Definition at line 107 of file displaycontext.cpp.

void pglSetDrawBuffers int    interlaced,
pgl_area_handle_t    frame0_mem,
pgl_area_handle_t    frame1_mem,
pgl_area_handle_t    depth_mem
 

Set the area(s) in gs mem to draw.

If two frame buffers are given they will be used as double buffers.

Parameters:
interlaced  PGL_INTERLACED or PGL_NONINTERLACED
frame0_mem  the first or only buffer
frame1_mem  NULL if single-buffered
depth_mem  the depth buffer; NULL for none

Definition at line 709 of file drawcontext.cpp.

void pglSetInterlacingOffset float    yPixels
 

Definition at line 720 of file drawcontext.cpp.

void pglSetRenderingFinishedCallback void(*    cb)(void)
 

Set a function to be called back when rendering finishes.

This function will be called from the interrupt handler; be careful!

Parameters:
a  pointer to the callback function or NULL to clear

Definition at line 635 of file glcontext.cpp.

void pglSwapBuffers void   
 

Signals the end of the current rendering loop and swaps anything double-buffered (display, draw buffers).

Note that this call is required. (Called by glut.)

Definition at line 622 of file glcontext.cpp.

void pglTextureFromGsMemArea pgl_area_handle_t    tex_area_handle
 

Texture from the given memory area.

Used in the same context as glTexImage2D(), this call would probably be used with procedural textures.

Definition at line 742 of file texture.cpp.

void pglWaitForVSync void   
 

Wait for the vertical retrace.

Note that this call is required for the interlacing to work properly. (Called by glut.)

Definition at line 610 of file glcontext.cpp.

void pglWaitForVU1 void   
 

Wait for dma transfers to vif1 to end.

Polls cop0, so it should not slow down the transfer, unlike sceGsSyncPath().

This call is for convenience only -- there is no need to call it if the app can manage on its own.

Definition at line 565 of file glcontext.cpp.


ps2gl version cvs