• What do you need help with? Version 1
    5,001 replies, posted
Long time since I last messed with shaders, but [code]uniform sampler2D textureA; uniform sampler2D textureB;[/code] ? [editline]08:18PM[/editline] :ninja:
[QUOTE=ZeekyHBomb;24690528]Long time since I last messed with shaders, but [code]uniform sampler2D textureA; uniform sampler2D textureB;[/code] ? [editline]08:18PM[/editline] :ninja:[/QUOTE] I just figured out that I can change the whole texture just the same as I can change the array index XD And what do you mean you haven't used shaders? Aren't they like a core part of OGL 3+?
I have. It's just been a while back, since I abandoned my OGL project for a rewrite in D2, but I haven't yet come to that because of other projects and difficulty setting up [url=http://www.dsource.org/projects/derelict]Derelict[/url]-stuff.
[QUOTE=ZeekyHBomb;24690709]I have. It's just been a while back, since I abandoned my OGL project for a rewrite in D2, but I haven't yet come to that because of other projects and difficulty setting up [url=http://www.dsource.org/projects/derelict]Derelict[/url]-stuff.[/QUOTE] Is it a good idea to make separate classes for stuff like Shaders, Shader programs, Textures? I mean, I could put stuff like uniform locations in a Dictionary in a ShaderProgram class and stuff like that. Is that good or is there a better way?
I wrote on a class like that myself. I found it way more intuitive to use than having OGL calls every time I write a new shader.
[cpp] public void Render () { GL.Clear( ClearBufferMask.ColorBufferBit ); GL.ActiveTexture( TextureUnit.Texture0 + 0 ); GL.BindTexture( TextureTarget.Texture2D, Textures[ (int)TextureNames.Blank ].ID ); GL.Uniform1( Program.Locations[ "texture" ], 0 ); GL.EnableClientState( ArrayCap.VertexArray ); GL.BindBuffer( BufferTarget.ArrayBuffer, testBuffer.ID ); GL.VertexAttribPointer( Program.Locations[ "position" ], 4, VertexAttribPointerType.Float, false, 5, 0 ); GL.VertexAttribPointer( Program.Locations[ "texcoord" ], 4, VertexAttribPointerType.Float, false, 5, 3 ); GL.EnableVertexAttribArray( Program.Locations[ "position" ] ); GL.EnableVertexAttribArray( Program.Locations[ "texcoord" ] ); GL.BindBuffer( BufferTarget.ElementArrayBuffer, elementBuffer.ID ); GL.DrawElements( BeginMode.Triangles, 4, DrawElementsType.UnsignedInt, 0 ); GL.DisableVertexAttribArray( Program.Locations[ "position" ] ); GL.DisableVertexAttribArray( Program.Locations[ "texcoord" ] ); SwapBuffers(); }[/cpp] Is this right? If I'm understanding this correctly I'm first giving OpenGL an array of floats, 5 per vertex, 20 total. Then I'm telling it that that the position of the vertex is at 0 offset and that there's a new position every 5 elements. Then I tell it that there are texture coords at the offset of 3 (or should that be 3*sizeof(float)?) It just displays a blank screen so I don't know what to do. If all this is correct then the problem is somewhere else. This is my buffer class, testBuffer and elementBuffer are it's instances: [cpp] class Buffer { public int ID; public Buffer ( BufferTarget Target, int Size, float[] Data, BufferUsageHint Hint ) { GL.GenBuffers( 1, out ID ); GL.BindBuffer( Target, ID ); GL.BufferData( Target, (IntPtr)Size, Data, Hint ); } public Buffer ( BufferTarget Target, int Size, uint[] Data, BufferUsageHint Hint ) { GL.GenBuffers( 1, out ID ); GL.BindBuffer( Target, ID ); GL.BufferData( Target, (IntPtr)Size, Data, Hint ); } }[/cpp] [editline]10:44PM[/editline] Also, in my fragment shader I have this: [cpp] gl_FragColor = texture2D( texture, texcoord );[/cpp] when I change it to gl_FragColor = vec4 (1.0, 0.0, 0.0, 1.0); it crashes when I run it. What?
I knew I wouldn't get an answer to this the second I hit post. Could someone please try to help? I know it seems long but it's really not.
You've enabled texturing and selected your program with glUseProgram somewhere earlier in your code, right? Your array data doesn't seem to add up right. Position is four values, starting at 0. Texcoords is four values, which it probably shouldn't be, starting at 3. It's looking like this: [code] 0 | 1 | 2 | 3 | 4 | 5 | 6 | POS.X | POS.Y | POS.Z | POS.W | | POS.X | POS.Y | | | | TEX.S | TEX.T | TEX.U | TEX.V | [/code] Note the overlap. Also, I think it should be offset*sizeof(float). From the glVertexAttribPointer page: [quote]If a non-zero named buffer object is bound to the GL_ARRAY_BUFFER target (see glBindBuffer) while a generic vertex attribute array is specified, pointer is treated as a [B][I]byte[/I] offset[/B] into the buffer object's data store.[/quote] Same goes for stride, I think.
I'm sure it's blindingly obvious, it'm just being an idiot, but I'm having trouble with some basic code for my Introduction to Java Programming class. I have the following error messages: [code]--------------------Configuration: <Default>-------------------- S:\MAKINGSUPERAMAZINGPROGRAMSANDSTUFF\THISISMYDAYBUTITISBETTERFORYOUTHANBROCCOLI\src\THISISMYDAYBUTITISBETTERFORYOUTHANBROCCOLI.java:20: cannot find symbol symbol : method drawString(java.lang.String) location: class java.awt.Graphics g.drawString("THIS IS MY SUPER FUN DAY PLANNER DON'T EAT IT"); ^ S:\MAKINGSUPERAMAZINGPROGRAMSANDSTUFF\THISISMYDAYBUTITISBETTERFORYOUTHANBROCCOLI\src\THISISMYDAYBUTITISBETTERFORYOUTHANBROCCOLI.java:21: cannot find symbol symbol : variable currentDate location: class THISISMYDAYBUTITISBETTERFORYOUTHANBROCCOLI g.drawString(currentDate.toString(), 200, 130); ^ 2 errors Process completed.[/code] My code is: [code]import java.util.Date; import java.awt.*; import java.applet.*; public class THISISMYDAYBUTITISBETTERFORYOUTHANBROCCOLI extends Applet { public void paint(Graphics g) { Date currentdate = new Date(); g.drawString("THIS IS MY DAY AND IT IS NOW MORE BETTER FOR YOU THAN BROCCOLI", 200, 70); g.drawString("THIS IS MY SUPER FUN DAY PLANNER DON'T EAT IT"); g.drawString(currentDate.toString(), 200, 130); } }[/code] What exactly did I fuck up?
I haven't used Java, but [code]g.drawString("THIS IS MY SUPER FUN DAY PLANNER DON'T EAT IT");[/code] Should that not take a position?
[QUOTE=Klownox;24709515]I'm sure it's blindingly obvious, it'm just being an idiot, but I'm having trouble with some basic code for my Introduction to Java Programming class. I have the following error messages: [code]--------------------Configuration: <Default>-------------------- S:\MAKINGSUPERAMAZINGPROGRAMSANDSTUFF\THISISMYDAYBUTITISBETTERFORYOUTHANBROCCOLI\src\THISISMYDAYBUTITISBETTERFORYOUTHANBROCCOLI.java:20: cannot find symbol symbol : method drawString(java.lang.String) location: class java.awt.Graphics g.drawString("THIS IS MY SUPER FUN DAY PLANNER DON'T EAT IT"); ^ S:\MAKINGSUPERAMAZINGPROGRAMSANDSTUFF\THISISMYDAYBUTITISBETTERFORYOUTHANBROCCOLI\src\THISISMYDAYBUTITISBETTERFORYOUTHANBROCCOLI.java:21: cannot find symbol symbol : variable currentDate location: class THISISMYDAYBUTITISBETTERFORYOUTHANBROCCOLI g.drawString(currentDate.toString(), 200, 130); ^ 2 errors Process completed.[/code] My code is: [code]import java.util.Date; import java.awt.*; import java.applet.*; public class THISISMYDAYBUTITISBETTERFORYOUTHANBROCCOLI extends Applet { public void paint(Graphics g) { Date currentdate = new Date(); g.drawString("THIS IS MY DAY AND IT IS NOW MORE BETTER FOR YOU THAN BROCCOLI", 200, 70); g.drawString("THIS IS MY SUPER FUN DAY PLANNER DON'T EAT IT"); g.drawString(currentDate.toString(), 200, 130); } }[/code] What exactly did I fuck up?[/QUOTE] I *think* this is obsolete and i don't know java but i think you need to long now = currentDate.GetDate() and you need to set the pos for g.drawString("THIS IS MY SUPER FUN DAY PLANNER DON'T EAT IT");
[QUOTE=Chris220;24709699]I haven't used Java, but [code]g.drawString("THIS IS MY SUPER FUN DAY PLANNER DON'T EAT IT");[/code] Should that not take a position?[/QUOTE] That and what looks kinda strange to me is that apostrophe in the word "DON'T". I use C++ so I don't know if in Java you must escape apostrophe in string or not.
[url]http://www.javapractices.com/topic/TopicAction.do?Id=96[/url] It would appear you do
When you have text containing apostrophe in quotation marks like "Don't" then why should you escape apostrophe if it really isn't a literal to end the string ?
Okay, so I got rid of one error(thanks to you guys), now I only have this error left: [code]--------------------Configuration: <Default>-------------------- S:\MAKINGSUPERAMAZINGPROGRAMSANDSTUFF\THISISMYDAYBUTITISBETTERFORYOUTHANBROCCOLI\src\THISISMYDAYBUTITISBETTERFORYOUTHANBROCCOLI.java:21: cannot find symbol symbol : variable currentDate location: class THISISMYDAYBUTITISBETTERFORYOUTHANBROCCOLI g.drawString(currentDate.toString(), 200, 130); ^ 1 error Process completed.[/code]
You define currentdate but use currentDate ...
Ohh! Thank you, I am such an idiot.
Hey i found this book for under £5 and wondered if its worth it? [QUOTE] A Level Pure Mathematics - Trigonometry by Anthony Nicolaides ISBN: 1872684025 Contents: 1. Angels, Degrees, Radians 2. Meansuration of a Circle 3. The basic Trigonometric Functions 4. The Sum and Difference of 2 angels and compound angles 5. The sums and difference into products 6. Products into sums or differences 7. Double angle formulae 8. Half angle formulae 9. The t-Formulae 10. Expression of a cos@ + b sin@ 11. Identities of circular or Trigonometric Functions and thier applications 12. Eliminate x between circular functions loci 13. Trigonometric Equations 14. Simultaneous Trigonometric Equations 15. The application of the sine and cosine Rules in solving triangles 16. Graphs of Circular or Trigonometric Functions 17. The inverse Trigonometric Function & Graphs for sine, cosine and tangent 18. 3 Dimensional problems 19. Small angles. 20. Misc 21. Solutions to all exercise sets[/QUOTE] I want to learn(or rather refresh) trig for game development However i am NOT taking A levels or anything this book is purely for self study, so would this be a good investment?
[QUOTE=Richy19;24710698]Hey i found this book for under £5 and wondered if its worth it? I want to learn(or rather refresh) trig for game development However i am NOT taking A levels or anything this book is purely for self study, so would this be a good investment?[/QUOTE] [url]http://www.youtube.com/user/khanacademy[/url] all ya need boi.
[QUOTE=Pirate Ninja;24711431][url]http://www.youtube.com/user/khanacademy[/url] all ya need boi.[/QUOTE] Yea but i like to have a written reference to look up
Books are great for learning stuff, and that's only £5. I say go for it!
Very new to this whole thing and I need a spot of help In visual studio 2010 (using visual basic language) How would I go about making a key loop. So when the user presses a button on the program it makes a certain key pressed loop for a user defined amount of times? Sorry if I am not too clear?
[url]http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.send.aspx[/url] Also, Google.
[QUOTE=ZeekyHBomb;24715204][URL]http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.send.aspx[/URL] Also, Google.[/QUOTE] I did try google but I guess I really am retarded. Edit: Like I mentioned I am new and I think I am going to need someone to explain this.
This thread is 'What do you need help with', not 'What do you want us to do for you'. He gave you enough to figure out how you do it on your own, assuming you've actually learnt the language. If you haven't, start with that.
[QUOTE=arienh4;24715880]This thread is 'What do you need help with', not 'What do you want us to do for you'. He gave you enough to figure out how you do it on your own, assuming you've actually learnt the language. If you haven't, start with that.[/QUOTE] Okay okay. I shall give it another go, but what I need wasn't actualy on that page.
how can i make an android app turn down the volume of the ringer? I want to make an app that checks what time it is and if it is later than 7:00am it will put the ringer on silent and then at 5:00pm it will turn it back on for like school.
Okay, so I'm having some trouble with that same program that I posted yesterday. Now, it's all working and no build messages appear, but when I load the applet, the image I have in the code, does not load. Could this be an error of where I put the image? Code is below. [code]/* * THIS IS MY DAY BUT IT IS BETTER FOR YOU THAN BROCCOLI * ZYPHLEN KOTANI * SEPTEMBER 9, 2010 * THISISMYDAYBUTITISBETTERFORYOUTHANBROCCOLI.java * THIS HERE PROGRAM IS USED TO SHOW YOU MY AMAZING DAY AND YOU WILL LIKE IT THANKS FOR COMING BY */ import java.util.Date; import java.awt.*; import java.applet.*; public class THISISMYDAYBUTITISBETTERFORYOUTHANBROCCOLI extends Applet { Image turtle; public void init() { turtle = getImage(getDocumentBase(), "turtle.jpg"); } public void paint(Graphics g) { Date currentdate = new Date(); g.drawString("THIS IS MY DAY AND IT IS NOW MORE BETTER FOR YOU THAN BROCCOLI", 200, 70); g.drawString("THIS IS MY SUPER FUN DAY PLANNER DON\'T EAT IT", 200, 100); g.drawString(currentdate.toString(), 200, 130); g.drawImage (turtle, 10, 10, this); setBackground(Color.orange); } }[/code] [editline]08:44AM[/editline] I have it working now. [editline]08:48AM[/editline] Okay, I have a new problem. My friend, who is sitting beside me just ran the same applet that I just finished. And... his computer restarted. It's happened twice now. I have no idea what is going on, but could anybody shed some light on the situation?
[QUOTE=ROBO_DONUT;24708585]You've enabled texturing and selected your program with glUseProgram somewhere earlier in your code, right? Your array data doesn't seem to add up right. Position is four values, starting at 0. Texcoords is four values, which it probably shouldn't be, starting at 3. It's looking like this: [code] 0 | 1 | 2 | 3 | 4 | 5 | 6 | POS.X | POS.Y | POS.Z | POS.W | | POS.X | POS.Y | | | | TEX.S | TEX.T | TEX.U | TEX.V | [/code] Note the overlap. Also, I think it should be offset*sizeof(float). From the glVertexAttribPointer page: Same goes for stride, I think.[/QUOTE] Ok, added the w to the position, and texcoord is only 2 floats. Still the same thing.
[QUOTE=Darwin226;24732020]Ok, added the w to the position, and texcoord is only 2 floats. Still the same thing.[/QUOTE] It is pretty difficult to determine what's wrong with only partial code. It's particularly difficult because my laptop with the code for my two game engines blew up, so I don't have anything to compare against or show as an example. Could you paste the updated drawing routine plus your vertex and fragment shaders?
Sorry, you need to Log In to post a reply to this thread.