68user's page 掲示板

Prev< No. 1813〜1818> Next  [最新発言に戻る] [過去ログ一覧]
No. 1813 # Yuuki [E-mail] 2001/03/12 (月) 14:35:37
>>1810 68user
> XDrawString/XmbDrawString に与える原点 x,y は、文字列の左下の
> 座標を与えます。
今まで左上にだと思いこんでました…。

> そこらへんの情報はXmbTextExtents で取得できます。
これで解決しました。
http://homepage1.nifty.com/tyuuki/tmp/drawstr.c
このようになりました。

ありがとうございます。

No. 1814 # 68user 2001/03/12 (月) 22:35:33
>>1813 Yuuki
> これで解決しました。
> http://homepage1.nifty.com/tyuuki/tmp/drawstr.c
http://homepage1.nifty.com/tyuuki/tmp/drawstr2.c ですよね。
誠に勝手ながら、後から見た人のために drawstr2.c を貼っておきます。
行数短縮のため、少々コードスタイルをいじらせていただきました。
もしまずければ削除いたします。

----
#include <stdio.h>
#include <locale.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>

static XFontSet load_font( Display *display, const char *font_names ){
        char **miss_str;
        int miss_cnt;
        char *def_str;
        return XCreateFontSet( display, font_names,
                                      &miss_str, &miss_cnt, &def_str );
}

static int ask_text_height( XFontSet font, const char *str ){
        XRectangle rect;
        XmbTextExtents( font, str, strlen( str ), &rect, NULL );
        return rect.height;
}

int main( int argc, char **argv ){
        Display *display;
        Window window;
        GC gc, gc_clr;
        unsigned long background, foreground;
        XFontSet font;
        Pixmap pixmap;
        const int width = 640;
        const int height = 480;
        const char *message = "こんにちは。";

        if ( setlocale( LC_CTYPE, "" ) == NULL ){
                printf( "setlocale error\n" );
                exit( 0 );
        }
        display = XOpenDisplay( NULL );
        font = load_font( display, "-misc-fixed-medium-r-normal--14-*-*-*-*-*-*-*,*" );
        background = WhitePixel( display, 0 );
        foreground = BlackPixel( display, 0 );

        window = XCreateSimpleWindow( display, DefaultRootWindow( display ),
                                            0, 0, width, height, 0, 0, background );
        pixmap = XCreatePixmap( display, window, width, height,
                                DefaultDepth( display, 0 ) );

        gc = XCreateGC( display, window, 0, 0 );
        XSetBackground( display, gc, background );
        XSetForeground( display, gc, foreground );

        gc_clr = XCreateGC( display, window, 0, 0 );
        XSetBackground( display, gc_clr, background );
        XSetForeground( display, gc_clr, background );

        XMapRaised( display, window );
        XSelectInput( display, window, ExposureMask );
        while ( 1 ){
                XEvent event;
                XNextEvent( display, &event );
                switch ( event.type ){
                case Expose :
                        XFillRectangle( display, pixmap, gc_clr, 0, 0, width, height );
                        XmbDrawString( display, pixmap, font, gc,
                                              0, ask_text_height( font, message ),
                                              message, strlen( message ) );
                        XCopyArea( display, pixmap, window, gc, 0, 0, width, height, 0, 0 );
                        break;
                }
        }
}

No. 1815 # Yuuki [E-mail] 2001/03/13 (火) 19:02:24
>>1814 68user
> http://homepage1.nifty.com/tyuuki/tmp/drawstr2.c ですよね。
すいません。
間違えていました…。

> もしまずければ削除いたします。
全然まずくないです。

今までのファイルをまとめておきました。
http://homepage1.nifty.com/tyuuki/archive/drawstr.tar.gz

No. 1816 # taka 2001/03/13 (火) 23:30:24
FreeBSD4.2R をインストールしたのですが、サウンドの設定がよくわからずつ
まずいてしまいました。いろいろHPや書籍を調べて以下のような処理を行いま
したが、以前としてサウンドが鳴りません。設定で間違っている箇所が
あれば指摘して頂きたいです。ちなみに、サウンドカードはYamahaのYMF740です。

1. カーネルの再構築
      # cd /usr/src/sys/i386/conf/
      # cp GENERIC MY_KERNEL
      # vi MY_KERNEL
          -------------------------
          以下の内容を追加
          # For PnP/PCI sound cards
          device pcm
          -------------------------
      # config MY_KERNEL
      # cd ../../compile/MY_KERNEL
      # make depend
      # make install

2. デバイスファイルの作成
      # cd /dev
      # ./MAKEDEV snd0

以下は関係ありそうなエラーログです。
> dmesg | grep pcm
pcm0: <Yamaha DS-1 (YMF740?)> irq 9 at device 10.0 on pci0
pcm0: unable to map register space
device_probe_and_attach: pcm0 attach returned 6

> cat /dev/sndstat
cat: /dev/sndstat: Device not configured

No. 1817 # 68user 2001/03/14 (水) 00:29:16
>>1816 taka
> FreeBSD4.2R をインストールしたのですが、サウンドの設定が
> よくわからずつまずいてしまいました。
えっと、サウンド・PnP まわりはいまだに何がなにやらわかりません。
うちでは device pcm を追加し、OS ブート時に boot -cv でコンフィグ
モードにして
    > pnp 1 0 bios enable irq0 5 drq0 1 port0 0x220 port1 0x0 port2 0x388
と設定しました。

なんで IRQ が 5 なのか、なんで PnP なのに手動で設定しないと
いけないのかさっぱりわかりません。pnpinfo(8) の出力も全く理解
できないし…。

僕は、IRQ って ISA のみにしかない概念? PCI のサウンドカードって
あるの? …てな知識レベルなので、FreeBSD-users-jp などで質問された
方が早いかもしれません。

どこかにわかりやすい解説はないかなぁ。

No. 1818 # rosegarden 2001/03/14 (水) 01:32:44
>>1816 taka
私の場合次のようになっています。もっとも 4.3-BETA ですが、
要領は同じだと思います。

# For non-pnp sound cards with no bridge drivers only:
device pcm0 at isa? irq 10 drq 1 flags 0x0
#
# For PnP/PCI sound cards
device pcm

# The bridge drivers for sound cards. These can be seperately configured
# for providing services to the likes of new-midi (not in the tree yet).
# When used with 'device pcm' they also provide pcm sound services.
#
# sbc: Creative SoundBlaster ISA PnP/non-PnP
# Supports ESS and Avance ISA chips as well.
# gusc: Gravis UltraSound ISA PnP/non-PnP
# csa: Crystal Semiconductor CS461x/428x PCI

# For non-PnP cards:
device sbc0 at isa? port 0x220 irq 5 drq 1 flags 0x15
#device gusc0 at isa? port 0x220 irq 5 drq 1 flags 0x13

sbc ドライバか gusc ドライバのいずれかを有効にしてみてください。
このへんは試行錯誤がいるかもしれません。
LINT から関係する部分を copy&paste してきて
自分に関係ない部分をコメントアウトすると面倒ないです。

Prev< No. 1813〜1818> Next  [最新発言に戻る] [過去ログ一覧]