Advertisement Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

122 Neutral

About DriveByBaptism

  • Rank
  1. DriveByBaptism

    OpenCL AMD Environment Set Up.

    [font=Verdana, Arial, Helvetica, sans-serif][size=2][font=Verdana, Arial, Helvetica, sans-serif][size=2]I am trying to learn OpenCL, but I am having some real problems setting up my environment. I have spent the last 2 hours following links and so called guides on how to run my first OpenCL program. I have update my graphics card drivers to make sure it supports OpenCL (my card is a msi radeon x1550 and I have a really old computer in case you couldn't tell), I downloaded the AMD APP SDK and followed its instructions on how to build/run the first program. But when I do I get the following error: Note it is the simple "hello world" app that comes with it. fatal error C1083: Cannot open include file: 'CL/opencl.h' fatal error C1083: Cannot open include file: 'SDKFile.hpp' I am using Visual Studio Express 2010 and I just ran the program as it came. I haven't touched a line of code or messed with any of the programs hierarchy. Going by the files instructions, it really should have been a case of hit F5 and go. But I keep getting the above errors. I even bought the OpenCL PDF to work through but it doesn't cover set up of AMD. They have a nice bit about everything else, just not AMD. [/font] [font=Verdana, Arial, Helvetica, sans-serif][size=2] [/font] [font=Verdana, Arial, Helvetica, sans-serif][size=2]I can run the precompiled programs that come with the AMD APPS SDK but I can't run the code from inside Visual Studio Express. I have both 2008 and 2010 and both have the same problems.[/font] [/font]
  2. DriveByBaptism

    C++ incremental pointer.

    Y += 1 is the exact same as y++ mate.
  3. DriveByBaptism

    C++ incremental pointer.

    I'm using OpenGL with GLFW and I'm trying to get a number to display, and increment when I click a button. int increment = 1; y = 1; char labelString[1]; sprintf(labelString, "%u", y); attack = new GuiLabel(FontManager::font("medium"), labelString, -280, -70, 1.0, true); add(attack); Some notes: y is a pointer to an integer stored in the header file. GuiLabel, is what I'm using to display text. It sets the font, what you want to say, x pos, y pos, scale and shadow. In my button code, I've simply got it going y += 1; but I'm getting the following error with this, that I don't know how to defeat: cannot convert from 'int' to 'int * Tried googling, but got nothing.
  4. I've been goggling my butt off for the past few days trying to find OpenGL specific tutorials/code snippets online that deal with the above two problems. I was wondering if any of you have used anything to solve the above two problems I need to complete. If not sites, the how about any books? Namely; will this book teach me the topics? Any help would be appreciated.
  5. DriveByBaptism

    XNA 2D sprite rotation

    [color="#4A4A4A"] What I'm trying to do is make a CCTV camera rotate about a point by itself. I've looked about and can't seem to find anything. I've found lots on making objects rotate around other objects, but nothing on making one sprite rotate on the spot. I thought it would be a simple case of updating the angle the spritesits at, but nothing happens when I press my keys. Not this is going to be an enemy object, not the games camera. Making a 2D stealth/spy game. The code I've is like this; [color="#4A4A4A"] Texture2D camera; Vector2 cameraOrigin = new Vector2(11, 50); float cameraAngle = 10.0f; Vector2 cameraPosistion = new Vector2(400, 200); protected override void Update(GameTime gameTime) { if (keyboardstate.IsKeyDown(Keys.A)) { cameraAngle+=0.01f; } base.Update(gameTime); } protected override void Draw(GameTime gameTime) { spriteBatch.Draw(camera, new Rectangle(100, 200, camera.Width, camera.Height), null, Color.White, cameraAngle, cameraOrigin, SpriteEffects.None, 1); base.Draw(gameTime); }[color=#4A4A4A] [color="#4A4A4A"] Can anyone see what I'm doing wrong or missing?
  6. DriveByBaptism

    Getter and setter problem (c++)

    @way2lazy - I know mate. I was just testing something. Plan on making all the variables protected. Thanks though Well I tired this: ship->setSpeed(500); and get the error: error C2039: 'setSpeed' : is not a member of 'BaseShip' Then I tried: shipTwo->setSpeed(10); error: left of '->setSpeed' must point to class/struct/union/generic type They are set up like this: BaseShip* ship = new BaseShip(); BaseShip shipTwo(); Wanted to test both ways. When I hold over the mouse where the red line appears for an error at setSpeed I get the following: BaseShip has no member setSpeed. Any ideas?
  7. I'm trying to access and change the information stored in one class (my baseship class) and have it display in another (ship builder class). I know that I need to use getters and setters to do this (come from a c#/xna background) as I will also need to change to information stored in the baseship class as well. My base ship .h looks like this: #pragma once #include <stdlib.h> class BaseShip { protected: public: BaseShip(void); ~BaseShip(void); int speed; //getters int GetSpeed(); //setters void SetSpeed(int speed); }; the .cpp #include "BaseShip.h" #include <stdlib.h> BaseShip::BaseShip(void) { } BaseShip::~BaseShip(void) { } void BaseShip::SetSpeed(int speed) { this->speed = speed; } int BaseShip::GetSpeed() { return speed; } Now in the class I'm trying to access it I add in the include to the baseship.h file in the required classes.h. Then I create a pointer like: BaseShip *ship; The only problem is, when I try to use ship in the class I don't get access to my set or get methods (only need it to return/display a number). All I get is the ~BaseShip. Can anyone see what it is I'm doing wrong?
  8. DriveByBaptism

    OpenGL Scrolling box

    At the moment I am using GLFW to make use of OpenGL (not sure how much of a difference that will make) and I need to make some scrollable windows that appear in certain game screens. For example, I have a buy screen in my game the needs to display items for sale. Rather than clutter up the screen with all the items I want to make a window where only a set amount of items are on display, and you need to scroll down to the see them all. Much like the browser window your using to view this post. I've looked about but can't seem to find anything. Could someone point me in the right direction for this. I'm fairly new to the world of OpenGL.
  9. DriveByBaptism

    3D Level Loading [DirectX 10]

    Yeah I was thinking about making something like that, but honestly have no where to begin. Hence why I was asking for suggestions the picuture above is what I'm trying to emulate though. No need to worry about rotating around objects etc. Thanks for the responce.
  10. I want to try and create a 3D level for the first time in DirectX. I've messed about with it and have gotten simple models loaded in and moving about. But now I want to create a proper level. I'm planning on creating a level similar in vain to something you'd see in league of Legends. Here is a picture of one of their levels: Whilst the above looks 2D, in game its 3D. My question is this: is there a way that I can generate a level like that without having to hard code in all the positional values? In XNA I've use a streamreader to read in a text file that would inform the computer what object it should place and where. Is there a better way of going about it that using a text file? The reason why I want to do it, it so I can put in collision detection more easily that if it was one large 3D level model. Any help and suggestions would be great. Also, if your going to post something that I "should" use, could you please link me to a good tutorial or something? I've been on here before and gotten one word answers that weren't that helpful. Thanks.,
  11. One of the main mechanics I have in the game I'm working on, is the abilitie to call an ally to attach a guard that blocks your path. Similar to assassins creed. I have got my rebel auto moving to a paticular guard in the following way: public void attackGuard(Guard g) { //find players direction and go to it Vector2 direction = g.Position - this.Position; direction.Normalize(); direction *= speed; this.body.Position = this.body.Position + direction; } In the main class, I call this method and update it, passing in the guard he is to attack. The problem is, my game has multiple instances of the same type of guard. Here is the update method: foreach (Rebel r in testRebels) { r.Update(gameTime); r.UpdateAI(guard1); } The UpdateAI calls the attack guard method. Does anyone have an idea of how I could get my rebel to attack its nearest enemy, reguardless of the type of guard?
  12. I was wondering if you guys know any good ways (and in turn tutorials/source code) for loading in 2D levels for a platformer game. At the moment I'm using streamreader to read in a text file of integers and the code is quite big and a horrid to refactors. At the moment, how I'm doing things is as follows so you get a feel of what I mean: using (StreamReader sr = new StreamReader(LevelName)) { //Starting positions for tiles int x = 0; int y = 0; while (!sr.EndOfStream) { string line = sr.ReadLine(); string[] elements = line.Split(','); foreach (string e in elements) { //Use a char to make the text file easier to read as opposed to intergers int t = int.Parse(e); //load player sprite if (t == 1) { playerSprite = new Player(); playerSprite.Position = new Vector2(x, y); //character.Position = new Vector2(playerSprite.Position.X, playerSprite.Position.Y); playerSprite.Load(@"Sprites/transpbox", Content, simulator);//default image for the player playerSprite.Body.Mass = 10; playerSprite.IsStatic = false; tiles.Add(playerSprite);//added to the tile array playerSprite.Geom.OnCollision += OnCollision;//fired when in contact } Now imagine that for each of your games assets. It's gets ungodly quickly. So I'm just wondering if you guys have any good/quick alternatives.
  13. What I have at the moment is a sprite that will be drawn and follows the mouse cursor where you move the to. The code is as follows, I'm going to omit a lot; #region Intialization protected override void Initialize() { MouseState current_mouse = Mouse.GetState(); int mouseX = current_mouse.X; int mouseY = current_mouse.Y; test1 = new Button(this, "Menu Sprites/Options", "Menu Sprites/Options selected", "Menu Sprites/Options", new Vector2(100, 520), OnClick); test2 = new Button(this, "Rebel/Rebelstilldown", "Rebel/Rebelstilldown", "Rebel/Rebelstilldown", new Vector2(mouseX, mouseY), DrawRebels); IsMouseVisible = true; base.Initialize(); } The above is my button code derived from its own class(main image, hover image, clicked image, location, event delegate. In the update function it is updated like so; this.BUTTONNAME.Update(); Button delegate code; public void OnClick() { testClick = true; } private void DrawRebels() { MouseState current_mouse = Mouse.GetState(); int mouseX = current_mouse.X; int mouseY = current_mouse.Y; clicked = true; if (current_mouse.LeftButton == ButtonState.Pressed) { TESTREBEL = new Rebel(); TESTREBEL.Position = new Vector2(mouseX, mouseY); //set sprite position TESTREBEL.Load(@"Rebel/Rebelstilldown", Content, simulator);//default image for the player TESTREBEL.Body.Mass = 10; TESTREBEL.IsStatic = false; testRebels.Add(TESTREBEL);//added to the tile array TESTREBEL.Geom.CollisionEnabled = false; } } Draw code; if (clicked == true) { foreach (Rebel testRebel in testRebels) { spriteBatch.Begin(); spriteBatch.Draw(testRebel.CurrentTexture, new Vector2(mouseX, mouseY), null, Color.White, testRebel.Rotation, testRebel.Origin, 1, SpriteEffects.None,1); spriteBatch.End(); } } if (testClick == true) { this.test2.Draw(); } My thinking behind how this would work is the following; A button would be on screen that would allow the player to draw a rebel sprite on screen. When this button is clicked, a rebel sprite button is placed on top of the mouse. When the player clicks on the ground, he hits the button and a rebel sprite is left behind and will update according to its AI. I have already made is possible for the sprite to be loaded in via a text file and have its positron correspond to what's in the text file. And thought it would be a simple case of doing what I did above. How ever, when I click, nothing happens. Can anyone see what I'm doing wrong and correct me? Or point me in the right direction of how to do this?
  14. At the moment I am creating a game that requires guards to patrol set paths. I have this working fine. What I'm having problems with is my guards field of view. Right now my guards chase the player when ever he is past there X position on the screen (2D game). This could be ANYWHERE on screen, all my player has to be is in front of them some how and they'll follow. What I want is to try and narrow this down, so that they only chase the player is he is with in a certain field. And only where the enemy is facing. At the moment the I code I have is thus: public void updateAI(Player p) { float distance = this.Position.X - p.Position.X; switch (guardCurrentState) { case GuardState.Patrol: this.setGuardMovement(this); if (distance < guardSight) { guardCurrentState = GuardState.Chase; } increaseThreat = false; break; case GuardState.Chase: this.chasePlayer(p); if (distance > guardSight) { guardCurrentState = GuardState.Patrol; } increaseThreat = true; break; } } public void chasePlayer(Player p) { Vector2 direction = p.Position - this.Position; direction.Normalize(); direction *= speed; this.body.Position = this.body.Position + direction; } public void setGuardMovement(Guard g) { if (g.Coordinates.ElementAt(cindex) != new Vector2(1, 1)) //if a vector is NOT 1,1, continue. // if it is 1,1, it means it has not been read in from the text file and doesnt exist { // delta points is the vector from one point to another Vector2 ?Points = new Vector2(g.Coordinates.ElementAt(cindex).X - g.body.Position.X, g.Coordinates.ElementAt(cindex).Y - g.body.Position.Y); if (?Points.Length() > speed)//if the vector length is greater than the speed scalor { ?Points.Normalize(); //change vector unit length to one ?Points = ?Points * speed; //scale the vector with the speed of the guard g.body.Position = g.body.Position + ?Points; //update teh guards body position by adding on the vector if (g.Body.Position == g.Coordinates.ElementAt(cindex)) //if the body has reached the coordinate { if (cindex == 9) //if the index is at the 10th position, set it to 0 { cindex = 0; } else { cindex++; // else add one to the coordinate index } } } else //if the vector length is less than the speed scalor { g.body.Position = g.body.Position + ?Points; //update teh guards body position by adding on the vector if (g.Body.Position == g.Coordinates.ElementAt(cindex)) //if the body position is equal to the coordinate its traveling too { if (cindex == 9) //if the index is at the 10th position, set it to 0 { cindex = 0; } else { cindex++;// else add one to the coordinate index } } } } else { if (cindex != 9) // if the index is not at last coordinate { cindex++;// increment the index } else { cindex = 0; // otherwise reset index } } } } The first part is a simple FSM with the requirements to allow the guard to change state. The second is the chaseplayer code with the last lump being my guards patrol code. It allows me to set 9 points and for the guard to follow in a clockwise fashion. If you could help me I would be greatful.
  15. At the moment I'm trying to get a 2D game working on the iPhone. I have got OpenGL render and colour buffer working and can render a nice square that floats up and down nicely. What i'm stuck with and need help/point in the right direction is getting a sprite to be drawn in it's place. I have googled my bum off for the past few hours but can't seem to find anything. My code so far is thus: -(BOOL) initOpenGL { //create the EAGLContext, use version 1.1 of OpenGL ES context = [[EAGLContext alloc] initWithAPI: kEAGLRenderingAPIOpenGLES1]; //set the current context to the one just created if(!context || ![EAGLContext setCurrentContext: context]) { [self release]; return NO; } //create default framebuffer object glGenFramebuffersOES(1, &defaultFramebuffer); glGenRenderbuffersOES(1, &colorRenderbuffer); //bind the framebuffer and the colour buffer glBindFramebufferOES(GL_FRAMEBUFFER_OES, defaultFramebuffer); glBindRenderbufferOES(GL_RENDERBUFFER_OES, colorRenderbuffer); //attach the colour buffer to the framebuffer glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, colorRenderbuffer); //allocate colour buffer backing based on the current layer size glBindRenderbufferOES(GL_RENDERBUFFER_OES, colorRenderbuffer); [context renderbufferStorage: GL_RENDERBUFFER_OES fromDrawable: (CAEAGLLayer*)self.layer]; //used to hold the width and height of the back buffer, our depth //buffer must match size of our screen GLint backingWidth; GLint backingHeight; //retriev the backbuffer ehight and width glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth); glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight); //create the depth buffer glGenRenderbuffersOES(1, &depthRenderbuffer); //bind the render buffer glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer); //specfy the format of our depthj buffer glRenderbufferStorageOES(GL_RENDERBUFFER_OES, GL_DEPTH_COMPONENT16_OES, backingWidth, backingHeight); //attach the depth buffer to the backing buffer glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, depthRenderbuffer); //enable depth testing glEnable(GL_DEPTH_TEST); if(glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) { NSLog(@"Failed to make complete framebuffer object %x", glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES)); return NO; } //create a time that is going to fire 60 times a second animationTimer = [NSTimer scheduledTimerWithTimeInterval:(NSTimeInterval)(1.0/60.0) target: self selector:@selector(render) userInfo:nil repeats:TRUE]; touchRotation = -90.0f; return YES; } -(void) render { static float transY = 0.0f; static const Vertex3DLit verts[]= { -0.5f, -0.33f, 1.0f, //position 0 0.0f, 0.0f, 1.0f, //normal 255, 255, 0, 255, //colour 0 0.5f, -0.33f, 1.0f, 0.0f, 0.0f, 1.0f, //normal 0, 255, 255, 255, -0.5f, 0.33f, 1.0f, 0.0f, 0.0f, 1.0f, //normal 0,0,0,0, 0.5f, 0.33f, 1.0f, 0.0f, 0.0f, 1.0f, //normal 255,0,255,255 }; //this appilcation only creates a single context which is already set current at this point //this call is redundant, but needed if dealing with multple contexts [EAGLContext setCurrentContext: context]; //this applicaton only creates a single default framebuffer which is already bound at this point //this call is redundant, but needed if dealing with multple framebuffers glBindFramebufferOES(GL_FRAMEBUFFER_OES, defaultFramebuffer); //setup the viewport this will usuable be the bounds of the UIView glViewport(0, 0, self.layer.bounds.size.width, self.layer.bounds.size.height); //set up the projection matrix glMatrixMode(GL_PROJECTION); //with the identity matrix glLoadIdentity(); gluPerspective(45.0f, self.layer.bounds.size.width / self.layer.bounds.size.height, 0.1f, 100.0f); //set the model view matrix (combined view and world matrix) glMatrixMode(GL_MODELVIEW); //with identity glLoadIdentity(); //calc look at matrix gluLookAt(0.0f, 0.0f, -10.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f); //translate the top of the matrix stack glRotatef(touchRotation, 0.0f, 0.0f, 1.0f); glTranslatef(0.0f, (GLfloat)(sinf(transY)/2.0f), 0.0f); transY += 0.075f; //set the clear colour glClearColor(0.5f, 0.5f, 0.5f, 1.0f); //glClearDepthf(0); //clear the colour buffer glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); //specifies the format the vertices glVertexPointer(3, GL_FLOAT, sizeof(Vertex3DLit),&verts[0].position); //enable a client state, vertex arrays glEnableClientState(GL_VERTEX_ARRAY); glNormalPointer(GL_FLOAT, sizeof(Vertex3DLit), &verts[0].normal); glEnableClientState(GL_NORMAL_ARRAY); //specifies the format of the vertices glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(Vertex3DLit), &verts[0].colours); //enable the colour arraye client state glEnableClientState(GL_COLOR_ARRAY); //draw the vertices that have been bound to the pipeline glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); //define the ambient component of the first light const GLfloat light0Ambient[] = {0.1, 0.1, 0.1, 1.0}; glLightfv(GL_LIGHT0, GL_AMBIENT, light0Ambient); //define the specular component and shininess of the first light const GLfloat light0Diffuse[] = {0.7,0.7,0.7,1.0}; glLightfv(GL_LIGHT0, GL_DIFFUSE, light0Diffuse); //define specular component and shininess of the first light const GLfloat light0Specular[] = {0.7, 0.7, 0.7, 1.0}; const GLfloat light0Shininess = 0.4; glLightfv(GL_LIGHT0, GL_SPECULAR, light0Specular); glLightfv(GL_LIGHT0, GL_SHININESS, &light0Shininess); //define position of the first light const GLfloat light0position[] = {0.0, 10.0, 10.0, 0.0}; glLightfv(GL_LIGHT0, GL_POSITION, light0position); //ambient colour GLfloat ambient[] = {0.0, 0.1, 0.9, 1.0}; glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ambient); //diffuse GLfloat diffuse[] = {0.9, 0.0, 0.1, 1.0}; glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffuse); //specular GLfloat specular[] = {0.3, 0.3, 0.3, 1.0}; glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specular); glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 25.0); //this application ponly creates a single colour renderbuffer which is already bound at this point //this call is redundant, but needed if dealing with multiple renderbuffers glBindRenderbufferOES(GL_RENDERBUFFER_OES, colorRenderbuffer); [context presentRenderbuffer:GL_RENDERBUFFER_OES]; } Is someone could tell me how to load in a sprite on the iPhone using OpenGL es I would be greatful. Thanks.
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!