Difference between revisions of "NeXTSTEP AppKit Framebuffer Window Depth"

 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
<pre>
 
Q:  How can my program tell whether it is running on a system with a color screen?
 
  
AThe PostScript graphics model allows you to do all your rendering in 24 bit color,  and have the WindowServer display it in the best way possible (dithering down to 2 bits,  if necessary).  If there are situations in which you need to use the "inquire and adapt" approach, the AppKit provides you with a method in the Application class called colorScreen that returns the most colorful screen available to your application.  By examining this data structure,  you can determine how deep your color screen is.  Below is a code fragment that does this:
+
'''QHow can my program tell whether it is running on a system with a color screen?'''
  
 +
The PostScript graphics model allows you to do all your rendering in 24 bit color,  and have the WindowServer display it in the best way possible (dithering down to 2 bits,  if necessary).  If there are situations in which you need to use the "inquire and adapt" approach, the AppKit provides you with a method in the Application class called colorScreen that returns the most colorful screen available to your application.  By examining this data structure,  you can determine how deep your color screen is.  Below is a code fragment that does this:
 +
<pre>
 
#import <appkit/Application.h>
 
#import <appkit/Application.h>
 
#import <appkit/screens.h>
 
#import <appkit/screens.h>
Line 29: Line 29:
 
}
 
}
 
}
 
}
 +
</pre>
  
 +
'''Q: How can I tell whether a View can display color or not?'''
  
Q: How can I tell whether a View can display color or not?
+
The previous question does not answer which kinds of rendering commands you should be sending for a given View.  There are two headed systems,  and other circumstances where the window you are drawing in is not based on the value of colorScreen. The most common thing you want to do is different rendering based on whether this View can display color or not.  One way to do this is to use the shouldDrawColor method of View.  Do the following in your drawSelf:: method for the View:
 
+
<pre>
A: The previous question does not answer which kinds of rendering commands you should be sending for a given View.  There are two headed systems,  and other circumstances where the window you are drawing in is not based on the value of colorScreen. The most common thing you want to do is different rendering based on whether this View can display color or not.  One way to do this is to use the shouldDrawColor method of View.  Do the following in your drawSelf:: method for the View:
 
 
 
 
- drawSelf:(NXRect *)rects :(int)count
 
- drawSelf:(NXRect *)rects :(int)count
 
{
 
{
Line 44: Line 44:
 
    ...
 
    ...
 
}
 
}
 
+
</pre>
 
If you need to know  the actual depth of a given window,  use the  depthLimit method of Window. Here's some code for that:
 
If you need to know  the actual depth of a given window,  use the  depthLimit method of Window. Here's some code for that:
 
+
<pre>
 
NXWindowDepthLimit depth;
 
NXWindowDepthLimit depth;
 
if ((depth = [myWindow depthLimit]) == NX_DefaultDepth) {
 
if ((depth = [myWindow depthLimit]) == NX_DefaultDepth) {
 
depth = [Window defaultDepthLimit];
 
depth = [Window defaultDepthLimit];
 
}
 
}
 
+
</pre>
 
QA700
 
QA700
  
 
Valid for 2.0, 3.0
 
Valid for 2.0, 3.0
</pre>
+
 
  
 
[[Category:Computing]][[Category:NeXT]]
 
[[Category:Computing]][[Category:NeXT]]

Latest revision as of 23:04, 20 July 2019

Q: How can my program tell whether it is running on a system with a color screen?

The PostScript graphics model allows you to do all your rendering in 24 bit color, and have the WindowServer display it in the best way possible (dithering down to 2 bits, if necessary). If there are situations in which you need to use the "inquire and adapt" approach, the AppKit provides you with a method in the Application class called colorScreen that returns the most colorful screen available to your application. By examining this data structure, you can determine how deep your color screen is. Below is a code fragment that does this:

	#import <appkit/Application.h>
	#import <appkit/screens.h>
	...
	{
		const NXScreen *deepestScreen;
	
		deepestScreen=[NXApp colorScreen];
	
		switch ( deepestScreen->depth ) {
	
			case NX_TwelveBitRGBDepth :
				/* Twelve Bit Color */
				break;
			
			case NX_TwentyFourBitRGBDepth :
				/* True Color */
				break;
			
			case NX_TwoBitGrayDepth :
			default :
				/* Greyscale */
				break;
			
			}
	}	

Q: How can I tell whether a View can display color or not?

The previous question does not answer which kinds of rendering commands you should be sending for a given View. There are two headed systems, and other circumstances where the window you are drawing in is not based on the value of colorScreen. The most common thing you want to do is different rendering based on whether this View can display color or not. One way to do this is to use the shouldDrawColor method of View. Do the following in your drawSelf:: method for the View:

	- drawSelf:(NXRect *)rects :(int)count
	{
	 	if ([self shouldDrawColor]) {
		... color-specific drawing ...
	  	} else {
	   	      ...
	    	}
	    	...
	}

If you need to know the actual depth of a given window, use the depthLimit method of Window. Here's some code for that:

	NXWindowDepthLimit 	depth;
	if ((depth = [myWindow depthLimit]) == NX_DefaultDepth) {
		depth = [Window defaultDepthLimit];
	}

QA700

Valid for 2.0, 3.0