OPENGL ES之繪製金字塔

2021-07-23 07:27:51 字數 2539 閱讀 2340

今天比照著教材畫了乙個金字塔,這個案例主要涉及到了圖形變換矩陣的使用。但是其中遇到了一些問題不甚明了,在我自己的**中,我設定了view.drawabledepth=glkviewdrawabledepth16,結果繪製出來的圖案給人的感覺是從三角形底部看去的,把設定繪製深度的**注釋掉,則我的**的表現與教材上面一致,下面貼下工程的全部**,如果有人知道為什麼,懇請賜教。
#import "viewcontroller.h"

@inte***ce viewcontroller ()

@property(nonatomic,strong)glkbaseeffect *baseeffect;

@end

typedef structscenevertex;

typedef struct scene********;

static const scenevertex vertexa =

, };

static const scenevertex vertexb =

, };

static const scenevertex vertexc =

, };

static const scenevertex vertexd =

, };

static const scenevertex vertexe =

, };

static const scenevertex vertexf =

, };

static const scenevertex vertexg =

, };

static const scenevertex vertexh =

, };

static const scenevertex vertexi =

, };

static scene******** scene********make(const scenevertex vertexa,const scenevertex vertexb,const scenevertex vertexc);

static void caculatenormalfor********s(scene******** *********);

@implementation viewcontroller

@synthesize baseeffect;

- (void)viewdidload

glenable(gl_depth_test);

gluint position;

glgenbuffers(1, &position);

glbindbuffer(gl_array_buffer, position);

glbufferdata(gl_array_buffer, sizeof(********s), ********s, gl_dynamic_draw);

glenablevertexattribarray(glkvertexattribposition);

glvertexattribpointer(glkvertexattribposition, 3, gl_float, gl_false, sizeof(scenevertex), null+offsetof(scenevertex, position));

glenablevertexattribarray(glkvertexattribnormal);

glvertexattribpointer(glkvertexattribnormal, 3, gl_float,gl_false, sizeof(scenevertex), null+offsetof(scenevertex, normal));

}- (ibaction)rotate:(id)sender

-(void)glkview:(glkview *)view drawinrect:(cgrect)rect

- (void)didreceivememorywarning

- (ibaction)low:(id)sender

glbufferdata(gl_array_buffer, sizeof(********s), ********s, gl_static_draw);

}- (ibaction)frustum:(id)sender

- (ibaction)far:(id)sender

- (ibaction)high:(id)sender

glbufferdata(gl_array_buffer, sizeof(********s), ********s, gl_static_draw);

}- (ibaction)near:(id)sender

@end

static scene******** scene********make(const scenevertex vertexa,const scenevertex vertexb,const scenevertex vertexc)

static void caculatenormalfor********s(scene******** *********)

python 金字塔 Python金字塔

托倫,函式中有幾個小錯誤和乙個邏輯問題print y to a 請注意,此函式生成乙個以z開頭的字串,但您希望將字串以相反的方向連線,而您的另乙個函式print a to y 確實停止了 1位置 例如 還要注意,您需要新增新行字元 n 以獲得一些不錯的輸出。在 我的解決方案是 def print a...

字母金字塔(類同數字金字塔)

問題描述 讓程式要求使用者輸入乙個大寫字母,使用巢狀迴圈產生像下面這樣的金字塔圖案 aaba abcba abcdba abcdecba 演算法分析 每行包括三個部分內容 若干個空格 正序排列的字母 倒序排列的字幕。使用乙個外部迴圈來處理行,在每乙個行中使用三個內部迴圈 乙個處理空格,乙個以公升序列...

數字金字塔

觀察下面的數字金字塔。寫乙個程式來查詢從最高點到底部任意處結束的路徑,使路徑經過數字的和最大。每一步可以走到左下方的點也可以到達右下方的點。7 3 8 8 1 0 2 7 4 4 4 5 2 6 5在上面的樣例中,從7 到 3 到 8 到 7 到 5 的路徑產生了最大 多組輸入資料 第乙個行包含 r...