opengl


What am I doing wrong, in regards to multi-texture(OpenGL)?


I am writing a bump mapping demo, so I need an image texture, and a normal texture which should be loaded into the fragment shader.
This is the texture part of my OpenGL code:
glActiveTexture(GL_TEXTURE0);
GLuint textureID;
glGenTextures(1, &textureID);
glBindTexture(GL_TEXTURE_2D, textureID);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1024, 1024, 0, GL_RGB, GL_UNSIGNED_BYTE, brick);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
GLint textureLocation = glGetUniformLocation(shader, "texture");
glUniform1i(textureLocation, 0);
glActiveTexture(GL_TEXTURE1);
GLuint normal_textureID;
glGenTextures(1, &normal_textureID);
glBindTexture(GL_TEXTURE_2D, normal_textureID);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1024, 1024, 0, GL_RGB, GL_UNSIGNED_BYTE,
brick_texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
GLint normalTextureLocation = glGetUniformLocation(shader, "normal_texture");
glUniform1i(normalTextureLocation, 1);
Here is the fragment shader:
uniform vec3 light;
uniform sampler2D texture;
uniform sampler2D normal_texture;
void main() {
vec3 tex = texture2D(normal_texture, gl_TexCoord[0].st).rgb;
gl_FragColor = vec4(tex, 1.0);
}
I am sure that the brick array contains the image texture, and the brick_texture array contains the normal texture; but it seems normal_texture and texture are both the image texture, not the normal texture. What am I doing wrong, in regards to multi-texture?

Related Links

OpenGL installation/initialization
2 pass effect in opengl
Opengl terrain height/vertex
Opengl 3.2: How to use texture atlas?
OpenGL, target spot-light “following me around the room”!
Is it reasonable to use modern OpenGL context?
Convert stack of 2d images into 3d image, volume rendering
my matrix multiplication in OpenGL not as expected
Render 2D image (with depth) in OpenGL preserving depth testing
OpenGL: GL_REPEAT and GL_CLAMP_TO_EDGE
Is it necessary to call glEnable(GL_TEXTURE) before using textures in OpenGL 2.1?
“missing glut32.dll” with OpenGL under VS2010
Unexpected behaviour with GLSL Matrix
OpenGL Clip Space Frustum Culling Wrong Results
Best Way to update all vertices data in openGL and to recalculate normals
Encoding FBO textures to H.264 video directly on GPU

Categories

HOME
hpoo
xpath
mod-rewrite
svn
opencart
couchdb
haproxy
message-queue
hdfs
nsis
video-streaming
stored-procedures
gprs
selection
fasm
createjs
ex
async-await
synthesis
android-5.1.1-lollipop
vertica
akka-persistence
tableview
altium-designer
conda
eclipse-emf
pdf.js
password-generator
cellular-network
android-service
running-object-table
tortoisehg
acrobat
npoi
region
audit
tilemill
google-play-developer-api
universal
spring-rabbitmq
subclassing
landscape
google-now
stat
robust
optionaldataexception
fluid-mac-app-engine
vesta
django-static-precompiler
webvtt
exc-bad-access
pen
rcharts
sidewaffle
maatwebsite-excel
xcode6.4
fuzzer
wolfram-language
dojo-build
qpixmap
maximize
android-async-http
vimperator
place
chicagoboss
cfwheels
highest
wlanapi
replicaset
text-align
comctl32
n-tier-architecture
flurry-analytics
iodocs
producer
storing-data
libgcc
jini
code-complexity
fileshare
zend-search-lucene
wso2bam
radius-protocol
jomsocial
assetic
django-settings
hyphen
progress-db
discovery
rautomation
node.js-stream
void-pointers
web-frameworks
oembed
play2-mini
jmenu
servlet-container
ninject-interception
outlook-2007-addin
fgetc
facebook-fbml
html-components
efs
icon-language
jvm-bytecode
error-detection

Resources

Encrypt Message