Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


stevo86

Member Since 29 Jun 2005
Offline Last Active Sep 19 2013 10:58 PM

Topics I've Started

Access Violation upon calling an OpenGL Extension

16 April 2010 - 08:35 AM

This is a very strange problem that I cannot seem to resolve. I've created an absolute basic windows program along the following lines:
	WNDCLASS wc;
	PIXELFORMATDESCRIPTOR pfd;
	int format;

	memset(&wc, 0, sizeof(WNDCLASS));
	memset(&pfd, 0, sizeof(PIXELFORMATDESCRIPTOR));
	
	wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
	wc.hCursor = LoadCursor(NULL, IDC_ARROW);
	wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
	wc.lpfnWndProc = os_proc;
	wc.lpszClassName = "BaseWindow";
	wc.style = CS_OWNDC | CS_VREDRAW | CS_HREDRAW;

	if (!RegisterClass(&wc))
	{
		return false;
	}

	if (!(gwnd = CreateWindow("BaseWindow", "Window", WS_VISIBLE | WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, width, height, NULL, NULL, ginstance, NULL)))
	{
		return false;
	}

	gdc = GetDC(gwnd);

	if (!gdc)
	{
		return false;
	}

	pfd.nVersion = 1;
	pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
	pfd.iLayerType = PFD_MAIN_PLANE;
	pfd.iPixelType = PFD_TYPE_RGBA;
	pfd.cColorBits = 32;
	pfd.cStencilBits = 8;
	pfd.cDepthBits = 24;
	pfd.dwFlags = PFD_DOUBLEBUFFER | PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL;

	format = ChoosePixelFormat(gdc, &pfd);
	if (!SetPixelFormat(gdc, format, &pfd))
	{
		return false;
	}

	grc = wglCreateContext(gdc);
	wglMakeCurrent(gdc, grc);

	glViewport(0, 0, width, height);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();

	gluOrtho2D(0, width, 0, height);

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	glEnable(GL_DEPTH_TEST);
	glDepthFunc(GL_LEQUAL);
	glClearDepth(1.0f);
	glClearColor(0, 0, 0, 0);

	int ret = glewInit();

	if (ret != GLEW_OK)
	{
		return false;
	}

	if (!GLEW_ARB_vertex_program)
	{
		printf("Vertex shaders are not supported\n");
		return false;
	}
	else
	{
		printf("Vertex shaders are supported\n");
	}

	unsigned int id = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
Now the odd part about this is that even though I'm calling glewInit() and verifying that it works, and verifying that I do have shader support, the second I run the program, I get the following error: "Unhandled exception in program.exe: access violation at 0xC0000005" When I hit OK, Visual Studio highlights the following line as the cause of the problem:
	unsigned int id = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
Anyone know the cause of this? I'm using an HP Pavilion d2035us laptop with an Intel 945 Express chipset.

MD2 Indices Are Confusing

20 October 2009 - 01:17 PM

My goal is to take an MD2 file, extract the information I need (essentially just the individual frames) and perform all the calculations necessary to get to the ACTUAL vertex information (not the compressed-encoded-bit form of the vertex index(I know I'm in a forum of overly-logical and analytical programmers so just to clarify, that was an exaggeration)), and write a new file using only that information. And if it turns out to be a nightmarishly large file I can always work on compressing it down later on. We're selling terabyte external hard drives for less than $100, I don't need to compress every single bit to 1/10000th of it's original size like we needed to for Quake or Quake 2, and I don't need the added complexity of skeletal animation or separate meshes like the milkshape format has, just the plain old vertices frame by frame that I can interpolate between and stuff into a vertex array to throw at the GPU. If anyone could try and help explain how all the indices work together and how I would need to arrange them to make them VA-friendly, I'd greatly appreciate it. Or if you've got another suggestion that would be more speed-friendly, I'm open to suggestions.

File IO question

13 September 2009 - 09:41 AM

I've always wondered about this and never really asked about it, and have never seen any mention of it in any articles or books, so here goes. Does the order of a structure in code affect how it's read from a file, assuming a broad fread call is made. For example:

typedef struct
{
 int id;
 float data;
} mystruct;

mystruct* m;
fread(m, 1, sizeof(mystruct), f);

// will the above result in the same as below:
typedef struct
{
 float data;
 int id;
} mystruct;

mystuct* m;
fread(m, 1, sizeof(mystruct), f);
Fairly simple, I'm assuming, but I've never really asked about it.

Entry Point Not Found __glutInitWithExit

16 August 2009 - 10:55 AM

I've looked everywhere and tried everything but can't seem to figure this out. I was going along programming away, testing a program that uses GLUT and out of nowhere, I hit F5 to fire up a debug test and instead of seeing my program, I get this error saying that the entry point could not be found in glut32.dll. I've checked on the MSDN forums and found a few similar complaints, tried all the solutions and come up empty handed. I've restarted Visual Studio, restarted my computer and completely reinstalled the GLUT libraries. I'm using Visual Studio 2008 Express, Windows 7 and the latest GLUT library. It worked right up until it didn't. The only thing I changed was code to modify a texture and I've since stripped that out to see if I somehow screwed with the GLUT initialization. I've checked my library directories, made sure all the files were in the right place and up to date, and I'm completely lost. So, any ideas? EDIT: this can be closed. I found out the linker was grabbing an out-dated version of glut32.dll in system32 whereas I had the newer version in the windows base directory. I think when I installed the ATI SDK it added its own version of glut32.dll to the system32 directory which takes precedence over the base windows directory, on my compiler anyways. [Edited by - stevo86 on August 16, 2009 5:27:16 PM]

Weird values coming up in a loop.

17 March 2009 - 10:17 AM

I'm working on building a terrain engine and in the portion of code where I construct the vertices I'm dumping the values and getting some very strange output. Here's the code:

	Vector3* vertices;
	int size = 256*256;

	vertices = new Vector3[size];

	int x,z;
	x=z=0;
	for (int i=0;i<size;i+=1)
	{
		vertices[i].x = x;
		vertices[i].y = 0;
		vertices[i].z = z;

		error("%d = %d,%d,%d", i, vertices[i].x, vertices[i].y, vertices[i].z);

		i++;

		vertices[i].x = x;
		vertices[i].y = 0;
		vertices[i].z = z+1;

		// Dump our vertices by triangle strip.
		error("%d = %d,%d,%d", i, vertices[i].x, vertices[i].y, vertices[i].z);

		x++;

		if (x == 256)
		{
			z++;
			x = 0;
		}
	}

The error() function is just a simple function that dumps whatever I print into a log.txt file.

Now the weird thing is the first 2 values are correct. The x,y and z coordinates are all set to 0 as expected, but on the next iteration of the loop, the x and z values are fine but the y value is an absurdly high arbitrary number like 238573937. Any ideas as to why this would be?

PARTNERS