Cg學習記錄003 之Varying引數

2021-04-20 01:57:50 字數 734 閱讀 2872

其實在cg中是沒有varying這種型別限制符的。

如何讓程式不僅僅輸出乙個單一的顏色,而是可以隨頂點改變的顏色或紋理座標集呢?

cg教程中給出如下範例:

// this is c3e2v_varying from "the cg tutorial" (addison-wesley, isbn

// 0321194969) by randima fernando and mark j. kilgard.  see page 65.

struct c3e2v_output ;

c3e2v_output c3e2v_varying(float2 position : position,

float3 color    : color,

float2 texcoord : texcoord0)

color和texcoord0分別對應著程式指定的頂點顏色和紋理座標集0。

在應用程式中這樣指定顏色就好了:

glbegin(gl_********s);

glcolor3f(1, 0, 0);  /* red */

glvertex2f(-0.8, 0.8);

glcolor3f(0, 1, 0);  /* green */

glvertex2f(0.8, 0.8);

glcolor3f(0, 0, 1);  /* blue */

glvertex2f(0.0, -0.8);

glend();

Reactjs學習記錄(003)

var foo delete rowbutton onclick delete rowbutton 來為事件處理函式傳遞引數 ebind popper extends react.component preventpop name,e render href onclick clicka div 由...

CG學習記錄(一)資料型別

1.float 32位浮點數,乙個符號位 2.half 16位浮點數 3.int 32位整型資料 4.fixed 12位定點數 5.bool 布林值 6.sampler 紋理物件控制代碼 包括sampler,sampler1d,sample2d,sample3d,samplecube,sampler...

oracle學習記錄之十三

約束 create table goods goodsid char 8 primary key,主鍵 goodsname varchar2 20 unitprice number 10,2 check unitprice 0 檢查 category varchar2 10 vendor varch...