Beispiel #1
0
static void
make_current(GLXContext ctx, Display *dpy, GLXDrawable draw, GLXDrawable read)
{
	gl_context_t *glc;

	glc=(gl_context_t*)pthread_getspecific(ctx_current);
	if (glc) {
		/* old context */
		glc->flags &= ~GH_GL_CURRENT;
		GH_verbose(GH_MSG_DEBUG, "unbound context %p\n",glc->ctx);
	}
	
	if (ctx) {
		glc=find_ctx(ctx);

		if (glc == NULL) {
			GH_verbose(GH_MSG_WARNING, "app tried to make current non-existing context %p\n",ctx);
		} else {
			glc->draw=draw;
			glc->read=read;
			glc->flags |= GH_GL_CURRENT;
			GH_verbose(GH_MSG_DEBUG, "made current context %p\n",ctx);
			if (glc->flags & GH_GL_NEVER_CURRENT) {
				unsigned int ft_delay=get_envui("GH_FRAMETIME_DELAY", 10);
				unsigned int ft_frames=get_envui("GH_FRAMETIME_FRAMES", 1000);
				GH_frametime_mode ft_mode=(GH_frametime_mode)get_envi("GH_FRAMETIME", (int)GH_FRAMETIME_NONE);
				int latency=get_envi("GH_LATENCY", GH_LATENCY_NOP);
				unsigned int latency_wait_interval=get_envui("GH_LATENCY_WAIT_USECS", 0);
				/* made current for the first time */
				glc->flags &= ~ GH_GL_NEVER_CURRENT;

				glc->swap_sleep_usecs=(useconds_t)get_envui("GH_SWAP_SLEEP_USECS",0);
				frametimes_init(&glc->frametimes, ft_mode, ft_delay, GH_FRAMETIME_COUNT, ft_frames, glc->num);
				frametimes_init_base(&glc->frametimes);
				latency_init(&glc->latency, latency, latency_wait_interval);
				if (glc->inject_swapinterval != GH_SWAP_DONT_SET) {
					GH_GET_PTR_GL(glXSwapIntervalEXT);
					if (GH_glXSwapIntervalEXT) {
						GH_verbose(GH_MSG_INFO, "injecting swap interval: %d\n",
								glc->inject_swapinterval);
						GH_glXSwapIntervalEXT(dpy, glc->draw, glc->inject_swapinterval);
					} else {
						GH_GET_PTR_GL(glXSwapIntervalSGI);
						if (GH_glXSwapIntervalEXT) {
							GH_verbose(GH_MSG_INFO, "injecting swap interval: %d\n",
									glc->inject_swapinterval);
							GH_glXSwapIntervalSGI(glc->inject_swapinterval);
						}
					}
				}
			}
		}
	} else {
		glc=NULL;
	}

	pthread_setspecific(ctx_current, glc);
}
Beispiel #2
0
static void output_ctx_hdr(
/*************************/

    ctx_def                     *ctx
) {
    ctx_def                     *temp_ctx;
    ctx_def                     *prev;      // for << button
    ctx_def                     *next;      // for >> button

    // output topic name
    whp_fprintf( Out_file, "::::\"" );
    str_out_ib( Out_file, ctx->title );
    whp_fprintf( Out_file, "\" 0 0\n" );

    // Header stuff:
    if( Do_tc_button
        || Do_idx_button
        || Do_browse
        || Do_up
        || Header_File[0] != '\0' ) {

        //beginning of header
        whp_fprintf( Out_file, ":h\n" );

        if( Do_tc_button ) {
            if( stricmp( ctx->ctx_name, "table_of_contents" ) != 0 ) {
                whp_fprintf( Out_file,
                                "%c" HB_CONTENTS "%cTable of Contents%c ",
                                Hyper_Brace_L,
                                CHR_HLINK_BREAK,
                                Hyper_Brace_R );
            } else {
                fake_hlink( Out_file, HB_CONTENTS );
            }
        }

        if( Do_kw_button ) {
            if( stricmp( ctx->ctx_name, "keyword_search" ) != 0 ) {
                whp_fprintf( Out_file,
                                "%c" HB_KEYWORDS "%cKeyword Search%c ",
                                Hyper_Brace_L,
                                CHR_HLINK_BREAK,
                                Hyper_Brace_R );
            } else {
                fake_hlink( Out_file, HB_KEYWORDS );
            }
        }

        if( Do_browse ) {
            find_browse_pair( ctx, &prev, &next );

            // << browse button
            if( prev != ctx ) {
                whp_fprintf( Out_file, "%c" HB_PREV "%c", Hyper_Brace_L,
                                CHR_HLINK_BREAK );
                str_out_ib( Out_file, prev->title );
                whp_fprintf( Out_file, "%c ", Hyper_Brace_R );
            } else {
                fake_hlink( Out_file, HB_PREV );
            }

            // >> browse button (relies on the find_browse_pair above)
            if( next != ctx ) {
                whp_fprintf( Out_file, "%c" HB_NEXT "%c", Hyper_Brace_L,
                                CHR_HLINK_BREAK );
                str_out_ib( Out_file, next->title );
                whp_fprintf( Out_file, "%c ", Hyper_Brace_R );
            } else {
                fake_hlink( Out_file, HB_NEXT );
            }
        }

        if( Do_idx_button ) {
            if( stricmp( ctx->ctx_name, "index_of_topics" ) != 0 ) {
                whp_fprintf( Out_file,
                                "%c" HB_INDEX "%cIndex of Topics%c ",
                                Hyper_Brace_L,
                                CHR_HLINK_BREAK,
                                Hyper_Brace_R );
            } else {
                fake_hlink( Out_file, HB_INDEX );
            }
        }

        // "Up" button
        if( Do_up ) {
            // find "parent" context
            for( temp_ctx = ctx->up_ctx; temp_ctx != NULL;
                                        temp_ctx = temp_ctx->up_ctx ) {
                if( !Remove_empty || !temp_ctx->empty ) {
                    break;
                }
            }

            // use table_of_contents if no "parent" context
            if( temp_ctx == NULL ) {
                temp_ctx = find_ctx( "table_of_contents" );
                if( temp_ctx == ctx) {
                    temp_ctx = NULL;
                }
            }

            // spit out up button stuff
            if( temp_ctx != NULL ) {
                whp_fprintf( Out_file, "%c" HB_UP "%c",
                                        Hyper_Brace_L, CHR_HLINK_BREAK );
                str_out_ib( Out_file, temp_ctx->title );
                whp_fprintf( Out_file, "%c ", Hyper_Brace_R );
            } else {
                fake_hlink( Out_file, HB_UP );
            }
        }
        // append user header file
        ib_append_line( Out_file, Header_File );

        // end of header
        whp_fprintf( Out_file, "\n:eh\n" );
    }
    // append user footer file
    if( Footer_File[0] != '\0' ) {
        whp_fprintf( Out_file, ":f\n" );
        ib_append_line( Out_file, Footer_File );
        whp_fprintf( Out_file, "\n:ef\n" );
    }
}
Beispiel #3
0
static void output_section_ib( section_def *section )
/***************************************************/
{
    int                         len;
    ctx_def                     *ctx;
    unsigned int                line;
    unsigned char               *label;
    int                         label_len;
    int                         ch;
    char                        *file;
    char                        *topic;
    unsigned char               *p;
    unsigned char               *end;

    p = (unsigned char *)section->section_text;
    end = p + section->section_size;
    len = 0;
    while( p + len < end ) {
        // stop when we hit a hyper-link
        if( *(p + len) != CHR_TEMP_HLINK ) {
            len++;
        } else {
            // write out the block of text we've got so far
            whp_fwrite( p, 1, len, Out_file );
            p += len + 1;

            // grab the line number
            for( len = 0; ; ++len ) {
                if( *(p + len) == CHR_TEMP_HLINK ) {
                    break;
                }
            }
            p[ len ] = '\0';
            line = atoi( (char *)p );
            p += len + 1;

            // find the length of the link label (what the user sees)
            for( len = 0; ; ++len ) {
                if( *(p + len) == CHR_HLINK_BREAK ) {
                    break;
                }
            }

            // if we're using the brace mode we strip off the "XX"
            if( Hyper_Brace_L == '<' ) {
                p += 2;
                len -= 2;
            }

            // output the label and the break
            label = p;
            label_len = len + 1;
            p += len + 1;

            // find the length of the link context
            for( len = 0; ; ++len ) {
                ch = *(p + len);
                if( ch == CHR_TEMP_HLINK || ch == CHR_HLINK_BREAK ) {
                    break;
                }
            }
            // null terminate the context name, and find the associated topic
            *(p + len) = '\0';
            topic = (char *)p;
            ctx = find_ctx( topic );

            // output the topic name that belongs to the context
            if( ctx == NULL && ch != CHR_HLINK_BREAK ) {
                warning( "Link to nonexistent context", line );
                printf( "For topic=%s\n", topic );
                whp_fwrite( label, 1, label_len - 1, Out_file );
            } else {
                // now we start writing the hyper-link
                whp_fwrite( &Hyper_Brace_L, 1, 1, Out_file );
                whp_fwrite( label, 1, label_len, Out_file );
                if( ctx != NULL ) {
                    str_out_ib( Out_file, ctx->title );
                } else {
                    str_out_ib( Out_file, topic );
                }
                if( ch == CHR_HLINK_BREAK ) {
                    /* file link. Get the file name */
                    file = (char *)(p + len + 1);
                    for( ;; ) {
                        ++len;
                        if( *(p + len) == CHR_TEMP_HLINK ) {
                            break;
                        }
                    }
                    *(p + len) = '\0';
                    whp_fprintf( Out_file, "%c%s", CHR_HLINK_BREAK, file );
                }
                whp_fwrite( &Hyper_Brace_R, 1, 1, Out_file );
            }

            // adjust the len and ctr counters appropriately
            p += len + 1;
            len = 0;
        }
    }
    // output whatever's left
    if( p < end ) {
        whp_fwrite( p, 1, end - p, Out_file );
    }
}