Peter Conn

  • Content count

  • Joined

  • Last visited

Community Reputation

126 Neutral

About Peter Conn

  • Rank
  1. OpenGL Various OpenGL Problems

    I've sorted it (I had to enclose textured objected between glEnable and glDisable for GL_TEXTURE_2D, and leave untextured objects out of the loop). Thanks alot for your help.
  2. OpenGL Various OpenGL Problems

    A new problem. I load a texture, but don't even use it, and everything that I draw is dimmer. It has something to do with: glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  3. OpenGL Various OpenGL Problems

    Where should I put the glDisable(GL_TEXTURE_2D) to make the textures go as they should? Should I enable and disable it in the main loop? And is the moral of the story to never use commas? Or that its ok to use them to declare variables, but not to initialize them? (for example would it be ok to use them with variables in a class, but then initialize them seperately. Thanks alot for your help!
  4. Hey I've been making an OpenGL window, and I've come accross various problems that I guess are to do with my OpenGL settings, but I can't pinpoint. At the moment my program can display a loaded *.bmp and texture it onto a square, most of the time. It also display a simple grid (to help me get my barings). Problem 1: The colours in the program go wierd. When I display the image, and don't use the function glColor3f(), the image displays correctly. The grid lines always take the colour of the pixel that is in the bottom left of the image. (When displayed, the texture appears mirrored in the line x=y, but the bottom left pixel stays the same). When I use glColor3f() (anywhere in the main loop), it acts as a kind of filter. glColor3f(1.0f, 1.0f, 1.0f) does nothing, glColor3f(0.0f, 0.0f, 0.0f) turns the image black, glColor3f(0.0f, 1.0f, 0.0f) turns the image green. Also, when I used the green color to draw the grid and I don't draw the texture, the grid appears a bright green, when I add the texture (and draw it) the green becomes a darker shade. Problem 2: Occasionally the program doesn't accept some input. Occasionally when I add a random line of code (it always happens when I am editing function arguments which are floats), the program starts up with the camera at a wierd angle (rotated about the y-axis about +- 45 deg (sometimes it goes in one direction, sometimes the other)). And the program won't accept input from the left and right keys (which would change the y Rotation angle). And Problem 3 magically dissappeared as I was trying to find out enough to tell you of it. My code is: #include "Includes.hpp" bool keyDown[323]; int LoadBMPTexture(char* filename); const short ScrWidth = 1366; const short ScrHeight = 768; int main(int argc, char *argv[]) { SDL_Surface *screen; SDL_Init(SDL_INIT_VIDEO); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 32); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1 ); SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 32); screen = SDL_SetVideoMode( ScrWidth, ScrHeight, 16, SDL_OPENGL | SDL_HWSURFACE | SDL_FULLSCREEN); // *changed* glClearColor( 0.0f, 0.0f, 0.0f, 0.0f ); glViewport( 0, 0, ScrWidth, ScrHeight ); glClearDepth(2.0); glDepthFunc(GL_LESS); glEnable(GL_DEPTH_TEST); glEnable(GL_TEXTURE_2D); glShadeModel(GL_SMOOTH); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0f, (GLfloat)(ScrWidth/ScrHeight), 0.1f, 300.0f); // Essential Line! glMatrixMode(GL_MODELVIEW); glLoadIdentity(); GLuint TexID = LoadBMPTexture("Test.bmp"); // Set up variables here /*Model *tim = new Model(); tim->LoadFromFile("Cube.txt"); Model *bob = new Model(); bob->LoadFromFile("Sphere.txt"); bob->x = 3; tim->PrintVertexData();*/ float yRot, xRot = 0; float xPos, yPos = 0; float dist = -5.0f; for(int i=0; i<323; i++){ keyDown[i]=false;} // Main Loop SDL_Event event; bool running = true; while(running){ // Draw Stuff glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear the screen before drawing glLoadIdentity(); // Reset the view // Set the view //glTranslatef(0.0f, -1.0f, dist); glTranslatef(0.0f, 0.0f, dist); glRotatef(xRot, 1.0f, 0, 0); glRotatef(yRot, 0, 1.0f, 0); // Main AXIS //tim->Draw(); //bob->Draw(); // Draw the textured face glBindTexture(GL_TEXTURE_2D,TexID); glBegin(GL_QUADS); glTexCoord2f(1.0f,1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); glTexCoord2f(1.0f,0.0f); glVertex3f( 1.0f, 1.0f, 1.0f); glTexCoord2f(0.0f,0.0f); glVertex3f( 1.0f, -1.0f, 1.0f); glTexCoord2f(0.0f,1.0f); glVertex3f(-1.0f, -1.0f, 1.0f); glEnd(); // Draw the grid lines //glColor3f(1.0f, 1.0f, 1.0f); //glColor3f(0.0f, 1.0f, 0.0f); glBegin(GL_LINES); for(int i=0; i<50; i++){ glVertex3f((GLfloat)(25-i), 0.0f, -25.0f); glVertex3f((GLfloat)(25-i), 0.0f, 25.0f); glVertex3f(-25.0f, 0.0f, (GLfloat)(25-i)); glVertex3f(25.0f, 0.0f, (GLfloat)(25-i)); } glEnd(); SDL_GL_SwapBuffers(); // Actually // Deal with input while(SDL_PollEvent(&event)) { switch(event.type){ case SDL_KEYDOWN: if(event.key.keysym.sym == SDLK_ESCAPE) running = 0; keyDown[event.key.keysym.sym] = true; break; case SDL_KEYUP: keyDown[event.key.keysym.sym] = false; break; case SDL_QUIT: running = 0; break; } } // Handle Key Downs if(keyDown[SDLK_RIGHT]) yRot -= 0.5f; if(keyDown[SDLK_LEFT]) yRot += 0.5f; if(keyDown[SDLK_UP]) xRot += 0.5f; if(keyDown[SDLK_DOWN]) xRot -= 0.5f; if(keyDown[SDLK_PAGEUP]) dist += 0.03f; if(keyDown[SDLK_PAGEDOWN]) dist -= 0.03f; } glDeleteTextures(1,&TexID); SDL_Quit(); return 0; } int LoadBMPTexture(char* filename) { SDL_Surface *tex = SDL_LoadBMP(filename); GLuint texture; printf("Status: Loading image "); printf(filename); printf("... "); if(tex) { glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture); glTexImage2D(GL_TEXTURE_2D, 0, 3, tex->w, tex->h, 0, GL_BGR, GL_UNSIGNED_BYTE, tex->pixels); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); printf("OK\n"); SDL_FreeSurface(tex); } else { printf("Failed\nQuitting..."); SDL_Quit(); return -1; } return texture; } I found the BMP SDL to OpenGL loader on this site, so I doubt that was in error. Thanks
  5. Hello I have loaded up a 3ds file and textured it, keeping my code similar to the 1st example. However any faces that have an edge off screen are not shown at all. This results in everything in the middle of the screen being displayed well but around the edges I get jagged faces and the background colour. My source is: #include <irrlicht.h> using namespace irr; using namespace core; using namespace scene; using namespace video; using namespace io; using namespace gui; int main(int argc, char** argv) { IrrlichtDevice *device = createDevice(EDT_SOFTWARE, dimension2d<s32>(640, 480)); device->setWindowCaption(L"Hello World! - Irrlicht Engine Demo"); IVideoDriver* driver = device->getVideoDriver(); ISceneManager* smgr = device->getSceneManager(); IGUIEnvironment* guienv = device->getGUIEnvironment(); guienv->addStaticText(L"Hello World! This is the Irrlicht Software renderer!", rect<int>(10,10,200,22), true); IMesh* mesh = smgr->getMesh("Castle#12.3ds"); //IMeshSceneNode *node = smgr->addMeshSceneNode(mesh); ISceneNode *node = smgr->addOctTreeSceneNode(mesh); if (node) { node->setMaterialFlag(EMF_LIGHTING, false); //node->setFrameLoop(0, 310); node->setMaterialTexture( 0, driver->getTexture("Texture.jpg") ); node->setScale(vector3df(6, 6, 6)); } //smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0)); smgr->addCameraSceneNodeFPS(); device->getCursorControl()->setVisible(false); while(device->run()) { driver->beginScene(true, true, SColor(255,200,200,200)); smgr->drawAll(); guienv->drawAll(); driver->endScene(); } device->drop(); return 0; }
  6. Irrlicht Texturing Problem

    Thanks, I'm using blender, how would I solve this problem? Is there a better way to export the mesh?
  7. I downloaded irrlicht, (via CodeBlocks DevPak plugin), and loaded the sample program. I changed the model used (from an animMesh to a plain mesh), and the texture, however when I run it, I get my mesh uniformly coloured the colour of the first pixel. The source code that I changed was: //IAnimatedMesh* mesh = smgr->getMesh("../../media/sydney.md2"); //IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh ); IMesh* mesh = smgr->getMesh("Castle.3ds"); IMeshSceneNode *node = smgr->addMeshSceneNode(mesh); if (node) { node->setMaterialFlag(EMF_LIGHTING, false); //node->setFrameLoop(0, 310); node->setMaterialTexture( 0, driver->getTexture("RedTexture.png") ); } On a side note, I tried to do a similar thing with Blitz3D, and the same thing happened - I could see my mesh, but it was uniformly the colour of the first pixel of the image. I exported the .3ds file from Blender, and I also have tried this with an exported .x file aswell, with the same result (except a different starting orientation of the mesh). I want to have the whole texture spread over the whole mesh. Any help would be much appreciated.
  8. Hello, For the past four hours I have been trying to export an animation from Blender and get it to work in Blitz3D. I have exported it as .3ds (which I soon found out, isn't supported by blender for animation), .x and b3d (using a downloaded exported from, and none of these work. Sometimes I get a totally blank 3d plane, but more usually I see my model frozen in its first frame. My model is very basic and is only there for example purposes, it has no textures and is just a cube that has been extruded to form an upside-down U, with armatures to make it "walk". As I said before, I've been trying various approaches for the past 4 hours, have downloaded the most recent version of Blender, its appropriate python version and a demo of the most up to date Blitz3D. I don't know if there is a lack of support for this, or if I'm just being stupid and overlooking something obvious, but I would greatly appreciate anyone who could give me a step-by-step guide to exporting an animation from Blender and getting it to move in Blitz3D. Thanks
  9. Pygame program not closing properly

    Thanks the "sys.exit()" thing works, but shuts down not only the pygame instance, but also IDLE (the interactive part and the window with my program). If it was an enviromental thing, what should I do - reinstall python and pygame (with the most recent version)? Thanks for your help
  10. Hi I'm making a basic game in python, so that I can mess around with various features I feel would be nice in other games - so I can test them in a (supposedly) easier language before putting them in C++. I've used python before, though never really learnt it properly. Now when I try to follow the tutorials that make a window it never shuts properly. I have initialized the event loop, but when I click the cross on my game window it won't shut - I get the "Program Isn't Responding" box and have to click "End Now". This is my code - I'm running Windows XP with Python 2.5.1, IDLE 1.2.1. import pygame def LoadImage(fileName, colourKey=None): try: image = pygame.image.load(fileName) except pygame.error, message: print "Error Loading Image:", fileName raise SystemExit, message image = image.convert() if colourKey is not None: if colourKey is -1: colourKey = image.get_at((0,0)) image.set_colourKey(colourKey, RLEACCEL) return image, image.get_rect() class Tile: def __init__(self, imageName): self.image, self.rect = LoadImage(imageName) def draw(self, screen, x, y): screen.blit(self.image, (x, y)) def main(): screen = pygame.display.set_mode((640, 480)) clock = pygame.time.Clock() running = 1 grassTile = Tile("GrassTile.bmp") dustTile = Tile("DustTile.bmp") while running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = 0 clock.tick(20) screen.fill((0, 0, 0)) grassTile.draw(screen, 0, 0) dustTile.draw(screen, 64, 0) pygame.display.flip() if __name__ == "__main__": main() Thanks for any help
  11. Hiya I've been researching for a long time now how to make my own computer and I'm almost ready to buy the parts for this. I was wondering though if there was any way to attach some circuitry (probably something controlled by a PIC microcontroller) to the computer. So I was wondering if there was any way to do this physically, but also how would I have to program for it (assembly?)? Thanks
  12. Hiya I need some help on where to start, and advice if what I'm doing is reasonable. Basically I want to get free texts over two phones - I know this seems impossible, but hear me out: I need the phones to communicate between two houses, the houses are within 60 meters, so I was wondering I could set up some sort of radio/wireless connection between them and then write a program in Java to use the connection to communicate - so essentailly its not texting, its sending messages using some other sort of program. Unfortunatly I need communication between two phones (not a computer and a phone) and bluetooth is too short ranged (otherwise it'd be perfect). Could you please tell me: - Is it viable? (I know there'll be set-up costs, but I don't want any continuoues costs) - What equipment would I need, would I need to create the communications devices and plug them into the phones? - What knowledge do I need? I know C++ and can do a bit of Java, but if I'm making a device from scratch will I need assembly (oh no...) for driver programming, can mobile phones even have drivers? - Are there other things I should look into? I'd really appreciate any help you can offer me.
  13. Hiya If you were looking for a tutorial would you prefer to find a text one or a video one? And if you were using a video one would you think it unprofessional if the person showing it made occasional typos or errors and had to recompile?
  14. Well I know the whole different shapes, different rotations, different sizes thing would be extremely difficult - but I am just wanting to do what Palidine says - same image, exactly the same size everytime. The only differences will be the position and the background - by transparency I mean that the image I am searching for has some transparent pixels in it - which won't be drawn to the screen, therefore I will just skip checking for those pixels. At the moment I would just like to know if there is somewhere to get the screen image and a good library for handling images on a pixel level (I don't mind what format).
  15. Erm, well I can get the image by pressing "Print Screen", and the image I am searching for is not rectangular. I was just going to find the first none transparent pixel in the image that I am going to look for (it will be no bigger than 64x64) and look for a pixel on the screen with the same RGB value, then I was going to see if the next none transparent pixel from the picture was the same colour as the corresponding one on the screen, and carry on like that returning false if it doesn't match. Then if they were all equal return a true (or the position the picture was found on the screen). I'm sorry if that doesn't help much, I don't know alot (I don't know what an accelerated display or a feature space are!). Thanks for the help though