Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.



This topic is 5821 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

O.k. I have a class that has a pointer to a structure. When I init the pointer it works in one program(DOS) but gives me an access violation In a windows prog?? Here is my code. defs:

#ifndef _defs_h_
#define _defs_h_

#include <windows.h>
#include <stdio.h>
#include <gl\gl.h>										// Header File For The OpenGL32 Library
#include <gl\glu.h>	

struct VERTEX

	float x;
	float y;
	float z;
	float R;
	float G;
	float B;
	float texx;
	float texy;

struct MD2_HEADER
   int magic; 
   int version; 
   int skinWidth; 
   int skinHeight; 
   int frameSize; 
   int numSkins; 
   int numVertices; 
   int numTexCoords; 
   int numTriangles; 
   int numGlCommands; 
   int numFrames; 
   int offsetSkins; 
   int offsetTexCoords; 
   int offsetTriangles; 
   int offsetFrames; 
   int offsetGlCommands; 
   int offsetEnd; 

struct MD2_VERTEX
   byte  vertex[3];
   byte lightNormalIndex;
struct MD2_FRAME
   float scale[3];
   float translate[3];
   char name[16];
   MD2_VERTEX verts[1];

	 void RenderVertexList(VERTEX * vertList,int numPrims);

typedef struct
   short vertex[3];
   short texture[3];

class MD2
	MD2_HEADER header;
	MD2_FRAME *frames;
	MD2_TRIANGLE *triangles;
	 bool LoadMD2(char *fileName);
	void RenderMD2();

init: bool MD2::LoadMD2(char *fileName) { int i; FILE *filePointer; filePointer=fopen(fileName,"rb"); if(!filePointer) { return FALSE; } fread(&header,1,sizeof(MD2_HEADER),filePointer); if(header.numFrames<1) { // cout<<"FUCK"<,1,sizeof(MD2_TRIANGLE),filePointer); fseek(filePointer,header.offsetFrames,SEEK_SET); for(i=0;i[edited by - tHiSiSbOb on December 6, 2002 6:36:44 PM] [edited by - tHiSiSbOb on December 6, 2002 6:37:46 PM]

Share this post

Link to post
Share on other sites
You do:


but ''triangles'' is just a pointer in a struct. Which means you scribble over whatever comes after that pointer/struct in memory. You probably want to write to the memory that ''triangles'' points at, and therefore need something like:


[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions | Organising code files | My stuff ]

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!