I'm trying to load a texture on to a model but all I get is a grey color, no texture. The filepath to the image is correct and I am pretty sure the UVs are correct, everything was taken from a .obj file. I am pretty sure it's something wrong with my drawing but I can't quite find it.
I'm talking about lines 122 to 155 in this file here: [url]https://github.com/Bumrang/Engine/blob/master/obj/src/test.cpp[/url]
[code]glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texPyro);
glUniform1i(TextureID, 0)
glBindBuffer(GL_ARRAY_BUFFER, uvbuf);
GLint texAttrib = glGetAttribLocation( shader, "texPyro" );
glEnableVertexAttribArray(texAttrib);
glVertexAttribPointer( texAttrib, 2, GL_FLOAT, GL_FALSE, 0, 0 );
glActiveTexture (GL_TEXTURE0);
glBindTexture (GL_TEXTURE_2D , PyroTex);
image = SOIL_load_image ("obj/pyro_red.png" , &width , &height , 0 , SOIL_LOAD_RGB);
glTexImage2D (GL_TEXTURE_2D , 0 , GL_RGB , width , height , 0 , GL_RGB , GL_UNSIGNED_BYTE , image);
SOIL_free_image_data (image);
glUniform1i (glGetUniformLocation (shader , "texPyro") , 0);
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glDrawArrays(GL_TRIANGLES,0,vertices.size());
glDisableVertexAttribArray(posAttrib);
glDisableVertexAttribArray(texAttrib);[/code]
You can find the shaders [URL="https://github.com/Bumrang/Engine/tree/master/obj/src/glsl"]here[/URL] and the .obj file + texture (pyro.obj and pyro_red.png) [URL="https://github.com/Bumrang/Engine/tree/master/obj/obj"]here.[/URL]
This is what it looks like:
[t]http://i.imgur.com/oQoU4.png[/t]
Does anybody know of a program that can generate code to print all the variables of a c struct?
[QUOTE=Philly c;36611818]Does anybody know of a program that can generate code to print all the variables of a c struct?[/QUOTE]
I don't know of one, but I can't imagine it'd be too hard to write your own!
[QUOTE=Chris220;36611858]I don't know of one, but I can't imagine it'd be too hard to write your own![/QUOTE]
I know but i'm lazy and stupid.
[QUOTE=WTF Nuke;36607739]It was my fault with the near/far in the ortho settings, but I've fixed it now.
However, now I am trying to get VBOs to work, but have ran into trouble again. It just crashes the app right off the bat, here is how I declare the VBO:
[cpp]GLES20.glGenBuffers(1, vertBuffer, 0);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, vertBuffer[0]);
GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, 3*3*4, mTriangle1Vertices, GLES20.GL_STATIC_DRAW);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);[/cpp]
And here is how I attempt to draw it:
[cpp]GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, vertBuffer[0]);
GLES20.glEnableVertexAttribArray(mPositionHandle);
GLES20.glVertexAttribPointer(mPositionHandle, 3*3, GLES20.GL_FLOAT, false, 0, 0);
Matrix.multiplyMM(mMVPMatrix, 0, mProjectionMatrix, 0, mModelMatrix, 0);
GLES20.glUniformMatrix4fv(mMVPMatrixHandle, 1, false, mMVPMatrix, 0);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
GLES20.glDrawArrays(GLES20.GL_TRIANGLES, 0, 3);[/cpp]
I am just trying to draw a triangle, with float data, but am unsure how to debug on the Android. Also, am I able to use VAOs? The crash in question appears to be a seg fault.[/QUOTE]
Looks like you forgot to enable the attributes. Like so:
glEnableVertexAttribArray(mPositionHandle);
You have to do this for every vertex shader 'in'.
Even so, I segfault.
Edit: Oh my word, I accidentally the vertex attribute pointer by putting 3*3, instead of 3 (as I am passing 3 floats at a time). Works like a charm now.
I have a load of photos in a folder named as such:
IMG(1).jpg
IMG(2).jpg
IMG(3).jpg
IMG(4).jpg
IMG(5).jpg
IMG(6).jpg
IMG(7).jpg
IMG(8).jpg
IMG(9).jpg
IMG(10).jpg
IMG(11).jpg
IMG(12).jpg
...
and im writing a python script to do some stuff with them, I want to load them as 1,2,3,4,5,6,7,8,9,10,11,12...
However with my current script:
[cpp]
import os
fileList = []
for files in os.listdir("."):
if files.endswith(".jpg"):
fileList.append(files)
fileList.sort()
for f in fileList:
print(f)
[/cpp]
It lists them as: 1,10,11,12,13... 2,20,21,22...
Is there anyway to sort them the way I want to?
Im open to other languages if its easier with a different language(so long as it supports making system command line calls, but I think all languages should support that now a days)
[editline]4th July 2012[/editline]
cheated a bit :P just did:
[cpp]
#!/usr/bin/python3
import os
fileList = []
for files in os.listdir("."):
if files.endswith(".jpg"):
fileList.append(files)
fileList.sort()
i = 0
for f in fileList:
P1 = f.index('(')+1
P2 = f.index(')')
if(P2 - P1 < 3):
newFN = ""
num = f[P1:P2]
if(P2 - P1 == 1):
newFN = f[:P1] + "00" + num + f[P2:]
elif(P2 - P1 == 2):
newFN = f[:P1] + "0" + num + f[P2:]
os.rename(f, newFN)
[/cpp]
[QUOTE=Richy19;36623776]
It lists them as: 1,10,11,12,13... 2,20,21,22...
Is there anyway to sort them the way I want to?
Im open to other languages if its easier with a different language(so long as it supports making system command line calls, but I think all languages should support that now a days)[/QUOTE]
Try this (it's much cleaner than yours)
[code]
import os
fileList = []
for files in os.listdir("."):
if files.endswith(".jpg"):
fileList.append(files)
def extractNum(str):
[int(s) for s in str.split() if s.isdigit()]
fileList.sort(key=extractNum)
for f in fileList:
print(f)
[/code]
But yeah, you should generally rename your files to have the same amount of digits with zero padding. That way it sorts right in Windows Explorer too, and other applications.
Is there any way to make a program that connects to a game's master server and generates a server list without having to start up the game.
The game itself seems to connect here: [url]http://crypticsea.com/anewzero/serverinfo.php[/url]
to get the ip address, which is the same for 3 different games (A new zero, Hockey?, and Sub Rosa)
[QUOTE=jeimizu;36626588]Is there any way to make a program that connects to a game's master server and generates a server list without having to start up the game.
The game itself seems to connect here: [url]http://crypticsea.com/anewzero/serverinfo.php[/url]
to get the ip address, which is the same for 3 different games (A new zero, Hockey?, and Sub Rosa)[/QUOTE]
You'll have to reverse engineer it. There's applications that let you look at incoming and outgoing internet packets. Then you can use c++ or c# networking protocols to mimic it.
I want to go in to deferred rendering. I have a basic understanding. Draw the geometry, outputting all necessary lighting information. Then Light screen space using the buffers. Looking at this it makes sense to have a vertex shader that does the drawing, then the pixel shader that outputs the special data, then have another pixel shader that does the lighting shadows etc. My question is for the second stage, can you only run a pixel shader in OpenGL, if so how? Also is this the usual deferred model used as far as shaders?
-snip wrong thread :v:-
[QUOTE=flayne;36627225]I want to go in to deferred rendering. I have a basic understanding. Draw the geometry, outputting all necessary lighting information. Then Light screen space using the buffers. Looking at this it makes sense to have a vertex shader that does the drawing, then the pixel shader that outputs the special data, then have another pixel shader that does the lighting shadows etc. My question is for the second stage, can you only run a pixel shader in OpenGL, if so how? Also is this the usual deferred model used as far as shaders?[/QUOTE]
Run a PS that draws to a fullscreen quad.
[QUOTE=Naelstrom;36626771]You'll have to reverse engineer it. There's applications that let you look at incoming and outgoing internet packets. Then you can use c++ or c# networking protocols to mimic it.[/QUOTE]
Wireshark.
[QUOTE=Lord Ned;36627290]Run a PS that draws to a fullscreen quad.[/QUOTE]
Do that. Later, if you're bound by that frag shader, you can optimize and instead of drawing fullscreen quads, you can draw circles (low-res, 8 vertex circles) that contain each light's sphere of influence to reduce the amount of discarded fragments. You'll shave off a LOT of attenuation calculations that way.
[QUOTE=Richy19;36623776]I have a load of photos in a folder named as such:
IMG(1).jpg
IMG(2).jpg
IMG(3).jpg
IMG(4).jpg
IMG(5).jpg
IMG(6).jpg
IMG(7).jpg
IMG(8).jpg
IMG(9).jpg
IMG(10).jpg
IMG(11).jpg
IMG(12).jpg
...
and im writing a python script to do some stuff with them, I want to load them as 1,2,3,4,5,6,7,8,9,10,11,12...
However with my current script:
[cpp]
import os
fileList = []
for files in os.listdir("."):
if files.endswith(".jpg"):
fileList.append(files)
fileList.sort()
for f in fileList:
print(f)
[/cpp]
It lists them as: 1,10,11,12,13... 2,20,21,22...
Is there anyway to sort them the way I want to?
Im open to other languages if its easier with a different language(so long as it supports making system command line calls, but I think all languages should support that now a days)
[editline]4th July 2012[/editline]
cheated a bit :P just did:
[cpp]
#!/usr/bin/python3
import os
fileList = []
for files in os.listdir("."):
if files.endswith(".jpg"):
fileList.append(files)
fileList.sort()
i = 0
for f in fileList:
P1 = f.index('(')+1
P2 = f.index(')')
if(P2 - P1 < 3):
newFN = ""
num = f[P1:P2]
if(P2 - P1 == 1):
newFN = f[:P1] + "00" + num + f[P2:]
elif(P2 - P1 == 2):
newFN = f[:P1] + "0" + num + f[P2:]
os.rename(f, newFN)
[/cpp][/QUOTE]
use ruby
[cpp]
Dir["*.png"].sort_by { |f| f =~ /image\((\d+)\).png/; $1.to_i }
[/cpp]
Should you use glVertexAttribPointer before or after glEnableVertexAttribArray?
[QUOTE=WTF Nuke;36638858]Should you use glVertexAttribPointer before or after glEnableVertexAttribArray?[/QUOTE]
It doesn't matter as long as the attribute array is enabled before an associated drawing command is issued.
Ah, thanks. Also, on Android, can you make something be X amount of pixels wide and long? I have tried to divide the length and width and scale it, but is there an easier way? It seems to have some artifacts.
[QUOTE=WTF Nuke;36639969]Ah, thanks. Also, on Android, can you make something be X amount of pixels wide and long? I have tried to divide the length and width and scale it, but is there an easier way? It seems to have some artifacts.[/QUOTE]
Create an orthographic projection that goes from (0,0) to (width, height), then you can directly use pixels as values for your vertices.
[QUOTE=robmaister12;36640236]Create an orthographic projection that goes from (0,0) to (width, height), then you can directly use pixels as values for your vertices.[/QUOTE]
Something to keep in mind with using exact pixel values is there's a variety of different resolutions and configurations for Android devices.
Yup, which is why I am using the height and width given by onSurfaceChanged. Thanks for the advice, this will get me to doing cool shit.
[QUOTE=WTF Nuke;36640410]Yup, which is why I am using the height and width given by onSurfaceChanged. Thanks for the advice, this will get me to doing cool shit.[/QUOTE]
That still won't solve the issue of different screen resolutions. If you test your game on a device with a 480x800 screen and place a sprite at (400, 800) and someone else tries to play on a phone with a 320x480 resolution, they won't be able to see that sprite.
The best solution for a UI system is to either set up relative positioning or anchoring to one edge of the screen with padding.
[QUOTE=robmaister12;36640787]That still won't solve the issue of different screen resolutions. If you test your game on a device with a 480x800 screen and place a sprite at (400, 800) and someone else tries to play on a phone with a 320x480 resolution, they won't be able to see that sprite.
The best solution for a UI system is to either set up relative positioning or anchoring to one edge of the screen with padding.[/QUOTE]
What is the padding option? I can make it relative the width and height though.
[QUOTE=WTF Nuke;36641501]What is the padding option? I can make it relative the width and height though.[/QUOTE]
The padding option is to associate an edge or corner of the screen with each UI element and have it "stick" to that edge. For example, if you wanted to add a button to the right edge of the screen, you would set it's position to (screen_width - elementSize.X/2, elementPosition.Y).
You add padding to have it offset from the edge or corner it's stuck to. Typically you'll have 4 padding values - top, left, bottom, and right, but those are really only useful for full UI systems where the padding guarantees that there not be any other elements within the padding area of the element.
To use a very simple version of it, you can have 2 padding values, x and y. Positive values lead in towards the screen and negative values lead out away from the screen. Your implementation will look more complicated than this if you want positive values to point into the screen, but sticking an element to the right side of the screen with a 5px padding on the right will look like:
(screenWidth - elementSize.X/2 + padding.X, elementPosition.Y + padding.Y)
Oh ok thanks.
[QUOTE=LuaChobo;36648146]Sort of a dumb question but.
I got sams learn c++ an hour a day etc etc textbook, But i keep getting distracted whenever i sit down to read it.
Anyone got any tips on how I can stop being an autistic shit and get myself to concentrate on it?[/QUOTE]
I actually think autists would have an easy time concentrating on something, especially if it was what they're into.
But there's really no straight answer, to my knowledge, just get yourself together and get some willpower to focus on the subject and read up.
Otherwise, you could do what I do, read it all on the internet, so when you're tired of it, you can just come back and pick it up easily afterwards. The problem, of course, is the lack of resources compared to books.
[QUOTE=LuaChobo;36648146]Sort of a dumb question but.
I got sams learn c++ an hour a day etc etc textbook, But i keep getting distracted whenever i sit down to read it.
Anyone got any tips on how I can stop being an autistic shit and get myself to concentrate on it?[/QUOTE]
Well, what is distracting you? Remove the distraction, and you'll no longer be distracted by it.
[QUOTE=LuaChobo;36648146]Sort of a dumb question but.
I got sams learn c++ an hour a day etc etc textbook, But i keep getting distracted whenever i sit down to read it.
Anyone got any tips on how I can stop being an autistic shit and get myself to concentrate on it?[/QUOTE]
My motivation got boosted once I dedicated a workplace for my learning/programming. Try going to school, maybe the library to learn and work with programming.
Try dedicating a "place" you go to in order to learn. Learning at home will rarely work due to distractions.
Getting into programming is hard, really hard, and it will only stick if you have a genuine interest in the subject and discipline.
What would you guys recommend as a good IDE for a beginner learning C++?
Sorry, you need to Log In to post a reply to this thread.