Jump to content

  • Log In with Google      Sign In   
  • Create Account


SM ForeveR

Member Since 04 Sep 2009
Offline Last Active Oct 29 2012 12:35 PM

Topics I've Started

Windows OpenGL project doesn't compile under release mode

11 October 2012 - 01:41 PM

Hi,
I have this strange problem, which I've ignored for quite some time...
I develop in debug mode, which works fine. But whenever I switch to release mode the following part of my code
[source lang="cpp"] GLenum err = glewInit(); if (err != GLEW_OK) LOGI("GLEW not initialized."); if (!GLEW_VERSION_2_1) LOGI("GLEW doesn't support OpenGL 2.1");[/source]
produces this message:
INFO: GLEW doesn't support OpenGL 2.1

I have this line in my header (glew.h is between <>):
[source lang="cpp"]#include glew.h#pragma comment(lib, "glew32.lib")[/source]
I include these directories:

C:\api\FMOD Programmers API Windows\api\inc;

C:\Program Files (x86)\FMOD SoundSystem\FMOD Programmers API Windows\api\inc;

C:\Binaries\DevIL-SDK-x86-1.7.8\include\IL;

C:\api\Glew\include\GL;

C:\api\DevIL\include\IL;$(IncludePath)

and these libraries:

C:\api\Glew\lib;

C:\api\DevIL\lib;

C:\api\FMOD Programmers API Windows\api\lib;

C:\Program Files (x86)\FMOD SoundSystem\FMOD Programmers API Windows\api\lib;

C:\Binaries\DevIL-SDK-x86-1.7.8\lib;$(LibraryPath)


I've had copied debug include and library entries to release mode, so they should be the same.

Any ideas, why in release mode glew doesn't add support for OpenGL2.1?
Thanks, Martin.

"Undefined reference to" error on NDK

18 June 2012 - 11:10 PM

Hello,
now I use eclipse (with sequoyah) to write application with ndk for android.
I'm experiencing a strange problem where I can't succesfully include any classes into current cpp file which is invoked by android system.

My cpp fle looks like this:

#include "Core/Ghost.h"
#include "Multiplatform/PlatformAndroid.h"
#ifdef ANDROID
int g_nWidth, g_nHeight;
Ghost* ghost_;
Platform* platform_;
extern "C" {
void Java_com_ghost_Renderer_init(JNIEnv* env) {
  ghost_ = new Ghost();
}
void Java_com_ghost_Renderer_resize(JNIEnv* env, void* reserved, int w, int h) {
  ghost_->resize(w, h);
}
void Java_com_ghost_Renderer_render(JNIEnv* env, void* reserved) {
  ghost_->computeFrame();
}
};
#endif

Whenever I try to use variable "ghost_" I get "Undefined reference to Ghost::..."

Any Ideas what might be causing this?

[EDIT] Apparently it has something to do with mk file, because after adding Ghost.cpp to it, the error went from Ghost to Renderer object which is used in Ghost.cpp. Unfortunately even adding all files to mk file didn't solve the problem.
[EDIT2] It was a syntax error on Renderer object. Now it works. But still, does that mean, that whenewer I add new files to project, I will also have to add them to mk file?

Thank you,
Martin

Camera positioning

08 February 2012 - 10:32 AM

Hi, I have been thinking for a few days on how to properly create camera matrix so I could specify it just as any other model in scene and the view would still be from camera object.
I use these methods to get camera matrix:
public static float[] getViewMatrix(float[] position, float[] rotation) {
  float[] matTrans = Matrix3D.copy(position);
  float[] matRot = Matrix3D.copy(rotation);
  // Transpose rotation matrix.
  float tmp;
  tmp = matRot[0 * 4 + 1]; matRot[0 * 4 + 1] = matRot[1 * 4 + 0]; matRot[1 * 4 + 0] = tmp;
  tmp = matRot[0 * 4 + 2]; matRot[0 * 4 + 2] = matRot[2 * 4 + 0]; matRot[2 * 4 + 0] = tmp;
  tmp = matRot[1 * 4 + 2]; matRot[1 * 4 + 2] = matRot[2 * 4 + 1]; matRot[2 * 4 + 1] = tmp;
  // Invert translation.
  matTrans[3 * 4 + 0] *= -1.0f;
  matTrans[3 * 4 + 1] *= -1.0f;
  matTrans[3 * 4 + 2] *= -1.0f;
  return Matrix3D.multiply(matRot, matTrans);
}
public static final float[] multiply(float[] b, float[] a) {
  // Return identity if matrices aren't 4x4.
  if (a.length != b.length && a.length != 16)
   return identity();
  // Initialize empty matrix.
  float[] result = new float[16];
  // Multiply.
  int k = 15;
  for (int i = 3; i >= 0; i--) {
   for (int j = 3; j >= 0; j--) {
	result[k] += a[i * 4] * b[j];
	result[k] += a[i * 4 + 1] * b[4 + j];
	result[k] += a[i * 4 + 2] * b[8 + j];
	result[k] += a[i * 4 + 3] * b[12 + j];
	k--;
   }
  }
  return result;
}
position and rotation float arrays are matrices.
The problem is, that viewing arround doesn't quite work on some directions unless I comment these lines:
tmp = matRot[0 * 4 + 1]; matRot[0 * 4 + 1] = matRot[1 * 4 + 0]; matRot[1 * 4 + 0] = tmp;
  tmp = matRot[0 * 4 + 2]; matRot[0 * 4 + 2] = matRot[2 * 4 + 0]; matRot[2 * 4 + 0] = tmp;
  tmp = matRot[1 * 4 + 2]; matRot[1 * 4 + 2] = matRot[2 * 4 + 1]; matRot[2 * 4 + 1] = tmp;

Any ideas what I'm doing wrong? This is on android.
Multiply method is tested and is working.
Thank you, Martin.

EDIT:
if I understand correctly, I need to inverse my camera position and rotation matrix to be able to get view from where camera is positioned with original matrix. Is there something wrong with my inverse matrix implementation?

Translation matrix

06 February 2012 - 02:26 AM

Hi, I am developing on android and I have encountered one problem. In opengl documentation it says, that matrices are in column-major order and translation matrix looks like this:
1 0 0 x
0 1 0 y
0 0 1 z
0 0 0 1
But in my program I use method like this:
public static final float[] translation(float x, float y, float z) {

  // 4x4 translation matrix.

  return new float[] {

	1.0f, 0.0f, 0.0f, 0.0f,

	0.0f, 1.0f, 0.0f, 0.0f,

	0.0f, 0.0f, 1.0f, 0.0f,

	x, y, z, 1.0f,

  };

}

And it works until I try to change x, y, z position to last column.
Does this have to do with the fact that I use 1D array and not 2D? Does each row in this array represents a column when passed to opengl methods?

Thank you,
Martin

Rendering textures from obj file

19 January 2012 - 01:43 AM

Hi,
I made a simple textured box in blender and exported to .obj file.
Content looks like this:
# Blender v2.61 (sub 0) OBJ File: 'skybox.blend'
# www.blender.org
mtllib skybox.mtl
v 1.000000 -1.000000 -1.000000
v 1.000000 -1.000000 1.000000
v -1.000000 -1.000000 1.000000
v -1.000000 -1.000000 -1.000000
v 1.000000 1.000000 -0.999999
v 0.999999 1.000000 1.000001
v -1.000000 1.000000 1.000000
v -1.000000 1.000000 -1.000000
vt 0.744716 0.379594
vt 0.503906 0.379595
vt 0.503906 0.138785
vt 0.744716 0.138784
vt 0.744717 0.620404
vt 0.744717 0.861216
vt 0.503906 0.861216
vt 0.503906 0.620405
vt 0.263096 0.620405
vt 0.263096 0.379595
vt 0.022287 0.620405
vt 0.022287 0.379595
vt 0.985527 0.379594
vt 0.985527 0.620404
usemtl skybox_mat_skybox.png
s off
f 1/1 2/2 3/3
f 1/1 3/3 4/4
f 5/5 8/6 7/7
f 5/5 7/7 6/8
f 1/1 5/5 6/8
f 1/1 6/8 2/2
f 2/2 6/8 7/9
f 2/2 7/9 3/10
f 3/10 7/9 8/11
f 3/10 8/11 4/12
f 5/5 1/1 4/13
f 5/5 4/13 8/14

The problem is, that I have no idea how to correctly map textures.
As for now I only use vt for textures (ignore f).
I thought that opengl es requires vt to be exact same amount as v. But there we have more texture coordinates than vertices.
Can someone tell me or give me some urls on how to make sense of numbers after the slash signs in faces? Not what they mean, but how to use them.

Thank you,
Martin

PARTNERS