// 9.1.h
#import <Foundation/Foundation.h>
@interface Complex : NSObject
{
double real;
double imaginary;
}
@property double real, imaginary;
-(void) print;
-(void) setReal: (double) andImaginary: (double) b;
-(Complex *) add: (Complex *) f;
@end
Run Code Online (Sandbox Code Playgroud)
#import "9.1.h"
@implementation Complex
@synthesize real, imaginary;
-(void) print
{
NSLog(@ "%g + %gi ", real, imaginary);
}
-(void) setReal: (double) a andImaginary: (double) b
{
real = a;
imaginary = b;
}
-(Complex *) add: (Complex *) f
{
Complex *result = [[Complex alloc] init];
[result …
Run Code Online (Sandbox Code Playgroud) 我对 OpenGL 完全陌生,无法弄清楚将纹理和着色器绑定到 VBO 的工作原理。
我正在使用 Cinder 的纹理和着色器类。这是我的绘制方法的一部分:
mShader.bind();
myImage.bind();
glPushMatrix();
glTranslated( scaledX, scaledY, scaledZ);
gl::draw(sphere.getVBO());
glPopMatrix();
glPushMatrix();
glTranslated( 0, 0, zshift - 200);
mDisc.draw();
glPopMatrix();
Run Code Online (Sandbox Code Playgroud)
在上面的代码中,如果我注释掉对 mShader.bind() 的调用,我的球体 VBO 将显示纹理 (myImage)。我的着色器对于普通(无纹理)形状效果很好,但是当我在绘制任何带有包裹纹理的形状之前绑定着色器时,它会阻止纹理的显示。
这是我使用的着色器的问题,还是我不理解的其他问题?(……还有很多不明白的地方)
谢谢
编辑:
这是我正在使用的着色器:
(片段):
uniform sampler2DShadow depthTexture;
varying vec3 N, V, L;
varying vec4 q;
void main(void)
{
vec3 normal = normalize( N );
vec3 R = -normalize( reflect( L, normal ) );
vec4 ambient = gl_FrontLightProduct[0].ambient;
vec4 diffuse = gl_FrontLightProduct[0].diffuse * max(dot( normal, L), 0.0);
vec4 …
Run Code Online (Sandbox Code Playgroud)