| | |
| Stránka: 1 z 1
| [ Príspevok: 1 ] | |
Autor | Správa |
---|
Registrovaný: 02.11.07 Prihlásený: 18.03.15 Príspevky: 470 Témy: 22 Bydlisko: Zilinska Un... |
zdravim potrebujem pomoc. Nemozem nacitat grafiku zo suboru *.txt, kompilator mi nevypisuje chybu ale po kompilacii mi zobrazi ciernu obrazovku, no bude to asi logicka chyba. Mozno to bude chyba vo funkcii " void SetupWorld() ", asi pri alokovani dynamickeho pola alebo as pri vykreslovani vo fun. "static void draw_objekt_3d()".
tu su tie funkcie.:
Kód: #ifdef HAVE_CONFIG_H #include <config.h> #endif
#include <iostream> #include <stdlib.h>
#include <GL/glew.h> #include <SDL/SDL.h> //#include "SDL_opengl.h" #include "time.h" #include "math.h" #include "user_input_enum.h"
#define TRUE 1 #define FALSE 0
#include "setting.h"
bool light;
using namespace std;
int done=0;
int mouse_x,mouse_y;
int user_input[1000];
static float rotation1=0; static float rotation2=0; //deklaracia pomocnej premennej pre rotaciu
GLfloat yrot; /* Camera rotation variable */ GLfloat xpos, zpos; /* Camera pos variable */
GLfloat walkbias= 0.0f; /* Head-bobbing variables */ GLfloat walkbiasangle= 0.0f; GLfloat lookupdown= 0.0f;
typedef struct tagVERTEX //nove { float x, y, z; /* 3D Coordinates */ float u, v; /* Texture Coordinates */ } VERTEX;
typedef struct tagTRIANGLE //nove { VERTEX vertex1[3]; /* Array Of Three Vertices */ } TRIANGLE;
typedef struct tagSECTOR //nove { int numTriangles; /* Number Of Triangles In Sector */ TRIANGLE* triangle1; /* Pointer To Array Of Triangles */ } SECTOR;
SECTOR sector1; //nove
----------------------------------- void readstr( FILE *f, char *string ) { /* Start A Loop */ do { /* Read One Line */ fgets( string, 255, f ); } while ( ( string[0] == '/' ) || ( string[0] == '\n' ) );
return; }
///////////////////////////////////////////////////////////////////////////////
void SetupWorld() { FILE *filein; /* File To Work With */
int numTriangles; /* Number of Triangles */ char oneLine[255]; /* One line from conf file */
float x, y, z, u, v; /* 3d and texture coordinates */
int triLoop; /* Triangle loop variable */ int verLoop; /* Vertex loop variable */ // worldFile = "data\\world.txt"; /* Open Our File */ filein = fopen("data\\world.txt", "rt" );
/* Grab a line from 'filein' */ readstr( filein, oneLine );
/* Read in number of triangle */ sscanf( oneLine, "NUMPOLLIES %d\n", &numTriangles );
/* allocate space for our triangles */ //sector1.triangle1 = new Triangle[numTriangles]; ///////////////////////////////////////////////////////////////////////////////////////////////////
sector1.triangle1 = new TRIANGLE[numTriangles]; //delete (sector1.triangle1); /* int a; void* vp=&a; int * ip=(int*)vp; ip=static_cast<int*> (vp); *ip=8; */ if ( sector1.triangle1 == NULL ) { fprintf( stderr, "Could not allocate memory for triangles.\n" ); exit(0); } sector1.numTriangles = numTriangles;
/* Get coords for each triangle */ for ( triLoop = 0; triLoop < numTriangles; triLoop++ ) { for ( verLoop = 0; verLoop < 3; verLoop++ ) { readstr( filein, oneLine ); sscanf( oneLine, "%f %f %f %f %f\n", &x, &y, &z, &u, &v ); sector1.triangle1[triLoop].vertex1[verLoop].x = x; sector1.triangle1[triLoop].vertex1[verLoop].y = y; sector1.triangle1[triLoop].vertex1[verLoop].z = z; sector1.triangle1[triLoop].vertex1[verLoop].u = u; sector1.triangle1[triLoop].vertex1[verLoop].v = v; // delete [] sector1.triangle1; } } //////////////////////////////////////////////////////////////////////
delete [] sector1.triangle1; /* Close Our File */ fclose( filein );
return; . . .
alebo Kód: #ifndef _draw_object_3d_h_ #define _draw_object_3d_h_ . . .
/////////////////////////////////////////////////////
static void draw_objekt_3d() { if(user_input[SDLK_RIGHT]) { yrot -= 1.5f; } if(user_input[SDLK_LEFT]) { yrot += 1.5f; } if(user_input[SDLK_UP]) { /* Move On The X-Plane Based On Player Direction */ xpos -= ( float )sin( yrot * piover180 ) * 0.05f; /* Move On The Z-Plane Based On Player Direction */ zpos -= ( float )cos( yrot * piover180 ) * 0.05f; if ( walkbiasangle >= 359.0f ) walkbiasangle = 0.0f; else walkbiasangle+= 10;
/* Causes the player to bounce */ walkbias = ( float )sin( walkbiasangle * piover180 ) / 20.0f; } if(user_input[SDLK_DOWN]) { /* Move On The X-Plane Based On Player Direction */ xpos += ( float )sin( yrot * piover180 ) * 0.05f; /* Move On The Z-Plane Based On Player Direction */ zpos += ( float )cos( yrot * piover180 ) * 0.05f; if ( walkbiasangle <= 1.0f ) walkbiasangle = 359.0f; else walkbiasangle -= 10;
walkbias = ( float )sin( walkbiasangle * piover180 ) / 20.0f; }
/* Rotate Up And Down To Look Up And Down */ glRotatef( lookupdown, 1.0f, 0.0f , 0.0f ); /* Rotate Depending On Direction Player Is Facing */ glRotatef( sceneroty, 0.0f, 1.0f , 0.0f );
/* Translate The Scene Based On Player Position */ glTranslatef( xtrans, ytrans, ztrans ); //glDisable(GL_TEXTURE_2D); //glEnable(GL_LIGHTING); // glEnable(GL_BLEND); // Turn Blending On // glDisable(GL_DEPTH_TEST); // Turn Depth Testing Off /* Bottom Left Of The Texture and Quad */ glBindTexture( GL_TEXTURE_2D, texture[2] ); // glTranslatef(pohX,pohY,0.0f);
for ( loop_m = 0; loop_m < sector1.numTriangles; loop_m++ ) { /* Start Drawing Triangles */ glBegin(GL_TRIANGLES); /* Normal Pointing Forward */ glNormal3f( 0.0f, 0.0f, 1.0f); /* X Vertex Of 1st Point */ x_m = sector1.triangle1[loop_m].vertex1[0].x; /* Y Vertex Of 1st Point */ y_m = sector1.triangle1[loop_m].vertex1[0].y; /* Z Vertex Of 1st Point */ z_m = sector1.triangle1[loop_m].vertex1[0].z; /* U Texture Coord Of 1st Point */ u_m = sector1.triangle1[loop_m].vertex1[0].u; /* V Texture Coord Of 1st Point */ v_m = sector1.triangle1[loop_m].vertex1[0].v;
/* Set The TexCoord And Vertice */ glTexCoord2f( u_m, v_m ); glVertex3f( x_m, y_m, z_m );
/* X Vertex Of 2nd Point */ x_m = sector1.triangle1[loop_m].vertex1[1].x; /* Y Vertex Of 2nd Point */ y_m = sector1.triangle1[loop_m].vertex1[1].y; /* Z Vertex Of 2nd Point */ z_m = sector1.triangle1[loop_m].vertex1[1].z; /* U Texture Coord Of 2nd Point */ u_m = sector1.triangle1[loop_m].vertex1[1].u; /* V Texture Coord Of 2nd Point */ v_m = sector1.triangle1[loop_m].vertex1[1].v;
/* Set The TexCoord And Vertice */ glTexCoord2f( u_m, v_m ); glVertex3f( x_m, y_m, z_m );
/* X Vertex Of 3rd Point */ x_m = sector1.triangle1[loop_m].vertex1[2].x; /* Y Vertex Of 3rd Point */ y_m = sector1.triangle1[loop_m].vertex1[2].y; /* Z Vertex Of 3rd Point */ z_m = sector1.triangle1[loop_m].vertex1[2].z; /* Texture Coord Of 3rd Point */ u_m = sector1.triangle1[loop_m].vertex1[2].u; /* V Texture Coord Of 3rd Point */ v_m = sector1.triangle1[loop_m].vertex1[2].v;
/* Set The TexCoord And Vertice */ glTexCoord2f( u_m, v_m ); glVertex3f( x_m, y_m, z_m ); glEnd( ); . . . . }
Dany kod je nepouzitelny, preto tu davam aj cely workspace pre program Eclipse., Nie je to link na warez, o je to moje. jj. ""!!!!, skuste mi pomoct, inak v tom worku je to "openglL10", diik. PS: nevem ci to je kompilovatelne pod windows, Linux no problem. link": Kód: http://rapidshare.com/files/148569164/eclipse1.zip.html
nemaste to, no WAREZ.
_________________ Notebook: HP EliteBook 8740w
You can see my work in my www |
|
| Stránka: 1 z 1
| [ Príspevok: 1 ] | |
Podobné témy | Témy | Odpovede | Zobrazenia | Posledný príspevok |
---|
| OpenGL v Ovládače | 18 | 7860 | 13.11.2008 1:25 PSYCHOTEROR | | OpenGL v Ostatné programy | 4 | 841 | 13.12.2006 18:47 POM4R4NC | | opengl v Assembler, C, C++, Pascal, Java | 1 | 634 | 17.11.2008 10:51 johny3212 | | CSS openGL v Počítačové hry | 3 | 467 | 17.04.2010 21:48 eXistenZ | | Java + OpenGL v Assembler, C, C++, Pascal, Java | 2 | 510 | 10.01.2011 21:28 gladiatus | | Java a OpenGL v Assembler, C, C++, Pascal, Java | 0 | 505 | 30.03.2009 20:29 ewil | | DirectX alebo OpenGL v Assembler, C, C++, Pascal, Java | 0 | 239 | 07.01.2013 11:17 FBerente | | Problém z OpenGL [ Choď na stránku: 1, 2 ] v ATI/AMD grafické karty | 30 | 505 | 08.02.2014 16:53 patrikufik | | Wolfenstein a OpenGL v Počítačové hry | 4 | 897 | 06.08.2007 12:42 johny128 | | C++/SFML/OpenGL v Assembler, C, C++, Pascal, Java | 23 | 702 | 26.04.2015 2:25 Misosvk | | MineCraft OpenGL CHYBA v Počítačové hry | 1 | 645 | 14.02.2011 9:54 shiro | | OpenGL v Linuxe v Assembler, C, C++, Pascal, Java | 11 | 1100 | 09.07.2009 16:16 chrono | | Problém s OpenGl v Ovládače | 2 | 438 | 19.01.2011 15:51 seamus_22 | | Problém s OpenGL v Ostatné programy | 0 | 507 | 15.11.2006 19:46 DeaLer | | Vista a OpenGL v Operačné systémy Microsoft | 4 | 488 | 17.09.2006 0:33 Shark NX | | problem s OpenGL v nVidia grafické karty | 4 | 523 | 15.05.2007 10:09 Shit |
| Nemôžete zakladať nové témy v tomto fóre Nemôžete odpovedať na témy v tomto fóre Nemôžete upravovať svoje príspevky v tomto fóre Nemôžete mazať svoje príspevky v tomto fóre
|
|