Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

107 Neutral

About Graphic_Programmer

  • Rank

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Graphic_Programmer

    my obj loader problem

    OKEEEEYY !!! I got it ! I understood why it dont draw.The reason of problem is a index.I used the index from 1 to end value but i might use from 0 to end-1.
  2. Graphic_Programmer

    my obj loader problem

    Is there nobody to help?
  3. Graphic_Programmer

    my obj loader problem

    Hi, I wrote my own obj loader codes and printed values of vertex,texture,normal and face to screen.The values in console screen was correct values but i cant draw the model properly.It looked distorted. These are my codes about to load obj model: #include <stdio.h> #include <math.h> int i,a,b,isaret,bb; int chartoint(char chr) { if(chr=='0') return 0; else if(chr=='1') return 1; else if(chr=='2') return 2; else if(chr=='3') return 3; else if(chr=='4') return 4; else if(chr=='5') return 5; else if(chr=='6') return 6; else if(chr=='7') return 7; else if(chr=='8') return 8; else if(chr=='9') return 9; else return 0; } char satir_atla(FILE * dosya_gostergesi) { char ww; while(! feof(dosya_gostergesi)) { ww=getc(dosya_gostergesi); if(ww=='\n') break; } ww=getc(dosya_gostergesi); return ww; } mtn_kopyala(char ydizi[],char hdizi[]) { for(i=0; ydizi!='\0'; i++) { ydizi[i+1]; hdizi=ydizi; } hdizi='\0'; } char satir_kopyala(FILE * dosya_gostergesi,char hdizi[]) { char ww; i=0; while(1) { ww=getc(dosya_gostergesi); hdizi[i+1]; hdizi=ww; if(ww=='\n') { hdizi='\0'; break; } i++; } ww=getc(dosya_gostergesi); return ww; } main() { FILE * gosterge; int yedek,sayiin,xxx,yyy,tip,atla,asama,nokta[3],j,ucgen_sayisi=0,vrtx=0,textu=0,nrml=0,ucgennn[10000][9]; char aaaa,satir[100],deneme[]="Aptal",deneme2[]="akilli"; double sayiif=0,texture[10000][3],vertex[10000][3],normal[10000][3]; gosterge=fopen("ucgen2.obj","r"); aaaa=getc(gosterge); while(! feof(gosterge)) { if(aaaa=='#') { aaaa=satir_atla(gosterge); } else if(aaaa=='v') { aaaa=getc(gosterge); if(aaaa==' ') {tip=0;} else if(aaaa=='t') {tip=1;} else if(aaaa=='n') {tip=2;} //sat?r? çözümlemeye ba?la { atla=1; asama=0; aaaa=satir_kopyala(gosterge,satir); for(i=0; 1; i++) { if((satir=='0' || satir=='1' || satir=='2' || satir=='3' || satir=='4' || satir=='5' || satir=='6' || satir=='7' || satir=='8' || satir=='9' || satir=='.') && asama%2==0) { nokta[asama%2]=i; asama++; } else if ((satir!='0' && satir!='1' && satir!='2' && satir!='3' && satir!='4' && satir!='5' && satir!='6' && satir!='7' && satir!='8' && satir!='9' && satir!='.')&& asama%2==1 ) { nokta[asama%2]=i-1; asama++; atla=0; } if(!atla) { if((asama%2)==0) { sayiif=0; if(satir[nokta[0]-1]=='-') isaret=-1; else isaret=1; for(yyy=0, j=nokta[1]; j>=nokta[0]; j--) { sayiif+=(chartoint(satir[j])*pow(10,(double)yyy)); if(satir[j]=='.') nokta[2]=j; else yyy++; } sayiif/=pow(10,(double)(nokta[1]-nokta[2])); sayiif*=isaret; //printf("%f\n",sayiif);//sayiif/=1;//(float)pow(10,(double)(nokta[2]-j)); switch(tip) { case 0: vertex[vrtx][asama/2-1]=sayiif; atla=1; case 1: texture[textu][asama/2-1]=sayiif; atla=1; default: normal[nrml][asama/2-1]=sayiif; atla=1; break; } } } if(tip==2) { if(asama==6) { nrml++; break; } } else if(tip==1) { if(asama==4) { textu++; break; } } else if(tip==0) { if(asama==6) { vrtx++; break; } } } } } else if(aaaa=='f') { //sat?r? çözümlemeye ba?la { atla=1; asama=0; aaaa=satir_kopyala(gosterge,satir); for(i=0; 1; i++) { if((satir=='0' || satir=='1' || satir=='2' || satir=='3' || satir=='4' || satir=='5' || satir=='6' || satir=='7' || satir=='8' || satir=='9' || satir=='.') && asama%2==0) { nokta[asama%2]=i; asama++; } else if ((satir!='0' && satir!='1' && satir!='2' && satir!='3' && satir!='4' && satir!='5' && satir!='6' && satir!='7' && satir!='8' && satir!='9' && satir!='.')&& asama%2==1 ) { nokta[asama%2]=i-1; asama++; atla=0; } if(!atla) { if((asama%2)==0) { sayiin=0; yedek=0; for(yyy=0, j=nokta[1]; j>=nokta[0]; j--,yyy++) { yedek=(int)(chartoint(satir[j])); for(b=0; b<yyy; b++) { yedek*=10; } sayiin+=yedek; } ucgennn[ucgen_sayisi][asama/2-1]=(int)sayiin; atla=1; } } if(asama==18) { ucgen_sayisi++; break; } } } } else { aaaa=getc(gosterge); } } fclose(gosterge); //printf("%d %d %d %f\n",nokta[0],nokta[1],t, sayiif); for(i=0; i<vrtx; i++) { printf("v "); for(j=0; j<3; j++) { printf("%f ",vertex[j]); if(j==2) printf("\n"); } } printf("\n"); for(i=0; i<textu; i++) { printf("vt "); for(j=0; j<2; j++) { printf("%f ",texture[j]); if(j==1) printf("\n"); } } printf("\n"); for(i=0; i<nrml; i++) { printf("vn "); for(j=0; j<3; j++) { printf("%f ",normal[j]); if(j==2) printf("\n"); } } printf("\n"); for(i=0; i<ucgen_sayisi; i++) { printf("f "); for(j=0; j<9; j++) { if((j%3)!=0) printf("/"); else printf(" "); printf("%i",ucgennn[j]); if(j==8) printf("\n"); } } while(1) { } } I tried the codes in Dev C++. You can try it to see values.For now, no problem but i couldnt draw properly when i tried these codes in Visual C++ with fist codes. glPushMatrix(); glScaled(1,1,1); glRotated(0,0,0,0); glTranslated(0,0,0); glBegin(GL_TRIANGLES); for(i=0; i<ucgen_sayisi; i++) { for(j=0; j<3; j++) { glNormal3d(normal[ucgennn[j*3+2]][0],normal[ucgennn[j*3+2]][1],normal[ucgennn[j*3+2]][2]); glVertex3d(vertex[ucgennn[j*3]][0],vertex[ucgennn[j*3]][1],vertex[ucgennn[j*3]][2]); } } glEnd(); glPopMatrix(); Thanks.
  4. Graphic_Programmer

    My Screenshot Problem with SDL and OpenGL in C

    [/quote] Thank you very much for your help! Me too not a expert of OpenGL but sure, you know it better than me becuse i am new in OpenGL and my English isn't very good to understand everything. Oh, i am an idiot First, I might say thats: Already, I called Screenshot function with screen surface and drew something to screen.The problem weren't them. When i tried GL_FRONT_LEFT, i made it just and i have a question: why doesn't it be when i tried GL_FRONT_RIGHT instead? What is different between LEFT and RIGHT? Does it mean front face and back face. I will try all of them.
  5. Graphic_Programmer

    My Screenshot Problem with SDL and OpenGL in C

    Isn't there nobody? Help! Pleasee
  6. Graphic_Programmer

    A games lifespan

    You spoke to a interesting point about old games. Why the old games work less quality on newer computers? I think, maybe the reason is developers's a premeditation or mismatchs between old versions and new versions. I don't know which one but me too wonder.
  7. Graphic_Programmer

    Cylindrical Texture Mapping

    This is as my own cylinder texture mapping but i did't use GL_QUAD_STRIP, used GL_QUADS. This topic can help in need of someone. Thanks.
  8. Hi, I wanted to write screen saver function for my mother OpenGL Suface yesterday. First, i thinked this is very easy! I wrote SDL_SaveBMP(screen,"deneme.bmp"); The End.. That can be comic for you but unluckily it did not be. The program showed an error message me and it was grotesque for me. Then, I found a function from a web site but does not work correctly.When it saved a bmp file, it only showed a color on all surface.The color was color of glClearColor function. The Screenshot Code: int Screenshot(char *filename, SDL_Surface *screen) { SDL_Surface *temp; unsigned char *pixels; int i; if (!(screen->flags & SDL_OPENGL)) { SDL_SaveBMP(temp, filename); return 0; } temp = SDL_CreateRGBSurface(SDL_SWSURFACE, screen->w, screen->h, 24, #if SDL_BYTEORDER == SDL_LIL_ENDIAN 0x000000FF, 0x0000FF00, 0x00FF0000, 0 #else 0x00FF0000, 0x0000FF00, 0x000000FF, 0 #endif ); if (temp == NULL) return -1; pixels = malloc(3 * screen->w * screen->h); if (pixels == NULL) { SDL_FreeSurface(temp); return -1; } glReadBuffer(GL_FRONT_AND_BACK); glReadPixels(0, 0,screen->w, screen->h,GL_RGB , GL_UNSIGNED_BYTE, pixels); for (i=0; i<ekran->h; i++) memcpy(((char *) temp->pixels) + temp->pitch * i, pixels + 3*screen->w * (ekran->h-i-1), screen->w*3); free(pixels); SDL_SaveBMP(temp, filename); SDL_FreeSurface(temp); return 0; } Not : For first error the reason is not different between screen,"filename" and "filename",screen.SDL_SaveBMP and Screenshot are different fuctions. Thanks.
  9. Graphic_Programmer

    3D Engine architecture

    Yes, me too, i want to make my own game engine.Mine will be with SDL and OpenGL in C.Now, if i want, i can use them to draw nice 3D/2D graphics but i still haven't got enough knowledge about them for advanced drawing so i must learn things more than them.At the moment, i am working on sound system.So far i tried a function to load and play a sound file(.wav) from a folder.I am very happy now becuse it played !
  10. Graphic_Programmer

    A Problem in drawing 2D transparent shapes with ortho

    I made it. Thank you very much!
  11. Graphic_Programmer

    A Problem in drawing 2D transparent shapes with ortho

    Do you think i must change 2-3 and 1? OK i will try
  12. Graphic_Programmer

    A Problem in drawing 2D transparent shapes with ortho

    Yes, i know but when i put glDisable(GL_DEPTH_TEST) to initialization, the red box looked on the transparent letter "A"(my 2D Ortho graphic).I think, the box must be under the 2D letter. This is screenshot when i put glDisable(GL_DEPTH_TEST);
  13. First, my English isn't very good, i can say wrong words so sorry. I am beginner to making 2D/3D Graphics in Opengl and i have a problem about drawing 3D shapes under 2D ortho graphics with alpha transparent. The ScreenShot I don't know could i tell. I think you understood my problem from the picture. These are my drawing codes; ciz() { glViewport(0,0,ewidth,eheight); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glPushMatrix(); glOrtho(-1,1,-1,1,-20,20); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glColor4f(1,1,0,1); glDisable(GL_TEXTURE_2D); glPushMatrix(); glTranslatef(((float)mouse_x-(ewidth/2))/(ewidth/2),-((float)mouse_y-(eheight/2))/(eheight/2),0.1); glBindTexture(GL_TEXTURE_2D,NULL); glBegin(GL_POLYGON); for(i=0; i<20; i++) { glVertex3f(cos(18*i*pi/180)/32,sin(18*i*pi/180)/32,0); } glEnd(); glColor4f(1,1,1,1); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D,tex[0]); glPopMatrix(); /* glBegin(GL_QUADS); glTexCoord2i(0,0); glVertex3f(-0.9,0.9,0); glTexCoord2i(1,0); glVertex3f(-0.6,0.9,0); glTexCoord2i(1,1); glVertex3f(-0.6,0.6,0); glTexCoord2i(0,1); glVertex3f(-0.9,0.6,0); glEnd(); glBegin(GL_QUADS); glTexCoord2i(0,0); glVertex3f(-0.6,0.9,0); glTexCoord2i(1,0); glVertex3f(-0.3,0.9,0); glTexCoord2i(1,1); glVertex3f(-0.3,0.6,0); glTexCoord2i(0,1); glVertex3f(-0.6,0.6,0); glEnd();*/ //glDisable(GL_BLEND); //glDisable(GL_DEPTH_TEST); glBindTexture(GL_TEXTURE_2D,tex[1]); glBegin(GL_QUADS); for(i=0,j=0; i<=yazi_uz; i++) { if(yazi=='A') { ii=0; jj=0; glTexCoord2f((1+(float)ii+(float)ii*13)/512,(1+(float)jj+(float)jj*18)/256); glVertex3f(((0+(float)i*50 )/640)*2-1,-(((0+(float)j*80 )/480)*2-1),0); glTexCoord2f((1+(float)ii+((float)ii+1)*13)/512,(1+(float)jj+(float)jj*18)/256); glVertex3f(((0+((float)i+1)*50 )/640)*2-1,-(((0+(float)j*80 )/480)*2-1),0); glTexCoord2f((1+(float)ii+((float)ii+1)*13)/512,(1+(float)jj+((float)jj+1)*18)/256); glVertex3f(((0+((float)i+1)*50 )/640)*2-1,-(((0+((float)j+1)*80 )/480)*2-1),0); glTexCoord2f((1+(float)ii+(float)ii*13)/512,(1+(float)jj+((float)jj+1)*18)/256); glVertex3f(((0+(float)i*50 )/640)*2-1,-(((0+((float)j+1)*80 )/480)*2-1),0); } } glEnd(); glEnable(GL_DEPTH_TEST); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glPopMatrix(); gluPerspective(45,(float)(ewidth/eheight),.1,1000); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(c_x+cos((dir+180)*pi/180)*cos(-der*pi/180)*uz,c_y+sin((dir+180)*pi/180)*cos(-der*pi/180)*uz,c_z+sin(-der*pi/180)*uz,c_x,c_y,c_z, 0,1,0); glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); glColor3f(1,1,1); //glDisable(GL_TEXTURE_2D); /* glBegin(GL_POLYGON); glTexCoord2i(0,0); glVertex3f(-15,15,0); glTexCoord2i(1,0); glVertex3f(15,15,0); glTexCoord2i(1,1); glVertex3f(15,-15,0); glTexCoord2i(0,1); glVertex3f(-15,-15,0); glEnd();*/ //glEnable(GL_TEXTURE_2D); /*glBegin(GL_TRIANGLES); for(i=0; i<10; i++) { glNormal3f(cos((i+0.5)*36*pi/180)*cos(90-atan(10/7)*pi/180),sin((i+0.5)*36*pi/180)*cos(90-atan(10/7)*pi/180),sin(90-atan(10/7)*pi/180)); glVertex3f(0,0,5); glVertex3f(cos(36*i*pi/180)*7,sin(36*i*pi/180)*7,-5); glVertex3f(cos(36*(i+1)*pi/180)*7,sin(36*(i+1)*pi/180)*7,-5); } glEnd();*/ glColor4f(1,1,1, 1); //glDisable(GL_DEPTH_TEST); //glDepthMask(GL_TRUE); //glEnable(GL_ALPHA_TEST); glBindTexture(GL_TEXTURE_2D, tex[2]); glPushMatrix(); glTranslatef(obj[0].x,obj[0].y,obj[0].z); glScalef(0.5,0.5,0.5); glRotatef(der2*5,0.7,0.3,0.5); //glBindTexture(GL_TEXTURE_2D,tex[1]); glBegin(GL_QUADS); //alt glNormal3f(0,0,-1); glTexCoord2i(0,0); glVertex3f(-8,8,-8); glTexCoord2i(1,0); glVertex3f(8,8,-8); glTexCoord2i(1,1); glVertex3f(8,-8,-8); glTexCoord2i(0,1); glVertex3f(-8,-8,-8); //üst glNormal3f(0,0,1); glTexCoord2i(0,0); glVertex3f(-8,8,8); glTexCoord2i(1,0); glVertex3f(8,8,8); glTexCoord2i(1,1); glVertex3f(8,-8,8); glTexCoord2i(0,1); glVertex3f(-8,-8,8); //sa? glNormal3f(1,0,0); glTexCoord2i(0,0); glVertex3f(8,8,-8); glTexCoord2i(1,0); glVertex3f(8,8,8); glTexCoord2i(1,1); glVertex3f(8,-8,8); glTexCoord2i(0,1); glVertex3f(8,-8,-8); //sol glNormal3f(-1,0,0); glTexCoord2i(0,0); glVertex3f(-8,8,-8); glTexCoord2i(1,0); glVertex3f(-8,8,8); glTexCoord2i(1,1); glVertex3f(-8,-8,8); glTexCoord2i(0,1); glVertex3f(-8,-8,-8); //yukar? glNormal3f(0,1,0); glTexCoord2i(0,0); glVertex3f(-8,8,8); glTexCoord2i(1,0); glVertex3f(8,8,8); glTexCoord2i(1,1); glVertex3f(8,8,-8); glTexCoord2i(0,1); glVertex3f(-8,8,-8); //a?a?? glNormal3f(0,-1,0); glTexCoord2i(0,0); glVertex3f(-8,-8,8); glTexCoord2i(1,0); glVertex3f(8,-8,8); glTexCoord2i(1,1); glVertex3f(8,-8,-8); glTexCoord2i(0,1); glVertex3f(-8,-8,-8); glEnd(); glPopMatrix(); glEnable(GL_DEPTH_TEST); /* glClearColor(1,0,0,1); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);*/ //resim_yukle("font.bmp"); SDL_GL_SwapBuffers(); } Help please, Thanks for your helps.
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!