OpenGL 텍스쳐 맵핑이 제대로 안됩니다...

lemk000의 이미지

텍스쳐 맵핑을 하려는데
구에다가 하려고 하거든요 근데 텍스쳐가 전체적으로 구에 붙는게 아니라
그 텍스쳐의 일부 색깔로 단색으로 구에 입혀져버립니다.
인터넷 많이 찾아보면서 그대로 했는데 이유를 모르겠습니다.

	AUX_RGBImageRec *tex[2];
	memset(tex, 0, sizeof(void *)*2);
 
	tex[0] = auxDIBImageLoad("texture/space.bmp");
       tex[1] = auxDIBImageLoad("texture/moon.bmp");
 
	for (i=0; i<2; i++) {
	   glGenTextures(1, &ids[i]); // generate texture id
	    glBindTexture (GL_TEXTURE_2D, ids[i]); // bind properties to tex id 
	    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	    glTexImage2D(GL_TEXTURE_2D, 0, 3, tex[i]->sizeX, tex[i]->sizeY, 0,GL_RGB, GL_UNSIGNED_BYTE, tex[i]->data); // give the texture image to be used 
	}
 
	for (i=0; i<2; i++) {
		if (tex[i]) {
			if (tex[i]->data) {
				free(tex[i]->data);
				free(tex[i]);
			}
		}
	}
 
	glEnable (GL_TEXTURE_2D); // enable texture mapping
    glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE)

위의 코드로 메인에서 텍스쳐를 사용하겠다고해주고

	glPushMatrix();
	glTranslatef(padding, 0, (obj[i].coming));
	glRotatef(obj[i].rotation, 0.0, 5.0, 1.0);
	glBindTexture (GL_TEXTURE_2D, ids[1]);
	glutSolidSphere(RADIUS, 20, 16);
	glPopMatrix();

위와같이 디스플레이 콜백 함수에서 구를 그릴때 바인딩을 해주었습니다.

제가 입히려는게 달표면 그림인데요 24비트 비트맵에 900*900입니다.
근데 달표면의 회색 색깔 단색으로 구에 그려집니다.
혹시나 텍스쳐맵핑이 안되나해서 다른그림으로 바꿔보면
역시 다른 그림의 단색으로 맵핑이 됩니다.
이유를 잘 모르겠습니다. 도와주세요

shint의 이미지

init2DTextures();를 호출하라는군요.
http://blog.naver.com/utez?Redirect=Log&logNo=90095920835

근데... ㅡ_ㅡ;;; 이거 찾아보니 아닌거 같네요.
openGL bible 3판 책보면 SphereWorld 소스가 있는데 그거 참고 하시는게 좋아보입니다.

----------------------------------------------------------------------------
젊음'은 모든것을 가능하게 만든다.

매일 1억명이 사용하는 프로그램을 함께 만들어보고 싶습니다.
정규 근로 시간을 지키는. 야근 없는 회사와 거래합니다.

각 분야별. 좋은 책'이나 사이트' 블로그' 링크 소개 받습니다. shintx@naver.com

ifree의 이미지

텍스처 매핑을 하기 전에 구에 uv 좌표를 설정해야 해요.
그 좌표에 따라 텍스처 이미지가 구에 입혀지게 됩니다.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.