Beispiel #1
0
void setupRC()
{
	expCounter = counterLoader();

	//BG:
	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

	//Enable depth testing so things won't look effed up:
	glEnable(GL_DEPTH_TEST);
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_SRC_COLOR);

	//Initialize stock shaders from GLTools:
	shaderManager.InitializeStockShaders();
	
	//Move cam back:
	cameraFrame.MoveForward(-30.0f);
	cameraFrame.MoveRight(-5.0f);
	cameraFrame.MoveUp(-8.0f);

	newDeskButton.init(20, 80, 165, 70, "Assets/button_new_desk165x70.tga");
	removeDeskButton.init(208, 80, 175, 67, "Assets/button_remove_desk175x67.tga");
	exportButton.init(403, 80, 168, 67, "Assets/button_export168x67.tga");

	M3DVector4f deskShine = {0.5, 0.5, 0.5, 1.0};
	M3DVector4f deskColor = {0.0f, 0.0f, 0.5f, 1.0f};

	hlGrid.init(0.0f, 0.0f, 0.0f, C_DM/2);
	cRoom.init();
	stuDesks.init(deskColor, deskShine, C_DM/2);
}
Beispiel #2
0
void mouseCameraFunc(int x, int y)
{
	if (mouseActive)
	{
		GLfloat angle = 0.005f;

		if (x > W_WIDTH/2)
		{
			cameraFrame.RotateWorld(-angle*(x-W_WIDTH/2), 0, 0, 1);
			glutWarpPointer(W_WIDTH/2, W_HEIGHT/2);
		}
		else if (x < W_WIDTH/2)
		{
			cameraFrame.RotateWorld(angle*(W_WIDTH/2-x), 0, 0, 1);
			glutWarpPointer(W_WIDTH/2, W_HEIGHT/2);
		}
		if (y > W_HEIGHT/2 && pitch < 90)
		{
			cameraFrame.RotateLocalX(-angle*(W_HEIGHT/2-y));
			glutWarpPointer(W_WIDTH/2, W_HEIGHT/2);
			pitch = pitch + (-angle*(W_HEIGHT/2-y));
		}
		else if (y < W_HEIGHT/2 && pitch > -90)
		{
			cameraFrame.RotateLocalX(angle*(y-W_HEIGHT/2));
			glutWarpPointer(W_WIDTH/2, W_HEIGHT/2);
			pitch = pitch + (angle*(y-W_HEIGHT/2));
		}
	}
}
jboolean Java_android_filterfw_core_GLFrame_setNativeTextureParam(JNIEnv* env,
                                                                  jobject thiz,
                                                                  jint param,
                                                                  jint value) {
  GLFrame* frame = ConvertFromJava<GLFrame>(env, thiz);
  return frame ? ToJBool(frame->SetTextureParameter(param, value)) : JNI_FALSE;
}
void RenderScene(void) {
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
	glEnable( GL_DEPTH_TEST ) ;
	glUseProgram(shader);
	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

	float angle = timer.GetElapsedSeconds();

	M3DVector3f eye = {cos(angle)*4.0f,sin(angle)*4.0,sin(angle)*4.0f}; 
	M3DVector3f at = {0,0,0}; 
	M3DVector3f up = {0.0f,0.0f,1.0f};

	GLFrame cameraFrame;
	LookAt(cameraFrame, eye, at, up);
	cameraFrame.GetCameraMatrix(cameraMatrix);
	
	m3dMatrixMultiply44(matrix, viewFrustum.GetProjectionMatrix(), cameraMatrix);

	M3DMatrix44f tMatrix;
	m3dTranslationMatrix44(tMatrix, 0, 0, 0);
	m3dMatrixMultiply44(matrix, tMatrix, matrix);

	if((sin(angle) < 0 && sin(angle-0.003) > 0) || (sin(angle) > 0 && sin(angle-0.003) < 0)) {
		debugMatrix44(matrix);
	}

	glUniformMatrix4fv(MVPMatrixLocation,1,GL_FALSE,matrix);

//	drawGrid(0.1);
	drawPyramid();

	glutSwapBuffers();
	glutPostRedisplay();
}
void NonASCIIKeyboardPress(int key, int mouseXPosition, int mouseYPosition)
{	
  switch (key) {
    case UP_KEY:
      cameraFrame.MoveForward(CAMERA_LINEAR_STEP);
      break;

    case DOWN_KEY:
      cameraFrame.MoveForward(-CAMERA_LINEAR_STEP);
      break;

    case LEFT_KEY:
      cameraFrame.RotateWorld(CAMERA_ANGULAR_STEP, 0.0f, 1.0f, 0.0f);
      break;

    case RIGHT_KEY:
      cameraFrame.RotateWorld(-CAMERA_ANGULAR_STEP, 0.0f, 1.0f, 0.0f);
      break;

    case F1_KEY:
      fullscreen = !fullscreen;
      fullscreen ? glutFullScreen() : glutReshapeWindow(ORIG_WINDOW_SIZE[0], ORIG_WINDOW_SIZE[1]);
      break;

    default:
      break;
  }
}
void SpecialKeys(int key, int x, int y)
{
	float linear = 0.1f;
	float angular = float(m3dDegToRad(5.0f));

	if (key == GLUT_KEY_UP)
	{
		cameraFrame.MoveForward(linear);
	}

	if (key == GLUT_KEY_DOWN)
	{
		cameraFrame.MoveForward(-linear);
	}

	if (key == GLUT_KEY_LEFT)
	{
		cameraFrame.RotateWorld(angular, 0.0f, 1.0f, 0.0f);
	}

	if (key == GLUT_KEY_RIGHT)
	{
		cameraFrame.RotateWorld(-angular, 0.0f, 1.0f, 0.0f);
	}
}
Beispiel #7
0
///////////////////////////////////////////////////////////////////////////////
// Called to draw scene
void RenderScene(void)
	{    
    static GLfloat vLightPos [] = { 1.0f, 1.0f, 0.0f };
    static GLfloat vWhite [] = { 1.0f, 1.0f, 1.0f, 1.0f };
    
	// Clear the window with current clearing color
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

	modelViewMatrix.PushMatrix();
		M3DMatrix44f mCamera;
		cameraFrame.GetCameraMatrix(mCamera);
		modelViewMatrix.MultMatrix(mCamera);

        M3DMatrix44f mObjectFrame;
        objectFrame.GetMatrix(mObjectFrame);
        modelViewMatrix.MultMatrix(mObjectFrame);

        glBindTexture(GL_TEXTURE_2D, textureID);
        shaderManager.UseStockShader(GLT_SHADER_TEXTURE_POINT_LIGHT_DIFF, 
                                     transformPipeline.GetModelViewMatrix(),
                                     transformPipeline.GetProjectionMatrix(), 
                                     vLightPos, vWhite, 0);

        pyramidBatch.Draw();

		
	modelViewMatrix.PopMatrix();

	// Flush drawing commands
	glutSwapBuffers();
    }
Beispiel #8
0
void SetUpFrame(GLFrame &frame,const M3DVector3f origin, const M3DVector3f forward, const M3DVector3f up) {
	frame.SetOrigin(origin);
	frame.SetForwardVector(forward);
	M3DVector3f side,oUp;
	m3dCrossProduct3(side,forward,up);
	m3dCrossProduct3(oUp,side,forward);
	frame.SetUpVector(oUp);
	frame.Normalize();
}
jboolean Java_android_filterfw_core_GLFrame_setNativeViewport(JNIEnv* env,
                                                              jobject thiz,
                                                              jint x,
                                                              jint y,
                                                              jint width,
                                                              jint height) {
  GLFrame* frame = ConvertFromJava<GLFrame>(env, thiz);
  return frame ? ToJBool(frame->SetViewport(x, y, width, height)) : JNI_FALSE;
}
void SpecialKeys(int key, int x, int y)
{
    if(key == GLUT_KEY_UP) objectFrame.RotateWorld(m3dDegToRad(-5.0f), 1.0f, 0.0f, 0.0f);
    if(key == GLUT_KEY_DOWN) objectFrame.RotateWorld(m3dDegToRad(5.0f), 1.0f, 0.0f, 0.0f);
    if(key == GLUT_KEY_LEFT) objectFrame.RotateWorld(m3dDegToRad(-5.0f), 0.0f, 1.0f, 0.0f);
    if(key == GLUT_KEY_RIGHT) objectFrame.RotateWorld(m3dDegToRad(5.0f), 0.0f, 1.0f, 0.0f);
    
    glutPostRedisplay();
}
Beispiel #11
0
// Called to draw scene
void RenderScene(void)
    {
    // Clear the window
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        
    glPushMatrix(); 
        frameCamera.ApplyCameraTransform(); // Move the camera about

        // Sky Box is manually textured
        glActiveTexture(GL_TEXTURE0);
        glDisable(GL_TEXTURE_2D);
        glActiveTexture(GL_TEXTURE1);

        glEnable(GL_TEXTURE_CUBE_MAP);
        glDisable(GL_TEXTURE_GEN_S);
        glDisable(GL_TEXTURE_GEN_T);
        glDisable(GL_TEXTURE_GEN_R);     
        glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
        DrawSkyBox();
 

        // Use texgen to apply cube map
        glEnable(GL_TEXTURE_GEN_S);
        glEnable(GL_TEXTURE_GEN_T);
        glEnable(GL_TEXTURE_GEN_R);
        glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
       
        glActiveTexture(GL_TEXTURE0);
        glEnable(GL_TEXTURE_2D);

        glPushMatrix();
            glTranslatef(0.0f, 0.0f, -3.0f);    
 
            glActiveTexture(GL_TEXTURE1);
            glMatrixMode(GL_TEXTURE);
            glPushMatrix();
            
            // Invert camera matrix (rotation only) and apply to 
            // texture coordinates
            M3DMatrix44f m, invert;
            frameCamera.GetCameraOrientation(m);
            m3dInvertMatrix44(invert, m);
            glMultMatrixf(invert);
    
            glColor3f(1.0f, 1.0f, 1.0f);
            gltDrawSphere(0.75f, 41, 41);
 
            glPopMatrix();
            glMatrixMode(GL_MODELVIEW);
        glPopMatrix();

    glPopMatrix();
        
    // Do the buffer Swap
    glutSwapBuffers();
    }
Beispiel #12
0
void SetUpFrame(GLFrame &cameraFrame,const M3DVector3f origin,
				const M3DVector3f forward,
				const M3DVector3f cameraUpDirection) {
					cameraFrame.SetOrigin(origin);
					cameraFrame.SetForwardVector(forward);
	M3DVector3f side,oUp;
	m3dCrossProduct3(side,forward,cameraUpDirection);
	m3dCrossProduct3(oUp,side,forward);
	cameraFrame.SetUpVector(oUp);
	cameraFrame.Normalize();
};
jbyteArray Java_android_filterfw_core_GLFrame_getNativeData(JNIEnv* env, jobject thiz) {
  GLFrame* frame = ConvertFromJava<GLFrame>(env, thiz);
  if (frame && frame->Size() > 0) {
    jbyteArray result = env->NewByteArray(frame->Size());
    jbyte* data = env->GetByteArrayElements(result, NULL);
    frame->CopyDataTo(reinterpret_cast<uint8_t*>(data), frame->Size());
    env->ReleaseByteArrayElements(result, data, 0);
    return result;
  }
  return NULL;
}
Beispiel #14
0
///////////////////////////////////////////////////////////////////////////////
// Called to draw scene
void RenderScene(void)
    {
    // Clear the window with current clearing color
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);

    modelViewMatrix.PushMatrix();
        M3DMatrix44f mCamera;
        cameraFrame.GetCameraMatrix(mCamera);
        modelViewMatrix.MultMatrix(mCamera);

        M3DMatrix44f mObjectFrame;
        objectFrame.GetMatrix(mObjectFrame);
        modelViewMatrix.MultMatrix(mObjectFrame);

        shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeline.GetModelViewProjectionMatrix(), vBlack);

        switch(nStep) {
            case 0:
                glPointSize(4.0f);
                pointBatch.Draw();
                glPointSize(1.0f);
                break;
            case 1:
                glLineWidth(2.0f);
                lineBatch.Draw();
                glLineWidth(1.0f);
                break;
            case 2:
                glLineWidth(2.0f);
                lineStripBatch.Draw();
                glLineWidth(1.0f);
                break;
            case 3:
                glLineWidth(2.0f);
                lineLoopBatch.Draw();
                glLineWidth(1.0f);
                break;
            case 4:
                DrawWireFramedBatch(&triangleBatch);
                break;
            case 5:
                DrawWireFramedBatch(&triangleStripBatch);
                break;
            case 6:
                DrawWireFramedBatch(&triangleFanBatch);
                break;
            }

    modelViewMatrix.PopMatrix();

    // Flush drawing commands
    glutSwapBuffers();
    }
jboolean Java_android_filterfw_core_GLFrame_nativeAllocateExternal(JNIEnv* env,
                                                                   jobject thiz,
                                                                   jobject gl_env) {
  GLEnv* gl_env_ptr = ConvertFromJava<GLEnv>(env, gl_env);
  if (!gl_env_ptr) return JNI_FALSE;
  GLFrame* frame = new GLFrame(gl_env_ptr);
  if (frame->InitWithExternalTexture()) {
    return ToJBool(WrapObjectInJava(frame, env, thiz, true));
  } else {
    delete frame;
    return JNI_FALSE;
  }
}
jboolean Java_android_filterfw_core_GLFrame_getNativeBitmap(JNIEnv* env,
                                                            jobject thiz,
                                                            jobject bitmap) {
  GLFrame* frame = ConvertFromJava<GLFrame>(env, thiz);
  if (frame && bitmap) {
    uint8_t* pixels;
    const int result = AndroidBitmap_lockPixels(env, bitmap, reinterpret_cast<void**>(&pixels));
    if (result == ANDROID_BITMAP_RESUT_SUCCESS) {
      frame->CopyDataTo(pixels, frame->Size());
      return (AndroidBitmap_unlockPixels(env, bitmap) == ANDROID_BITMAP_RESUT_SUCCESS);
    }
  }
  return JNI_FALSE;
}
// called on arrow keys
void SpecialKeys(int key, int x, int y){
    float linear = 0.1f;
    float angular = float(m3dDegToRad(5.0f));

    // TODO - flatten movement to the XZ axis

    if(key == GLUT_KEY_UP)
        cameraFrame.MoveForward(linear);
    if(key == GLUT_KEY_DOWN)
        cameraFrame.MoveForward(-linear);
    if(key == GLUT_KEY_LEFT)
        cameraFrame.RotateWorld(angular, 0.0f, 1.0f, 0.0f);
    if(key == GLUT_KEY_RIGHT)
        cameraFrame.RotateWorld(-angular, 0.0f, 1.0f, 0.0f);
}
jboolean Java_android_filterfw_core_GLFrame_nativeAllocateWithFbo(JNIEnv* env,
                                                                  jobject thiz,
                                                                  jobject gl_env,
                                                                  jint fbo_id,
                                                                  jint width,
                                                                  jint height) {
  GLEnv* gl_env_ptr = ConvertFromJava<GLEnv>(env, gl_env);
  if (!gl_env_ptr) return JNI_FALSE;
  GLFrame* frame = new GLFrame(gl_env_ptr);
  if (frame->InitWithFbo(fbo_id, width, height)) {
    return ToJBool(WrapObjectInJava(frame, env, thiz, true));
  } else {
    delete frame;
    return JNI_FALSE;
  }
}
Beispiel #19
0
// Called to draw scene
void RenderScene(void)
{
	// Clear the window with current clearing color
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glPushMatrix();
	frameCamera.ApplyCameraTransform();

	// Position light before any other transformations
	glLightfv(GL_LIGHT0, GL_POSITION, fLightPos);

	// Draw the ground
	glColor3f(0.60f, .40f, .10f);
	DrawGround();

	// Draw shadows first
	glDisable(GL_DEPTH_TEST);
	glDisable(GL_LIGHTING);
	glPushMatrix();
	glMultMatrixf(mShadowMatrix);
	DrawInhabitants(1);
	glPopMatrix();
	glEnable(GL_LIGHTING);
	glEnable(GL_DEPTH_TEST);

	// Draw inhabitants normally
	DrawInhabitants(0);

	glPopMatrix();

	// Do the buffer Swap
	glutSwapBuffers();
	glutPostRedisplay();
}
Beispiel #20
0
void RenderScene(void)
{

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
	
	modelViewMatrix.PushMatrix();

	M3DMatrix44f mCamera;
	cameraFrame.GetCameraMatrix(mCamera);
	modelViewMatrix.MultMatrix(mCamera);
	modelViewMatrix.MultMatrix(mRotation);

	glUseProgram(myShader);
	//mWcgCube.Draw(locMVP, modelViewMatrix, transformPipeline);

	mWcgCube.DrawRotate(0, 30, locMVP, modelViewMatrix, transformPipeline);
	//glUniformMatrix4fv(locMVP, 1, GL_FALSE, transformPipeline.GetModelViewProjectionMatrix());

	
	
	
	//cubeBatch.Draw();
	//sphereBatch.Draw();
	//triangleBatch.Draw();

	modelViewMatrix.PopMatrix();

	glutSwapBuffers();

	glutPostRedisplay();
	
}
jboolean Java_android_filterfw_core_GLFrame_setNativeBitmap(JNIEnv* env,
                                                            jobject thiz,
                                                            jobject bitmap,
                                                            jint size) {
  GLFrame* frame = ConvertFromJava<GLFrame>(env, thiz);
  if (frame && bitmap) {
    uint8_t* pixels;
    const int result = AndroidBitmap_lockPixels(env, bitmap, reinterpret_cast<void**>(&pixels));
    if (result == ANDROID_BITMAP_RESUT_SUCCESS) {
      const bool success = frame->WriteData(pixels, size);
      return ToJBool(success &&
                     AndroidBitmap_unlockPixels(env, bitmap) == ANDROID_BITMAP_RESUT_SUCCESS);
    }
  }
  return JNI_FALSE;
}
Beispiel #22
0
// This function does any needed initialization on the rendering
// context. 
void SetupRC(void)
	{
	// Background
	glClearColor(0.0f, 0.0f, 0.0f, 1.0f );

	glEnable(GL_DEPTH_TEST);
	glEnable(GL_CULL_FACE);

    shaderManager.InitializeStockShaders();
    viewFrame.MoveForward(4.0f);

    // Make the sphere
    gltMakeSphere(sphereBatch, 1.0f, 26, 13);

	ADSLightShader = shaderManager.LoadShaderPairWithAttributes("ADSGouraud.vp", "ADSGouraud.fp", 2, GLT_ATTRIBUTE_VERTEX, "vVertex",
			GLT_ATTRIBUTE_NORMAL, "vNormal");

	locAmbient = glGetUniformLocation(ADSLightShader, "ambientColor");
	locDiffuse = glGetUniformLocation(ADSLightShader, "diffuseColor");
	locSpecular = glGetUniformLocation(ADSLightShader, "specularColor");
	locLight = glGetUniformLocation(ADSLightShader, "vLightPosition");
	locMVP = glGetUniformLocation(ADSLightShader, "mvpMatrix");
	locMV  = glGetUniformLocation(ADSLightShader, "mvMatrix");
	locNM  = glGetUniformLocation(ADSLightShader, "normalMatrix");
	}
jboolean Java_android_filterfw_core_GLFrame_setNativeData(JNIEnv* env,
                                                          jobject thiz,
                                                          jbyteArray data,
                                                          jint offset,
                                                          jint length) {
  GLFrame* frame = ConvertFromJava<GLFrame>(env, thiz);
  if (frame && data) {
    jbyte* bytes = env->GetByteArrayElements(data, NULL);
    if (bytes) {
      const bool success = frame->WriteData(reinterpret_cast<const uint8_t*>(bytes + offset), length);
      env->ReleaseByteArrayElements(data, bytes, JNI_ABORT);
      return ToJBool(success);
    }
  }
  return JNI_FALSE;
}
Beispiel #24
0
// This function does any needed initialization on the rendering
// context. 
void SetupRC(void)
	{
	// Background
	glClearColor(0.025f, 0.25f, 0.25f, 1.0f );

	glEnable(GL_DEPTH_TEST);

    shaderManager.InitializeStockShaders();
    viewFrame.MoveForward(4.0f);

    // Make the torus
    gltMakeTorus(torusBatch, .80f, 0.25f, 52, 26);

	toonShader = gltLoadShaderPairWithAttributes("ToonShader.vp", "ToonShader.fp", 2, GLT_ATTRIBUTE_VERTEX, "vVertex",
			GLT_ATTRIBUTE_NORMAL, "vNormal");

	locLight = glGetUniformLocation(toonShader, "vLightPosition");
	locMVP = glGetUniformLocation(toonShader, "mvpMatrix");
	locMV  = glGetUniformLocation(toonShader, "mvMatrix");
	locNM  = glGetUniformLocation(toonShader, "normalMatrix");
	locColorTable = glGetUniformLocation(toonShader, "colorTable");

	glGenTextures(1, &texture);
	glBindTexture(GL_TEXTURE_1D, texture);
	GLubyte textureData[4][3] = { 32,  0, 0,
                                  64,  0, 0,
								  128, 0, 0,
								  255, 0, 0};

	glTexImage1D(GL_TEXTURE_1D, 0, GL_RGB, 4, 0, GL_RGB, GL_UNSIGNED_BYTE, textureData);
	glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
	glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
	glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
	}
Beispiel #25
0
void Display()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
	
	static CStopWatch timer;
	GLfloat yRot = timer.GetElapsedSeconds()*20.0f;

	GLfloat vWhite[] = {1.0f,1.0f,1.0f,1.0f};
	GLfloat vLightPos[] = {0.0f,2.0f,2.0f};
	GLfloat vAmbient[] = {0.3f,0.3f,1.0f,1.0f};
	modelViewMatrix.PushMatrix();
		//move to camera view
		M3DMatrix44f mCamera;
		cameraFrame.GetCameraMatrix(mCamera);
		modelViewMatrix.MultMatrix(mCamera);

		modelViewMatrix.PushMatrix();
		modelViewMatrix.Rotate(yRot,1.0,1.0,1.0);
		glBindTexture(GL_TEXTURE_2D,fbxTexture);
		shaderManager.UseStockShader(GLT_SHADER_TEXTURE_POINT_LIGHT_DIFF, 
                                     transformPipeLine.GetModelViewMatrix(),
                                     transformPipeLine.GetProjectionMatrix(), 
                                     vLightPos, vWhite, 0);
		//*/shaderManager.UseStockShader(GLT_SHADER_FLAT, transformPipeLine.GetModelViewProjectionMatrix(),vWhite);
		modelViewMatrix.Scale(0.05,0.05,0.05);
		rTest.DrawReader();

		modelViewMatrix.PopMatrix();
	modelViewMatrix.PopMatrix();

	glutSwapBuffers();
	glutPostRedisplay();
}
Beispiel #26
0
// This function does any needed initialization on the rendering
// context. 
void SetupRC(void)
	{
	// Background
	glClearColor(0.0f, 0.0f, 0.0f, 1.0f );

	glEnable(GL_DEPTH_TEST);
	glEnable(GL_CULL_FACE);

    shaderManager.InitializeStockShaders();
    viewFrame.MoveForward(4.0f);

    // Make the sphere
    gltMakeSphere(sphereBatch, 1.0f, 52, 26);

	normalMapShader = gltLoadShaderPairWithAttributes("NormalMapped\\NormalMapped.vp", "NormalMapped\\NormalMapped.fp", 3, GLT_ATTRIBUTE_VERTEX, "vVertex",
			GLT_ATTRIBUTE_NORMAL, "vNormal", GLT_ATTRIBUTE_TEXTURE0, "vTexture0");

	locAmbient = glGetUniformLocation(normalMapShader, "ambientColor");
	locDiffuse = glGetUniformLocation(normalMapShader, "diffuseColor");
	locLight = glGetUniformLocation(normalMapShader, "vLightPosition");
	locMVP = glGetUniformLocation(normalMapShader, "mvpMatrix");
	locMV  = glGetUniformLocation(normalMapShader, "mvMatrix");
	locNM  = glGetUniformLocation(normalMapShader, "normalMatrix");
	locColorMap = glGetUniformLocation(normalMapShader, "colorMap");
    locNormalMap = glGetUniformLocation(normalMapShader, "normalMap");

	glGenTextures(2, texture);
    glActiveTexture(GL_TEXTURE0);
	glBindTexture(GL_TEXTURE_2D, texture[0]);
	LoadTGATexture("NormalMapped\\IceMoon.tga", GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE);
    glActiveTexture(GL_TEXTURE1);
    glBindTexture(GL_TEXTURE_2D, texture[1]);
    LoadTGATexture("NormalMapped\\IceMoonBump.tga", GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_REPEAT);
	}
Beispiel #27
0
// This function does any needed initialization on the rendering context.
void SetupRC(void)
{
    // Background
    glClearColor(0.2f, 0.2f, 0.3f, 1.0f );

    glEnable(GL_DEPTH_TEST);

    shaderManager.InitializeStockShaders();
    viewFrame.MoveForward(4.0f);

    // Make the torus
    gltMakeTorus(torusBatch, .70f, 0.10f, 11, 7);

    explodeProgram = gltLoadShaderTripletWithAttributes("../../Data/Shaders/Chapter11/GSExplode.vs",
                                                        "../../Data/Shaders/Chapter11/GSExplode.gs",
                                                        "../../Data/Shaders/Chapter11/GSExplode.fs",
                                                        2,
                                                        GLT_ATTRIBUTE_VERTEX, "vVertex",
                                                        GLT_ATTRIBUTE_NORMAL, "vNormal");

    locMVP = glGetUniformLocation(explodeProgram, "mvpMatrix");
    locMV  = glGetUniformLocation(explodeProgram, "mvMatrix");
    locNM  = glGetUniformLocation(explodeProgram, "normalMatrix");
    locPushOut = glGetUniformLocation(explodeProgram, "push_out");
}
jboolean Java_android_filterfw_core_GLFrame_setNativeInts(JNIEnv* env,
                                                          jobject thiz,
                                                          jintArray ints) {
  GLFrame* frame = ConvertFromJava<GLFrame>(env, thiz);
  if (frame && ints) {
    jint* int_ptr = env->GetIntArrayElements(ints, NULL);
    const int length = env->GetArrayLength(ints);
    if (int_ptr) {
      const bool success = frame->WriteData(reinterpret_cast<const uint8_t*>(int_ptr),
                                            length * sizeof(jint));
      env->ReleaseIntArrayElements(ints, int_ptr, JNI_ABORT);
      return ToJBool(success);
    }
  }
  return JNI_FALSE;
}
Beispiel #29
0
void SetupRC()
{
    // Background
    glClearColor(0.0f, 0.0f, 0.0f, 1.0f );

    viewFrame.MoveForward(4.0f);

    shaderManager.InitializeStockShaders();

    // Simple triangle
    // Load up a triangle
    GLfloat vVerts[] = {
      -0.5f, 0.0f, 0.0f,
      0.5f, 0.0f, 0.0f,
      0.0f, 0.5f, 0.0f
    };

    GLfloat vTexCoords [] = {
      0.0f, 0.0f,
      1.0f, 0.0f,
      0.5f, 1.0f
    };

    triangleBatch.Begin(GL_TRIANGLES, 3, 1);
    triangleBatch.CopyVertexData3f(vVerts);
    triangleBatch.CopyTexCoordData2f(vTexCoords, 0);
    triangleBatch.End();

    texturedIdentity = gltLoadShaderPairWithAttributes("TexturedIdentity.vp", "TexturedIdentity.fp", 2, GLT_ATTRIBUTE_VERTEX, "vVertex", GLT_ATTRIBUTE_TEXTURE0, "vTexCoords");

    glGenTextures(1, &stoneTexture);
    glBindTexture(GL_TEXTURE_2D, stoneTexture);
    LoadTGATexture("Stone.tga", GL_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE);
}
Beispiel #30
0
void GetViewProjectionMatrix(float *viewProjectionMatrix)
{	
	M3DMatrix44f viewMatrix;
	cameraFrame.GetCameraMatrix(viewMatrix);

	m3dMatrixMultiply44(viewProjectionMatrix, viewFrustum.GetProjectionMatrix(), viewMatrix);
}