[comp.sys.next] dspwrap without the appkit

pts@mendel.acc.Virginia.EDU (Paul T. Shannon) (11/29/90)

I'm looking for a simple program which shows how to use pswraps
*outside* of the application kit and Interface Builder.   I understand
how to write postScript code, convert it to C using pswrap, and then
compile and link to form an executable file.  What I don't understand,
however, is how to establish the proper context, which (I guess) 
is a connection between my program and the Display Postscript Interpreter.

For those curious, or skeptical,  I want to do this so that I can
use the entire display, with as little interference and overhead as 
possible, to present full-screen visual stimuli for experiments in 
perceptual psychology.  

A good example of the sort of full-screen use I'm after is in the file

  /NextLibrary/Images/Scene_movies/snake.script.ps

But what I'd like to do is to take that (or similar) postscript code,
pswrap it, and run it from a fast-loading C program, rather than out
of Preview.  Can anyone help me on this?  Thanks.

 - Paul Shannon
   pts@virginia.edu

wjs@milton.u.washington.edu (William Jon Shipley) (11/29/90)

Paul T. Shannon writes:
>I'm looking for a simple program which shows how to use pswraps
>*outside* of the application kit and Interface Builder.   I understand
>how to write postScript code, convert it to C using pswrap, and then
>compile and link to form an executable file.  What I don't understand,
>however, is how to establish the proper context, which (I guess) 
>is a connection between my program and the Display Postscript Interpreter.
>
>For those curious, or skeptical,  I want to do this so that I can
>use the entire display, with as little interference and overhead as 
>possible, to present full-screen visual stimuli for experiments in 
>perceptual psychology.  

Well, I hate to sound like the NeXT Thought Police (TM), but I wouldn't
recommend you go outside the appkit for this project.

Why?  Because it's much cleaner and easier to do it inside the appkit.
I don't think you will gain any speed going around the appkit, either.

Following is a description of how to make your window the size of the whole
screen, and titlebarless.  This will have the same effect as being able
to write to the screen itself, except you'll have the convienience of
using a Window.

What I think you want to do is go ahead and use the IB to get a nice
shell of a program, but create a new subclass of window in IB, calling
it, say, "BigWindow".  Make your main window (called MyWindow, probably)
an instance of class BigWindow in the Inspector panel (select the window
down amongst the icons in the lower right, hit command-1, change class).

Unparse your BigWindow class in IB, then get into Edit (or emacs) and edit
BigWindow.m.

Rewrite the newContent:... method as follows:

+ newContent:(const NXRect *)contentRect 
	style:(int)aStyle 
	backing:(int)bufferingType 
	buttonMask:(int)mask 
	defer:(BOOL)flag
{
  NXRect	cRect, fRect;

  // We want our new window to be the size of the whole screen.
  [NXApp getScreenSize:&fRect.size];

  // But we create a window by specifying the content size, so we get that.
  [BigWindow getContentRect:&cRect forFrameRect:&fRect style:NX_PLAINSTYLE];

  // Create an untitled window the size of the screen
  return [super newContent:&cRect style:NX_PLAINSTYLE backing:bufferingType
    buttonMask:mask defer:flag];
}


Now your main window will cover the whole screen, and not have an annoying (to
you) title bar, and yet you still get to use the appkit (big win!) and not
try to create your own context with the window server (big win too!).

Warning: I'm just writing this off the top of my head, I haven't tried any of
it.

-william shipley
just a regular guy who really wouldn't mind working for NeXT developer support

mdixon@parc.xerox.com (Mike Dixon) (11/29/90)

    I'm looking for a simple program which shows how to use pswraps
    *outside* of the application kit and Interface Builder.

checkout hackkit.tar.Z in the next/sources directory at your favorite
ftp site.  from the README file:

The HACKKIT
Written by Bill Spitzak (SPITZAK@MCIMAIL.COM), Summer 1989.

Main features:

DIS : a powerful symbolic disassembler, specially designed for looking at
mysterious library objects (although it can also disassemble executables).

ICONCLOCK : App that draws a clock in it's own icon, yet can be resized to
make larger clocks.  The clock appearance is in a postscript file and may
be edited to customize it.

SOURCE CODE: Lots of short, self-contained, source files that demonstrate
how to interface with the PostScript server, the Workspace, and the Pasteboard,
without using the AppKit routines or "objective C".
--

                                             .mike.

wiml@milton.u.washington.edu (William Lewis) (11/29/90)

In article <1990Nov28.234910.28347@murdoch.acc.Virginia.EDU> pts@mendel.acc.Virginia.EDU (Paul T. Shannon) writes:
>                                  ... What I don't understand,
>however, is how to establish the proper context, which (I guess) 
>is a connection between my program and the Display Postscript Interpreter.

   DPSCreateContext() is what you want. I'm not very clear on what the
PS*() routines think the "current context" is, but if you only have one
context open I think it's usually that one.

>For those curious, or skeptical,  I want to do this so that I can
>use the entire display, with as little interference and overhead as 
>possible, to present full-screen visual stimuli for experiments in 
>perceptual psychology.  

   Well, if you *really* want as little interference and overhead
(or help from the OS) as possible, check out the DKIOCGADDR ioctl, 
defined in <nextdev/video.h> (which only works on /dev/vid0). This
will give you the address of the video RAM, to which you can directly
write. Pretty fast, especially if the windowserver is quiescent or
not running (ie. user is logged in from console). Beware that if you 
do this you'll get flakes of image all over your screen that you'll have
to wipe off with your frontwindow, unless you create a fullscreen
window in front of the screen first to use as a tarpaulin. 
(Actually, you'll almost certainly want to do that: any exposed
portions of Retained windows that get overwritten in this way will
*stay* overwritten -- no backing store, you see =8) and the image has
effectively been blitted right into the window buffer. I'm still trying
to think of a use for this. IMHO, there should be some way to map
the windowserver's buffers for certain windows into your process's
address space... on the other hand, all this circumvents all the wonderful
things we all know love and use about PostScript. sigh, the price of
portability is control) 
   If you (or anyone else reading this message, since I do seem to
be posting it to the net) want some sample code, I have some poorly-
written stuff that puts PBMs on the screen and does sort of 2-entry
CLUT animation with them.

>A good example of the sort of full-screen use I'm after is in the file
>  /NextLibrary/Images/Scene_movies/snake.script.ps
>But what I'd like to do is to take that (or similar) postscript code,
>pswrap it, and run it from a fast-loading C program, rather than out
>of Preview.  Can anyone help me on this?  Thanks.

   Also take a look at 'pft'. You should be able to do

pft -f /full/path/name/myFunFile.ps -s 

   to run a postscript program without invoking Preview. Note that the
program run this way has to do its own window creation, but most movies
seem to do that anyway.

   
  Flames about portability and philosophy to /dev/vid0.
-- 
 wiml@milton.acs.washington.edu       Seattle, Washington   
     (William Lewis)   |  47 41' 15" N   122 42' 58" W  
"These 2 cents will cost the net thousands upon thousands of 
dollars to send everywhere. Are you sure you want to do this?"