HELP,,$DIR$Im!ConfigureTI-!RootIڿ@Context IO4IntroductionDATA#f24 = Trinity.Medium 12 12 #f25 = Trinity.Medium.Italic 12 12 #f26 = Trinity.Bold 12 12 #f27 = Corpus.Medium 12 12 #SpriteFile Sprites DATAOpenGL Reference #Wrap Off #fh2:Mesa Reference for RISC OS users #Wrap #Line #fh3:Contents Introduction.Introduction> Context.CreateContext> Context.MakeCurrent> Context.DestroyContext> Context.GetCurrentContext> Context.PixelStore> Context.GetIntegerv> Context.GetDepthBuffer> Context.SwapBuffers> #Line #fh3:Index of functions Context.CreateContext> Context.MakeCurrent> Context.DestroyContext> Context.GetCurrentContext> Context.PixelStore> Context.GetIntegerv> Context.GetDepthBuffer> Context.SwapBuffers> #Line #fh3:Contact address David Boddie #URL mailto:davidb@mcs.st-and.ac.uk> DIR$@@,I0CreateContext IMakeCurrentLIoDestroyContext0IGetCurrentContextIPxGetIntegervI*PixelStore8IUGetDepthBufferIaSwapBuffersDATACreating a rendering context #Include !Configure #fh3:Creating a rendering context Before you can describe your 3D scene, it is necessary to infom the library about the type of screen mode or sprite you wish to render into. The format of the function used to do this is: #Wrap Off {f25:ROSMesaContext}{f26: ROSMesaCreateContext}{f24:(}{f25:GLenum format}{f24:, }{f25: GLuint bpp}{f24:, }{f25: GLboolean doublebuffer}{f24:)\;} #Wrap The parameters are as follows: {f25:format} is either {f27:ROSMESA_RGBA} for a context where colours are described using red, green, blue and alpha components, or {f27:ROSMESA_RGB} for just red, green and blue components. {f25:bpp} is the number of bits per pixel used to decribe the colour: this can be 8, 16 or 32. {f25:doublebuffer} is either {f27:GL_TRUE} for double buffering or {f27:GL_FALSE} for a single buffer. If the context, {f25:ROSMesaContext}, returned by the function is {f27:NULL} then the creation has failed. If the creation was a success then you may wish to make the context the current rendering context so that you can render your scene into it. #Align Centre Context.MakeCurrent> DATAMaking a context the current rendering context #Include !Configure #fh3:Making a context the current rendering context In order to render your scene, you must make a context the current rendering context. The format of the function used to do this is: #Wrap Off {f25:GLboolean}{f26: ROSMesaMakeCurrent}{f24:(}{f25:ROSMesaContext ctx}{f24:, }{f25:void *buffer1}{f24:, }{f25: void *buffer2}{f24:,} {f25: GLenum type}{f24:,}{f25:GLsizei width}{f24:, }{f25: GLsizei height}{f24:)\;} #Wrap {f25:ctx} is the context returned by Context.CreateContext>. {f25:buffer1} is a pointer to a buffer in which images will be rendered. {f25:buffer2} is a pointer to a second buffer which is used if double buffering was requested when the context was created. The buffers may be the screen or the part of a sprite which stores the visual information. It is up to the programmer to set up the buffers for use. {f25:type} should be set to {f27:GL_UNSIGNED_BYTE}. {f25:width} and {f25:height} are the dimensions of the buffers. The function will return {f27:GL_TRUE} if it was successful, otherwise it will return {f27:GL_FALSE}. You may now begin using the {f26:gl} commands to render your scene. When you have finished, you may destroy the rendering context. #Align Centre Context.DestroyContext> DATADestroying a rendering context #Include !Configure #fh3:Destroying a rendering context When you have finished using a rendering context, you may wish to destroy it. The format of the function used to do this is: #Wrap Off {f25:void}{f26: ROSMesaDestroyContext}{f24:(}{f25:ROSMesaContext ctx}{f24:)\;} #Wrap {f25:ctx} is a context returned by Context.CreateContext>. The context {f25:ctx} will be destroyed, making it unavailable for further use. DATAObtaining the current rendering context #Include !Configure #fh3:Obtaining the current rendering context If you are using several rendering context, you may wish to discover which one is curently being used. The format of the function used to do this is: #Wrap Off {f25:ROSMesaContext}{f26: ROSMesaGetCurrentContext}{f24:(}{f25:void}{f24:)\;} #Wrap The pointer returned will be {f27:NULL} if you haven't already Context.MakeCurrent>. DATAxObtaining information about the current context #Include !Configure #fh3:Obtaining information about the current context You can discover details about the current rendering context using this function: #Wrap Off {f25:void}{f26: ROSMesaGetIntegerv}{f24:(}{f25:GLint pname}{f24:, }{f25:GLint *value}{f24:)\;} #Wrap {f25:pname} specifies the property of the context on which you require information, {f25:value} is a variable of type {f25:GLint}. {f25:pname} can be any of the following: {f27:ROSMESA_WIDTH }returns current image width {f27:ROSMESA_HEIGHT }returns current image height {f27:ROSMESA_FORMAT }returns image format {f27:ROSMESA_TYPE }returns color component data type {f27:ROSMESA_ROW_LENGTH }returns row length in pixels {f27:ROSMESA_Y_UP }returns 1 or 0 to indicate {f25:y} axis direction DATASet pixel store/packing parameters for the current context #Include !Configure #fh3:Set pixel store/packing parameters for the current context You may change the way Mesa treats the image used for the current context using this function: #Wrap Off {f25:void}{f26: ROSMesaPixelStore}{f24:(}{f25:GLint pname}{f24:, }{f25:GLint value}{f24:)\;} #Wrap {f25:pname} is the parameter which is to be changed to the {f25:value} given. {f25:pname} may be either {f27:ROSMESA_ROW_LENGTH} which currently has no effect, or {f27:ROSMESA_Y_UP} which specifies whether increasing values of {f25:y} are upwards ({f27:GL_TRUE}) or downwards ({f27:GL_FALSE}) in the viewport coordinate system. DATAUObtaining the current depth buffer #Include !Configure #fh3:Obtaining the current depth buffer The depth buffer associated with a rendering context can be obtained with the function: #Wrap Off {f25:GLboolean}{f26: ROSMesaGetDepthBuffer}{f24:(}{f25:ROSMesaContext c}{f24:, }{f25:GLint *width}{f24:, }{f25:GLint *height}{f24:,} {f25:GLint *bytesPerValue}{f24:, }{f25:void **buffer}{f24:)\;} #Wrap {f25:c} is the context for which you require the depth buffer. The function returns the width, height and number of bytes per depth value in the variables {f25:width}, {f25:height} and {f25:bytesPerValue} respectively. A pointer to the depth buffer is returned in the variable {f25:buffer}. If the function was successful then it returns {f27:GL_TRUE} otherwise returning {f27:GL_FALSE}. DATASwapping the buffers when double buffering #Include !Configure #fh3:Swapping the buffers when double buffering If double buffering was specified when the current context was created and buffers provided when the context was made current, then the image buffer being used to can be swapped with the other to allow smooth updating of animations. This is achieved using the function: #Wrap Off {f25:void}{f26: ROSMesaSwapBuffers}{f24:(}{f25:ROSMesaContext ctx}{f24:)\;} #Wrap {f25:ctx} is the context which is to be affected. DIR$44 IIntroductionDATAIntroduction #fh3:Introduction #URL http://mesa3d.sourceforge.net/> is a library for rendering three dimensional graphics which is similar in most respects to the #URL http://www.opengl.org/> library created by #URL http://www.sgi.com/>. Mesa was originally written by Brian Paul, but is now maintained and developed by a number of people. The #URL http://www-solar.mcs.st-and.ac.uk/~davidb/Mesa/> allows programmers to display 3D graphics by rendering to memory in the format used by screen modes and sprites under RISC OS. The aim of this manual is to document the functions specific to RISC OS rather than to be a tutorial. It does not explain the generic OpenGL functions since they are adequately documented elsewhere.