Jump to content
  • Advertisement

Archived

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

com

2d (isometric) using the 3d box tutorial from nehe

This topic is 5675 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

I was trying to create tiles over one flat area to make a sort of isometric map. i used the 3d box tutorial as help and just got rid of 3 sides so im left with the bottom only. I tried using 2 flat surfaces to place to textures on but i get an error:C:\Program Files\Microsoft Visual Studio\MyProjects\Alpha_Region_The_Game\tileSetRender.cpp(79) : error C2601: ''DrawGLScene'' : local function definitions are illegal
  
int DrawGLScene(GLvoid)								// Here''s Where We Do All The Drawing

{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);			// Clear Screen And Depth Buffer

	glLoadIdentity();							// Reset The Current Matrix

	glTranslatef(0.0f,0.0f,-5.0f);						// Move Into The Screen 5 Units

glBindTexture(GL_TEXTURE_2D, texture[0]);				// Select Our Texture

glBegin(GL_QUADS);
		glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, -1.0f);	// Top Right Of The Texture and Quad

		glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, -1.0f);	// Top Left Of The Texture and Quad

		glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f,  1.0f);	// Bottom Left Of The Texture and Quad

		glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f,  1.0f);	// Bottom Right Of The Texture and Quad

glBindTexture(GL_TEXTURE_2D, texture[1]);
glNormal3f( 1.0f, 0.0f, 0.0f);
		glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, -1.0f);	// Top Right Of The Texture and Quad

		glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, -1.0f);	// Top Left Of The Texture and Quad

		glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f,  1.0f);	// Bottom Left Of The Texture and Quad

		glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f,  1.0f);	// Bottom Right Of The Texture and Quad

		glEnd();
return true;
}	
  
so is there way i can make lots of tiles and add a texture to each or just one tile with different textures on? thx an advance.

Share this post


Link to post
Share on other sites
Advertisement
You are probably missing a closed ''}''
symbol in a statement.
Check and see if you are closing all of your statements properly.

Cheers,

TommyB

Share this post


Link to post
Share on other sites
quote:
Original post by com

I tried using 2 flat surfaces to place to textures on but i get an error:C:\Program Files\Microsoft Visual Studio\MyProjects\Alpha_Region_The_Game\tileSetRender.cpp(79) : error C2601: ''DrawGLScene'' : local function definitions are illegal


    
int DrawGLScene(GLvoid) // Here''s Where We Do All The Drawing

{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer

glLoadIdentity(); // Reset The Current Matrix

glTranslatef(0.0f,0.0f,-5.0f); // Move Into The Screen 5 Units

glBindTexture(GL_TEXTURE_2D, texture[0]); // Select Our Texture

glBegin(GL_QUADS);
glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, -1.0f); // Top Right Of The Texture and Quad

glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, -1.0f); // Top Left Of The Texture and Quad

glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); // Bottom Left Of The Texture and Quad

glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); // Bottom Right Of The Texture and Quad

glBindTexture(GL_TEXTURE_2D, texture[1]);
glNormal3f( 1.0f, 0.0f, 0.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, -1.0f); // Top Right Of The Texture and Quad

glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, -1.0f); // Top Left Of The Texture and Quad

glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); // Bottom Left Of The Texture and Quad

glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); // Bottom Right Of The Texture and Quad

glEnd();
return true;
}



Looking at the error you probably forgot } at the end of the previous function

Share this post


Link to post
Share on other sites
maybe im blind becasue i cant see it myself so heres the full code for that section:

  
#include <windows.h>
#include <gl/gl.h>
#include <gl/glu.h>
#include <gl/glaux.h>
#include <stdio.h>
GLuint texture[2];
HDC hDC=NULL; // Private GDI Device Context

HGLRC hRC=NULL; // Permanent Rendering Context

HWND hWnd=NULL; // Holds Our Window Handle

HINSTANCE hInstance;
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
AUX_RGBImageRec *LoadBMP(char *Filename) // Loads A Bitmap Image

{
FILE *File=NULL; // File Handle

if (!Filename) // Make Sure A Filename Was Given

{
return NULL; // If Not Return NULL

}
File=fopen(Filename,"r"); // Check To See If The File Exists

if (File) // Does The File Exist?

{
fclose(File); // Close The Handle

return auxDIBImageLoad(Filename); // Load The Bitmap And Return A Pointer

}
return NULL; // If Load Failed Return NULL

}

int LoadGLTextures() // Load Bitmaps And Convert To Textures

{
int Status=FALSE; // Status Indicator

AUX_RGBImageRec *TextureImage[2]; // Create Storage Space For The Texture

memset(TextureImage,0,sizeof(void *)*1); // Set The Pointer To NULL

// Load The Bitmap, Check For Errors, If Bitmap''s Not Found Quit

if (TextureImage[0]=LoadBMP("2.bmp"))
{
Status=TRUE; // Set The Status To TRUE

glGenTextures(1, &texture[0]); // Create The Texture


// Typical Texture Generation Using Data From The Bitmap

glBindTexture(GL_TEXTURE_2D, texture[0]);
// Generate The Texture

glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); // Linear Filtering

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); // Linear Filtering

if (TextureImage[0]) // If Texture Exists

{
if (TextureImage[0]->data) // If Texture Image Exists

{
free(TextureImage[0]->data); // Free The Texture Image Memory

}

free(TextureImage[0]); // Free The Image Structure

}
if (TextureImage[1]=LoadBMP("2.bmp"))
{
Status=TRUE; // Set The Status To TRUE

glGenTextures(1, &texture[1]); // Create The Texture


// Typical Texture Generation Using Data From The Bitmap

glBindTexture(GL_TEXTURE_2D, texture[1]);
// Generate The Texture

glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[1]->sizeX, TextureImage[1]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[1]->data);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); // Linear Filtering

glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); // Linear Filtering

if (TextureImage[1]) // If Texture Exists

{
if (TextureImage[1]->data) // If Texture Image Exists

{
free(TextureImage[0]->data); // Free The Texture Image Memory

}

free(TextureImage[1]); // Free The Image Structure

}
return Status; // Return The Status

}



int DrawGLScene(GLvoid) // Here''s Where We Do All The Drawing

{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer

glLoadIdentity(); // Reset The Current Matrix

glTranslatef(0.0f,0.0f,-5.0f); // Move Into The Screen 5 Units

glBindTexture(GL_TEXTURE_2D, texture[0]); // Select Our Texture

glBegin(GL_QUADS);
glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, -1.0f); // Top Right Of The Texture and Quad

glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, -1.0f); // Top Left Of The Texture and Quad

glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); // Bottom Left Of The Texture and Quad

glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); // Bottom Right Of The Texture and Quad

glBindTexture(GL_TEXTURE_2D, texture[1]);
glNormal3f( 1.0f, 0.0f, 0.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, -1.0f); // Top Right Of The Texture and Quad

glTexCoord2f(0.0f, 1.0f); glVertex3f( 1.0f, -1.0f, -1.0f); // Top Left Of The Texture and Quad

glTexCoord2f(0.0f, 0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); // Bottom Left Of The Texture and Quad

glTexCoord2f(1.0f, 0.0f); glVertex3f(-1.0f, -1.0f, 1.0f); // Bottom Right Of The Texture and Quad

glEnd();

return true;
}

thx in advance

Share this post


Link to post
Share on other sites
I am NOT a C++ programmer, and I don''t know too much C++, only C.
But isn''t this illegal: int DrawGLScene(GLvoid) ?
I mean, shouldn''t it be something like:
int DrawGLScene() ?

Share this post


Link to post
Share on other sites
Dude,
Your
int LoadGlTextures function is messed.
Count the number of ''{'' vs. ''}''
The compiler will give you this error if a previously
declared function is missing braces.
Take a look at your code again. I don''t mean to be mean, but
your code indenting leaves much to be desired.

Peace,


TommyB

Share this post


Link to post
Share on other sites
well ive fixed those {} errors but now i have a new problem.
--------------------Configuration: Alpha_region - Win32 Debug--------------------
Compiling...
tileSetRender.cpp
window.cpp
Linking...
window.obj : error LNK2005: "int __cdecl DrawGLScene(void)" (?DrawGLScene@@YAHXZ) already defined in tileSetRender.obj
window.obj : error LNK2005: "struct HWND__ * hWnd" (?hWnd@@3PAUHWND__@@A) already defined in tileSetRender.obj
window.obj : error LNK2005: "struct HGLRC__ * hRC" (?hRC@@3PAUHGLRC__@@A) already defined in tileSetRender.obj
window.obj : error LNK2005: "struct HDC__ * hDC" (?hDC@@3PAUHDC__@@A) already defined in tileSetRender.obj
window.obj : error LNK2005: "struct HINSTANCE__ * hInstance" (?hInstance@@3PAUHINSTANCE__@@A) already defined in tileSetRender.obj
tileSetRender.obj : error LNK2001: unresolved external symbol _auxDIBImageLoadA@4
tileSetRender.obj : error LNK2001: unresolved external symbol __imp__glTexParameteri@12
tileSetRender.obj : error LNK2001: unresolved external symbol __imp__glTexImage2D@36
tileSetRender.obj : error LNK2001: unresolved external symbol __imp__glBindTexture@8
tileSetRender.obj : error LNK2001: unresolved external symbol __imp__glGenTextures@8
tileSetRender.obj : error LNK2001: unresolved external symbol __imp__glEnd@0
tileSetRender.obj : error LNK2001: unresolved external symbol __imp__glNormal3f@12
tileSetRender.obj : error LNK2001: unresolved external symbol __imp__glVertex3f@12
tileSetRender.obj : error LNK2001: unresolved external symbol __imp__glTexCoord2f@8
tileSetRender.obj : error LNK2001: unresolved external symbol __imp__glBegin@4
tileSetRender.obj : error LNK2001: unresolved external symbol __imp__glTranslatef@12
tileSetRender.obj : error LNK2001: unresolved external symbol __imp__glLoadIdentity@0
window.obj : error LNK2001: unresolved external symbol __imp__glLoadIdentity@0
tileSetRender.obj : error LNK2001: unresolved external symbol __imp__glClear@4
window.obj : error LNK2001: unresolved external symbol __imp__glClear@4
window.obj : error LNK2001: unresolved external symbol _gluPerspective@32
window.obj : error LNK2001: unresolved external symbol __imp__glMatrixMode@4
window.obj : error LNK2001: unresolved external symbol __imp__glViewport@16
window.obj : error LNK2001: unresolved external symbol __imp__glHint@8
window.obj : error LNK2001: unresolved external symbol __imp__glDepthFunc@4
window.obj : error LNK2001: unresolved external symbol __imp__glEnable@4
window.obj : error LNK2001: unresolved external symbol __imp__glClearDepth@8
window.obj : error LNK2001: unresolved external symbol __imp__glClearColor@16
window.obj : error LNK2001: unresolved external symbol __imp__glShadeModel@4
window.obj : error LNK2001: unresolved external symbol __imp__wglDeleteContext@4
window.obj : error LNK2001: unresolved external symbol __imp__wglMakeCurrent@8
window.obj : error LNK2001: unresolved external symbol __imp__wglCreateContext@4
Debug/Alpha_region.exe : fatal error LNK1120: 25 unresolved externals
Error executing link.exe.

Alpha_region.exe - 33 error(s), 0 warning(s)
usually removing all the project files and then creating a new project and adding them fixes this but it doesnt now.

Share this post


Link to post
Share on other sites
It looks like your tileSetRender.obj knows nothing about your OpenGL functions...
You are probably not including gl.h, glu.h, etc. in your
tileSetRender.c/tileSetRender.cpp source.

Cheers,

TommyB

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!