mikenovemberoscar

Members
  • Content count

    74
  • Joined

  • Last visited

Community Reputation

215 Neutral

About mikenovemberoscar

  • Rank
    Member
  1. OpenGL Confused about OpenGL 3.0+ shaders

    Hi Marc,   Thanks so much for your reply, it was very informative. I did what you said but it still isn't working, however I found out that my glGetUniformLocation calls are returning -1. Why could this be?   Here's what I'm now doing:   (at startup) loadShaders(...); glUseProgram(programShaderID); glBindAttribLocation(...); int projectionMatrixLocation = glGetUniformLocation(programShaderID, "projectionMatrix"); int viewMatrixLocation = glGetUniformLocation(programShaderID, "viewMatrix"); int modelMatrixLocation = glGetUniformLocation(programShaderID, "modelMatrix"); // THESE ^^ RETURN NEGATIVE ONE! projectionMatrix = getProjectionMatrix(); (each frame) viewMatrix = glm::... modelmatrix = glm::... glUniformMatrix4fv(projectionMatrixLocation, 1, GL_FALSE, &projectionMatrix[0][0]); glUniformMatrix4fv(viewMatrixLocation, 1, GL_FALSE, &viewMatrix[0][0]); glUniformMatrix4fv(modelMatrixLocation, 1, GL_FALSE, &modelMatrix[0][0]); drawModels(); Thanks :)
  2. OpenGL Confused about OpenGL 3.0+ shaders

    Yes that was probably my fault- but like I said- whatever I put there doesn't make a difference, no translations are being done. Plus- no linker errors from the shader loader are generated?
  3. OpenGL Confused about OpenGL 3.0+ shaders

    Thanks for the reply,  TheChubu.   I did what you said- but nothing happened. The entire scene is rendered however no translation is being done. I'm not sure if it makes a difference, but I noticed that you wrote: vertexPosition_modelspace instead of in_Position But whatever I change that variable to- nothing happens. Are you sure I don't have to somehow feed each variable through the shader? Or is that automatic?   My graphics card is an "ATI Mobility Radeon HD 2400 XT". My machine is a 2011 iMac but running Boot Camped WinXP.
  4. Hi all,   I recently discovered that the latest OpenGL standards have deprecated glTranslatef and a bunch of other immediate-mode functions. My graphics hardware is not great (it doesn't support VAOs, for instance) but I feel I should learn the correct way of doing things.   I read these tutorials: http://www.swiftless.com/opengltuts/opengl4tuts.html and the ones at opengl-tutorial.net.   I tried to implement shaders into my code, but I just see some yellow lines...   Here's what I'm doing: (my shader loading function is from here):   In the initiation procedure:       glViewport(0, 0, (GLsizei) screenSize.x, (GLsizei) screenSize.y);       projectionMatrix = glm::perspective( 75.0f, screenSize.x / screenSize.y, clip_near, clip_far);   int programShaderID = loadShaders("vertexShader.txt","fragmentShader.txt");      glBindAttribLocation(programShaderID, 0, "in_Position"); // Bind a constant attribute location for positions of vertices      glUseProgram(programShaderID); Drawing is done by VBOs only (my hardware doesn't support VAOs AFAIK), in the usual way as far as I can see.   Every frame, after drawing:     int projectionMatrixLocation = glGetUniformLocation(programShaderID, "projectionMatrix"); // Get the location of our projection matrix in the shader           int viewMatrixLocation = glGetUniformLocation(programShaderID, "viewMatrix"); // Get the location of our view matrix in the shader           int modelMatrixLocation = glGetUniformLocation(programShaderID, "modelMatrix"); // Get the location of our model matrix in the shader         glUniformMatrix4fv(projectionMatrixLocation, 1, GL_FALSE, &projectionMatrix[0][0]); // Send our projection matrix to the shader           glUniformMatrix4fv(viewMatrixLocation, 1, GL_FALSE, &viewMatrix[0][0]); // Send our view matrix to the shader           glUniformMatrix4fv(modelMatrixLocation, 1, GL_FALSE, &modelMatrix[0][0]); // Send our model matrix to the shader   Shaders:      vertex: #version 330 core in vec3 in_Position; void main(){ uniform mat4 projectionMatrix; uniform mat4 viewMatrix; uniform mat4 modelMatrix; gl_Position = projectionMatrix * viewMatrix * modelMatrix * vec4(vertexPosition_modelspace, 1.0); }      fragment: #version 330 core out vec3 color; void main(){ color = vec3(1,0,0); } I can see something, but my glm::matrices are not seeming to work (i.e. the translation is NOT happening). I'm so confused, and most of the tutorials seem to use VAOs which I can't do.   Am I doing this right? Can I use shaders without VAOs? Am I supposed to pass vertex to a shader, like I did with the matrices?   EDIT: I checked, and it is only the translation which is not happening as far as I can see. Why is this?   Thanks very much in advance   mikey
  5. C++ Binary File I/O Problem

    Ah thankyou Brother Bob and rip-off! That fixed it. I apologise too - the reason no file was being written was I had not closed the ofstream before checking the file's size.  Thanks again!
  6. Hi all,   I am trying to write binary data to a file, and I have the following C++ code: (I borrowed the write & read functions from here) u8 readU8(istream& file) { u8 value = '\0'; file.read((char*)value,1); return value; } void writeU8(ostream &file, u8 value) { file.write((char*)value,1); } ... animationFile.open("/Users/me/Desktop/BINARY_FILE.bin", ios::out | ios::binary | ios::trunc); if (!animationFile.is_open()) { return 1; } writeU8(animationFile,u8('a')); ... Although my program crashes and lldb returns an 'EXC_BAD_ACCESS (code = 1, address = 0x50).   What is wrong? If I change writeU8 to writeU16 (and the anonymous object to u16('a')): void writeU16(ostream &file, u16 value) { u8 bytes[2]; // Extract the individual bytes from our value. bytes[0] = (value) & 0xFF; // Low byte bytes[1] = (value >> 8) & 0xFF; // High byte // Write those bytes to the file. file.write((char*)bytes,2); } There is no exception, but no data is written to the file. I have also tried many different paths and filenames.   Thanks
  7. Platform and IDE dilemma with C++11

    Thanks for all the replies. Argh I would love Windows 7 but I just can't justify the money for what I'd use it for... I'll look into Qt Creator for my Windows stuff (there was another IDE, a Linux one but I can't remember it's name).
  8. Platform and IDE dilemma with C++11

    Hey all,   I'm a C++ coder, and I used to always code with Xcode on Mac. Recently I boot-camped my iMac to run Windows XP, and then acquired Visual Studio 2010 Ultimate and proceeded to use that for C++ projects.   I fell in love with VS2010, and it seems that VS is the industry standard IDE for the type of software development I am interested in, so it would be fantastic to continue using it.   My problem is that VS2010 does not support C++11 features, and I hate writing out a new loop counter variable which is used once to then create a 'currentItem' pointer, it would be fantastic to be able to take advantage of C++11's features. I also try and keep up with the latest technologies and update my coding style to suit, so templates  and the rest would be helpful.   If I could purchase Visual Studio 2012 Ultimate is there any way that could run on XP? Could I configure VS2010 to run using GCC (or the MinGW equivalent), as GCC has C++11 features? Is there any extensions/hacks/add-ins for VS2010 which can give me C++11 features? Should I just switch to Xcode, or stay and labour with normal C++? Thanks   mikenovemberoscar
  9. OXY - A programming language

    Awesome thanks!
  10. OXY - A programming language

    Hi, I attempted to write my own language a while ago but I really got lost in complexity. I'd really appreciate it if you could share any resources (tutorials, websites, etc) that you used, or if there was any really useful resources on writing a compiler or interpreter?   Thanks.
  11. LEON - A simple text-based data format

    LEON looks really cool, good job.
  12. Getting frustrated with programming.

    Thanks OandO that looks really helpful...
  13. Getting frustrated with programming.

    Cheers mate. Hopefully this new 3D game will be better than my last 3D game: https://sites.google.com/site/michaelssoftwaresite/starfighter-2
  14. Getting frustrated with programming.

    Cheers for the replies guys :) I like the look of MonoGame. I looked into Allegro but I'd prefer 3D, but I shall look into it again anyway thanks.      Yeah I sometimes wish I loved 2D platformers... but sadly I am not really a gamer, and when I am I play FPS games. Which reminds me I did have my engine knocking about somewhere, but no graphics libraries... arrghhhhhhh.... looks like I'll have to bash on with hacking at SFML... while I'm here, does anyone know of a better alternative or some decent Mac SFML tutorials?
  15. Getting frustrated with programming.

    Hi all, frustrated hobby programmer here.   The story goes something like this...   I've been programming for a while, making stupid text based games, and messing around but you could count my list of finished projects on Bart Simpson's hand.   I recently tried to use SFML (GLUT didn't work anymore) but I just kept running into problem after error after problem. Before that I tried to get started with networking (sockets and that) but I'm on a Mac it's hard to find relevant tutorials for people with no experience. The list goes on.   I'm pretty open minded to any sort of interesting project, but the thing is I just can't find any. I am pretty fluent in C++ and a few other languages but I just am out of ideas (and steam).   It feels like I've followed all the 'beginner' tutorials, but where do I go now? The state of computer education where I live at my stage is abysmal. I like games, but I am constantly getting bogged down hacking graphics libraries to work with my code. I wanted to write a compiler but it seems all the tutorials are for people at university. I wrote a text based adventure, it was pretty boring and I again got stuck at the final hurdle: actually releasing the executable and source files.   Where did you go after learning the beginner tutorials? I would like to do something vaguely interesting, what options are available? How can I actually implement my language skills, without getting bogged down in technology I don't really need?   Are there any half decent graphics/network/audio libraries for Mac? Are there any guides for getting started with them (I like SFML but there is not a lot of Xcode relevant documentation). Are there any intermediate projects you think are worth giving a shot?