Gibbon_99

Members
  • Content count

    30
  • Joined

  • Last visited

Community Reputation

122 Neutral

About Gibbon_99

  • Rank
    Member
  1. Trying to compile v2.18 (SVN) into my game to avoid needing an additional lib file. This is on Linux 64bit using Codeblocks. Compiling gives me this error: ||=== baseCode, Debug ===| /src/script/as_callfunc.cpp||In function ‘int PrepareSystemFunction(asCScriptFunction*, asSSystemFunctionInterface*, asCScriptEngine*)’:| /src/script/as_callfunc.cpp|301|error: ‘TXT_DONT_SUPPORT_TYPE_s_BY_VAL’ was not declared in this scope| ||=== Build finished: 1 errors, 0 warnings ===| Doing a grep on the src tree doesn't show up the value of TXT_DONT_SUPPORT_TYPE_s_BY_VAL anywhere? <prompt>/Linux/AngelScript_2.18.0$ grep -r -i TXT_DONT_SUPPORT_TYPE_s_BY_VAL . ./angelscript/source/as_callfunc.cpp: str.Format(TXT_DONT_SUPPORT_TYPE_s_BY_VAL, func->parameterTypes[n].GetObjectType()->name.AddressOf()); I've copied all the source files from the SVN source directory into my project, and have added them all - but I can't see where TXT_DONT_SUPPORT_TYPE_s_BY_VAL is defined anywhere. Thanks
  2. Circular explosion with definable points

    Quote:Original post by CrimsonSun Have you measured your performance and determined this to be a bottleneck? I think you may be focusing on too low of a level. I would be surprised if your implementation didn't already use lookup tables or some sort of fast numerical algorithm for trig functions. It seems to be taking about 1.01% of the total frame rate to do the calculations on 45 points. Not much. But - I plan on having a fair number of these 'explosions' happening at once on the screen. It's written in plain C running on Linux - so I wouldn't think it would be using any sort of lookup tables already. EDIT: found this http://www.flipcode.com/archives/Fast_Trigonometry_Functions_Using_Lookup_Tables.shtml Gives a nice speed boost - and plugs straight into the existing solution. WIN ! [Edited by - Gibbon_99 on December 1, 2009 11:30:22 PM]
  3. Circular explosion with definable points

    That works as well ! Thanks. PS: To be a little more efficient I should setup a lookup table for the COS and SIN as well. Would I be right in guessing that these calculations are resulting in a radian result? How do you go about setting up a COS lookup table for radians. I would imagine that a degree lookup table would be something like double cosTable[360] - but I obviously can't use a radian as an index into that table.
  4. Circular explosion with definable points

    Quote:Original post by bzroom I dunno if you're just trying to be crazy or what.. but what's wrong with this? void getParticlePositions(float _x, float _y, float _r, float segments) { float theta = 2.0f * PI / segments; for (int i = 0; i != segments; ++i) { particlePos[i].x = _x + cos(i * theta) * _r; particlePos[i].y = _y + sin(i * theta) * _r; } } That still doesn't draw a set of points, evenly spaced around a circle. But this does. void getParticlePositions(float _x, float _y, float _r, float segments) { float theta = 2.0f * PI / segments; int stepSize = 360 / segments; for (int i = 0; i != segments; ++i) { particlePos[i].x = _x + cos(i + stepSize * theta) * _r; particlePos[i].y = _y + sin(i + stepSize * theta) * _r; } } As long as I use a reasonable number of segments, I get a nice expanding circle of points from a central point. If I use something like 10 segments, I get three in the top left diagonal, 4 in the top right diagonal, and three heading straight down. Thanks !
  5. Circular explosion with definable points

    void getParticlePositions(float _x, float _y, float _r, float segments) { float theta = 2 * PI / (float)segments; float tangetial_factor = tanf(theta); float radial_factor = 1 - cosf(theta); float x = _x + _r; float y = _y; for (int i = 0; i != segments; i++) { float tx = -(y - _y); float ty = x - _x); x += tx * tangetial_factor; y += ty * tangetial_factor; float rx = _x - x; float ry = _y - y; x += rx * radial_factor; y += ry * radial_factor; particlePos[i].x = x; particlePos[i].y = y; } } If I use 360 segments, I get a full circle, if I use 180 segments, I get a semi-circle - not a circle with the points spaced further apart.
  6. I'm trying to find an algorithm that will allow me to create an explosion effect using particles in 2D. I'd like to be able to define the number of points - and have them evenly spaced around the circles center, and radiate out from there. I have one working now - but it only works if I use 360 points - if I use anything else, for example 90 points - then it only draws an arc. There are lots of circle functions, but they all seem to assume that you want to draw a full circle. Code in C would be great. Thanks
  7. Excellent - thanks.
  8. Hi I'm looking at getting a new laptop and I want to develop OpenGL 3.2 apps with it. I want it to have a nVidia graphics card but looking at the specifications page on the nVidia site - the newest mobile chipset ( the 100 series ) only supports OpenGL 2.1. Mind you - the specs for a GTX295 also say OpenGL 2.1. Is that enough hardware support to run the latest nVidia drivers for GL 3.2 support? Thanks
  9. Quote:Original post by Gage64 Quote:Original post by Gibbon_99 kmMat4OrthographicProjection(&projectionMatrix, 0.0f, (float)winWidth, (float)winHeight, 0.0f, 1.0f, 100.0f); kmGLGetMatrix(KM_GL_PROJECTION, &projectionMatrix); It seems like the 2nd call overwrites the value of projectionMatrix that was computed by the first call. Ah - yes - you are right ! Now I get nothing drawn on the screen - I'll need to find what else is wrong. thanks ** EDIT Solved - Needed to translate into view - kmGLTranslatef(0.0, 0.0f, -1.0f); Cheers [Edited by - Gibbon_99 on October 4, 2009 6:15:57 AM]
  10. I'm trying to use Kazmath with openGL 3.2 and shaders for a 2d game. I'm attempting to setup a 2d ortho view where I can use the window size as the coordinates - ie: top left (0,0) bottom right (640,480) I have the following code for setting up the matrix info kmMat4 projectionMatrix; kmMat4 modelview; glUseProgram(shaderProgram[SHADER_NORMAL].programID); glViewport(0, 0, winWidth, winHeight); kmGLMatrixMode(KM_GL_PROJECTION); kmGLLoadIdentity(); kmMat4OrthographicProjection(&projectionMatrix, 0.0f, (float)winWidth, (float)winHeight, 0.0f, 1.0f, 100.0f); kmGLGetMatrix(KM_GL_PROJECTION, &projectionMatrix); kmGLMatrixMode(KM_GL_MODELVIEW); kmGLLoadIdentity(); // kmGLTranslatef(0.0f, 0.0f, 1.5f); kmGLRotatef(rotateAngle, 0.0f, 0.0f, 1.0f); // rotate kmGLGetMatrix(KM_GL_MODELVIEW, &modelview); // // Load the matrixes into the vertex shader glUniformMatrix4fv(modelMatrixLocation, 1, GL_FALSE, modelview.mat); glUniformMatrix4fv(projMatrixLocation, 1, GL_FALSE, projectionMatrix.mat); gl_getAllGLErrors("updateScreen"); // Clear the background glClearColor(0.0, 0.0, 0.3, 1.0); glClear(GL_COLOR_BUFFER_BIT); glDrawArrays(GL_TRIANGLE_FAN, 0, 4); // Swap buffers glfwSwapBuffers(); and this is the vertex shader #version 150 // in_Position was bound to attribute index 0 and in_Color was bound to attribute index 1 in vec3 in_Position; in vec3 in_Color; uniform mat4 projMat; uniform mat4 modelMat; // We output the ex_Color variable to the next shader in the chain out vec3 ex_Color; void main(void) { vec4 pos = modelMat * vec4(in_Position, 1.0); gl_Position = projMat * pos; ex_Color = in_Color; } This works, I get a spinning diamond on the screen - but it's not using ortho coordinates - only coordinates between 0.0 and 1.0. Thanks for any advice.
  11. Help - Should I move to VBOs?

    Quote:Original post by snoutmate Do you have the VBO bound before calling the gl*Pointer functions ? Works !! Changing from glVertexPointer(2, GL_FLOAT, sizeof(myVertex), BUFFER_OFFSET(0)); glTexCoordPointer(2, GL_FLOAT, sizeof(myVertex), BUFFER_OFFSET(sizeof(GLfloat) * 2)); glBindBuffer(GL_ARRAY_BUFFER, splashVBOID); to glBindBuffer(GL_ARRAY_BUFFER, splashVBOID); glVertexPointer(2, GL_FLOAT, sizeof(myVertex), BUFFER_OFFSET(0)); glTexCoordPointer(2, GL_FLOAT, sizeof(myVertex), BUFFER_OFFSET(sizeof(GLfloat) * 2)); Thank you for your help !
  12. Help - Should I move to VBOs?

    Ok - that makes sense So now it looks like glVertexPointer(2, GL_FLOAT, sizeof(myVertex), BUFFER_OFFSET(0)); //(const char *)&myQuad[0].x); glTexCoordPointer(2, GL_FLOAT, sizeof(myVertex), BUFFER_OFFSET(sizeof(GLfloat) * 2)); //(const char *)&myQuad[0].s); But now I get a seg fault on glDrawArrays(GL_QUADS, 0, NUM_VERTS_SPLASH); The page does mention that if you are using interleaved arrays - that you need to specify the stride in gl*Pointer. Have I got sizeof(myVertex) right as the stride - The stride takes it from myQuad[0].x to the next coordindate myQuad[1].x - therefore the stride is the size needed to get to the start of the next vertex. Is that right?? Thanks for your help so far.
  13. Help - Should I move to VBOs?

    Thanks - I've already been using that as a reference.
  14. Help - Should I move to VBOs?

    I've been trying to get a basic VBO to work - but I'm not having much luck. I can't see what is wrong with the code below. It draws a full screen textured quad on my laptop ( Intel chipset ) but on the PC ( NVidia GTX 295 ) it doesn't show anything. On the laptop the texture shows, but it's below everything else that it should be drawn on top of. All drawing is done in 2D mode and the quad works fine in immediate mode. Another question - is glBegin() / glEnd() still required when using VBO's? Thanks // Draw a test VBO void sysTestVBO() //----------------------------------------------------------------------------- { static bool initDone = false; static GLuint splashVBOID; static GLuint sizeVBO; #define NUM_VERTS_SPLASH 4 struct myVertex { GLfloat x, y; // position GLfloat s, t; // texture coordindate }; myVertex myQuad[NUM_VERTS_SPLASH]; myQuad[0].x = 0.0f; myQuad[0].y = 0.0f; myQuad[0].s = 0.0f; myQuad[0].t = 0.0f; myQuad[1].x = (GLfloat)winWidth; myQuad[1].y = 0.0f; myQuad[1].s = 1.0f; myQuad[1].t = 0.0f; myQuad[2].x = (GLfloat)winWidth; myQuad[2].y = (GLfloat)winHeight; myQuad[2].s = 1.0f; myQuad[2].t = 1.0f; myQuad[3].x = 0.0f; myQuad[3].y = (GLfloat)winHeight; myQuad[3].s = 0.0f; myQuad[3].t = 1.0f; if (false == initDone) { sizeVBO = sizeof(myVertex) * NUM_VERTS_SPLASH; //(NUM_VERTS_SPLASH * NUM_COORDS_PER_VERT_SPLASH) * sizeof(GLfloat); // // Get the VBO buffer ID glGenBuffers(1, &splashVBOID); glBindBuffer(GL_ARRAY_BUFFER, splashVBOID); glBufferData(GL_ARRAY_BUFFER, sizeVBO, (const GLvoid *)&myQuad, GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_NEAREST); initDone = true; } glActiveTexture(GL_TEXTURE0); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texture[SPLASH].textureID); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY); glVertexPointer(2, GL_FLOAT, sizeof(myVertex), (const GLvoid *)&myQuad[0].x); glTexCoordPointer(2, GL_FLOAT, sizeof(myVertex), (const GLvoid *)&myQuad[0].s); glBindBuffer(GL_ARRAY_BUFFER, splashVBOID); glDrawArrays(GL_QUADS, 0, NUM_VERTS_SPLASH); glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_TEXTURE_COORD_ARRAY); gl_getAllGLErrors((char *)"After VBO"); }
  15. Help - Should I move to VBOs?

    Understood. How high will glTranslate() go up to? If my playfield is 10,000 pixels long - can I translate between 0 and 10,000? Given my screen resolution is just a sliding window over the entire playfield.