Lines Matching refs:osmesa
37 #include "GL/osmesa.h"
65 * OSMesa rendering context, derived from core Mesa struct gl_context.
134 (DST)[osmesa->rInd] = R; \
135 (DST)[osmesa->gInd] = G; \
136 (DST)[osmesa->bInd] = B; \
137 (DST)[osmesa->aInd] = A; \
140 #define PIXELADDR4(X,Y) ((GLchan *) osmesa->rowaddr[Y] + 4 * (X))
144 * Draw a flat-shaded, RGB line into an osmesa buffer.
149 const OSMesaContext osmesa = OSMESA_CONTEXT(ctx); \
163 * Draw a flat-shaded, Z-less, RGB line into an osmesa buffer.
170 const OSMesaContext osmesa = OSMESA_CONTEXT(ctx); \
194 const OSMesaContext osmesa = OSMESA_CONTEXT(ctx);
204 if (osmesa->format != OSMESA_RGBA &&
205 osmesa->format != OSMESA_BGRA &&
206 osmesa->format != OSMESA_ARGB) return NULL;
237 const OSMesaContext osmesa = OSMESA_CONTEXT(ctx);
267 const OSMesaContext osmesa = OSMESA_CONTEXT(ctx); \
295 const OSMesaContext osmesa = OSMESA_CONTEXT(ctx);
302 if (osmesa->format != OSMESA_RGBA &&
303 osmesa->format != OSMESA_BGRA &&
304 osmesa->format != OSMESA_ARGB) return (swrast_tri_func) NULL;
355 compute_row_addresses( OSMesaContext osmesa )
358 GLubyte *origin = (GLubyte *) osmesa->srb->Buffer;
360 GLint height = osmesa->srb->Base.Height;
362 if (osmesa->userRowLength)
363 rowlength = osmesa->userRowLength;
365 rowlength = osmesa->srb->Base.Width;
367 bytesPerRow = rowlength * _mesa_get_format_bytes(osmesa->srb->Base.Format);
369 if (osmesa->yup) {
372 osmesa->rowaddr[i] = (GLvoid *) ((GLubyte *) origin + i * bytesPerRow);
379 osmesa->rowaddr[i] = (GLvoid *) ((GLubyte *) origin + j * bytesPerRow);
405 const OSMesaContext osmesa = OSMESA_CONTEXT(ctx);
417 if (osmesa->format == OSMESA_RGBA) {
418 if (osmesa->DataType == GL_UNSIGNED_BYTE) {
424 else if (osmesa->DataType == GL_UNSIGNED_SHORT) {
431 else if (osmesa->format == OSMESA_BGRA) {
432 if (osmesa->DataType == GL_UNSIGNED_BYTE) {
438 else if (osmesa->DataType == GL_UNSIGNED_SHORT) {
439 _mesa_warning(ctx, "Unsupported OSMesa format BGRA/GLushort");
443 _mesa_warning(ctx, "Unsupported OSMesa format BGRA/GLfloat");
447 else if (osmesa->format == OSMESA_ARGB) {
448 if (osmesa->DataType == GL_UNSIGNED_BYTE) {
454 else if (osmesa->DataType == GL_UNSIGNED_SHORT) {
455 _mesa_warning(ctx, "Unsupported OSMesa format ARGB/GLushort");
459 _mesa_warning(ctx, "Unsupported OSMesa format ARGB/GLfloat");
463 else if (osmesa->format == OSMESA_RGB) {
464 if (osmesa->DataType == GL_UNSIGNED_BYTE) {
467 else if (osmesa->DataType == GL_UNSIGNED_SHORT) {
468 _mesa_warning(ctx, "Unsupported OSMesa format RGB/GLushort");
472 _mesa_warning(ctx, "Unsupported OSMesa format RGB/GLfloat");
476 else if (osmesa->format == OSMESA_BGR) {
477 if (osmesa->DataType == GL_UNSIGNED_BYTE) {
480 else if (osmesa->DataType == GL_UNSIGNED_SHORT) {
481 _mesa_warning(ctx, "Unsupported OSMesa format BGR/GLushort");
485 _mesa_warning(ctx, "Unsupported OSMesa format BGR/GLfloat");
489 else if (osmesa->format == OSMESA_RGB_565) {
490 ASSERT(osmesa->DataType == GL_UNSIGNED_BYTE);
494 _mesa_problem(ctx, "bad pixel format in osmesa renderbuffer_storage");
500 compute_row_addresses( osmesa );
540 const OSMesaContext osmesa = OSMESA_CONTEXT(ctx);
543 /* this is an OSMesa renderbuffer which wraps user memory */
548 if (osmesa->userRowLength)
549 rowStride = osmesa->userRowLength * bpp;
553 if (!osmesa->yup) {
615 OSMesaContext osmesa;
684 osmesa = (OSMesaContext) CALLOC_STRUCT(osmesa_context);
685 if (osmesa) {
686 osmesa->gl_visual = _mesa_create_visual( GL_FALSE, /* double buffer */
700 if (!osmesa->gl_visual) {
701 free(osmesa);
712 if (!_mesa_initialize_context(&osmesa->mesa,
714 osmesa->gl_visual,
717 &functions, (void *) osmesa)) {
718 _mesa_destroy_visual( osmesa->gl_visual );
719 free(osmesa);
723 _mesa_enable_sw_extensions(&(osmesa->mesa));
724 _mesa_enable_1_3_extensions(&(osmesa->mesa));
725 _mesa_enable_1_4_extensions(&(osmesa->mesa));
726 _mesa_enable_1_5_extensions(&(osmesa->mesa));
727 _mesa_enable_2_0_extensions(&(osmesa->mesa));
728 _mesa_enable_2_1_extensions(&(osmesa->mesa));
730 osmesa->gl_buffer = _mesa_create_framebuffer(osmesa->gl_visual);
731 if (!osmesa->gl_buffer) {
732 _mesa_destroy_visual( osmesa->gl_visual );
733 _mesa_free_context_data( &osmesa->mesa );
734 free(osmesa);
741 _swrast_add_soft_renderbuffers(osmesa->gl_buffer,
743 osmesa->gl_visual->haveDepthBuffer,
744 osmesa->gl_visual->haveStencilBuffer,
745 osmesa->gl_visual->haveAccumBuffer,
749 osmesa->format = format;
750 osmesa->userRowLength = 0;
751 osmesa->yup = GL_TRUE;
752 osmesa->rInd = rind;
753 osmesa->gInd = gind;
754 osmesa->bInd = bind;
755 osmesa->aInd = aind;
757 _mesa_meta_init(&osmesa->mesa);
761 struct gl_context *ctx = &osmesa->mesa;
769 _mesa_destroy_visual(osmesa->gl_visual);
771 free(osmesa);
794 return osmesa;
801 * \param osmesa the context to destroy
804 OSMesaDestroyContext( OSMesaContext osmesa )
806 if (osmesa) {
807 if (osmesa->srb)
808 _mesa_reference_renderbuffer((struct gl_renderbuffer **) &osmesa->srb, NULL);
810 _mesa_meta_free( &osmesa->mesa );
812 _swsetup_DestroyContext( &osmesa->mesa );
813 _tnl_DestroyContext( &osmesa->mesa );
814 _vbo_DestroyContext( &osmesa->mesa );
815 _swrast_DestroyContext( &osmesa->mesa );
817 _mesa_destroy_visual( osmesa->gl_visual );
818 _mesa_reference_framebuffer( &osmesa->gl_buffer, NULL );
820 _mesa_free_context_data( &osmesa->mesa );
821 free( osmesa );
839 * Input: osmesa - the rendering context
848 * Return: GL_TRUE if success, GL_FALSE if error because of invalid osmesa,
853 OSMesaMakeCurrent( OSMesaContext osmesa, void *buffer, GLenum type,
856 if (!osmesa || !buffer ||
862 if (osmesa->format == OSMESA_RGB_565 && type != GL_UNSIGNED_SHORT_5_6_5) {
875 osmesa_update_state( &osmesa->mesa, 0 );
891 if (!osmesa->srb) {
892 osmesa->srb = new_osmesa_renderbuffer(&osmesa->mesa, osmesa->format, type);
893 _mesa_remove_renderbuffer(osmesa->gl_buffer, BUFFER_FRONT_LEFT);
894 _mesa_add_renderbuffer(osmesa->gl_buffer, BUFFER_FRONT_LEFT,
895 &osmesa->srb->Base);
896 assert(osmesa->srb->Base.RefCount == 2);
899 osmesa->DataType = type;
904 osmesa->srb->Buffer = buffer;
905 osmesa->srb->Base.Width = osmesa->srb->Base.Height = 0;
910 _mesa_resize_framebuffer(&osmesa->mesa, osmesa->gl_buffer, width, height);
911 osmesa->gl_buffer->Initialized = GL_TRUE; /* XXX TEMPORARY? */
913 _mesa_make_current( &osmesa->mesa, osmesa->gl_buffer, osmesa->gl_buffer );
918 _mesa_remove_renderbuffer(osmesa->gl_buffer, BUFFER_FRONT_LEFT);
919 _mesa_add_renderbuffer(osmesa->gl_buffer, BUFFER_FRONT_LEFT,
920 &osmesa->srb->Base);
924 _mesa_update_framebuffer_visual(&osmesa->mesa, osmesa->gl_buffer);
927 _mesa_resize_framebuffer(&osmesa->mesa, osmesa->gl_buffer, width, height);
949 OSMesaContext osmesa = OSMesaGetCurrentContext();
954 _mesa_error( &osmesa->mesa, GL_INVALID_VALUE,
958 osmesa->userRowLength = value;
961 osmesa->yup = value ? GL_TRUE : GL_FALSE;
964 _mesa_error( &osmesa->mesa, GL_INVALID_ENUM, "OSMesaPixelStore(pname)" );
968 compute_row_addresses( osmesa );
975 OSMesaContext osmesa = OSMesaGetCurrentContext();
979 if (osmesa->gl_buffer)
980 *value = osmesa->gl_buffer->Width;
985 if (osmesa->gl_buffer)
986 *value = osmesa->gl_buffer->Height;
991 *value = osmesa->format;
995 *value = osmesa->DataType;
998 *value = osmesa->userRowLength;
1001 *value = osmesa->yup;
1010 _mesa_error(&osmesa->mesa, GL_INVALID_ENUM, "OSMesaGetIntergerv(pname)");
1017 * Return the depth buffer associated with an OSMesa context.
1018 * Input: c - the OSMesa context
1055 * Return the color buffer associated with an OSMesa context.
1056 * Input: c - the OSMesa context
1063 osmesa, GLint *width,
1066 if (osmesa->srb && osmesa->srb->Buffer) {
1067 *width = osmesa->srb->Base.Width;
1068 *height = osmesa->srb->Base.Height;
1069 *format = osmesa->format;
1070 *buffer = (void *) osmesa->srb->Buffer;
1120 OSMesaContext osmesa = OSMesaGetCurrentContext();
1123 osmesa->mesa.Color.ClampFragmentColor = GL_TRUE;
1126 osmesa->mesa.Color.ClampFragmentColor = GL_FIXED_ONLY_ARB;